diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index ab51a737c..c9230394b 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -25,6 +25,7 @@ jobs: "git-lfs", "github-cli", "go", + "haskell", "hugo", "java", "kubectl-helm-minikube", diff --git a/.github/workflows/test-pr.yaml b/.github/workflows/test-pr.yaml index fb586fb8b..5ee4dd0c5 100644 --- a/.github/workflows/test-pr.yaml +++ b/.github/workflows/test-pr.yaml @@ -25,6 +25,7 @@ jobs: git-lfs: ./**/git-lfs/** github-cli: ./**/github-cli/** go: ./**/go/** + haskell: ./**/haskell/** hugo: ./**/hugo/** java: ./**/java/** kubectl-helm-minikube: ./**/kubectl-helm-minikube/** diff --git a/src/haskell/NOTES.md b/src/haskell/NOTES.md new file mode 100644 index 000000000..19fe92f31 --- /dev/null +++ b/src/haskell/NOTES.md @@ -0,0 +1,7 @@ + + +## OS Support + +This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed. + +`bash` is required to execute the `install.sh` script. diff --git a/src/haskell/devcontainer-feature.json b/src/haskell/devcontainer-feature.json new file mode 100644 index 000000000..34aada1e8 --- /dev/null +++ b/src/haskell/devcontainer-feature.json @@ -0,0 +1,53 @@ +{ + "id": "haskell", + "version": "1.0.0", + "name": "Glasgow Haskell Compiler", + "documentationURL": "https://github.com/devcontainers/features/tree/main/src/haskell", + "description": "Installs the Glasgow Haskell Compiler", + "options": { + "version": { + "type": "string", + "proposals": [ + "latest", + "recommended", + "9.4.4", + "9.2.7" + ], + "default": "recommended", + "description": "Select or enter a GHC Version to install" + }, + "cabalVersion": { + "type": "string", + "proposals": [ + "latest", + "recommended", + "3.6.2.0" + ], + "default": "recommended", + "description": "Select or enter a Cabal Version to install" + }, + "hlsVersion": { + "type": "string", + "proposals": [ + "latest", + "recommended", + "1.9.0.0" + ], + "default": "recommended", + "description": "Select or enter a Haskell Language Server Version to install" + }, + "stackVersion": { + "type": "string", + "proposals": [ + "latest", + "recommended", + "2.9.3" + ], + "default": "recommended", + "description": "Select or enter a Stack Version to install" + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils" + ] +} \ No newline at end of file diff --git a/src/haskell/install.sh b/src/haskell/install.sh new file mode 100644 index 000000000..7edc7740a --- /dev/null +++ b/src/haskell/install.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -e +set -o xtrace + +GHCUP_VERSION="0.1.19.2" + +architecture="$(arch)" +GHCUP_BIN="${architecture}-linux-ghcup-${GHCUP_VERSION}" + +BOOTSTRAP_HASKELL_GHC_VERSION="${VERSION:-"recommended "}" + +# Maybe install curl, gcc, make +for x in curl gcc make; do + which $x > /dev/null || (apt update && apt install $x -y -qq) +done + +GHCUP_DIR=${_REMOTE_USER_HOME}/.ghcup/bin + +mkdir -p $GHCUP_DIR +echo https://downloads.haskell.org/~ghcup/${GHCUP_VERSION}/${architecture}-linux-ghcup-${GHCUP_VERSION} --output ${GHCUP_BIN} +curl https://downloads.haskell.org/~ghcup/${GHCUP_VERSION}/${architecture}-linux-ghcup-${GHCUP_VERSION} --output ${GHCUP_BIN} +# echo "25b7fc417c1a811dd7ff439b67ea647a59cf5b8d71b274f97e917d50b2150d5b ${GHCUP_BIN}" | sha256sum --check --status + +mv ${GHCUP_BIN} $GHCUP_DIR/ghcup +chmod a+x $GHCUP_DIR/ghcup + +export GHCUP_INSTALL_BASE_PREFIX=${_REMOTE_USER_HOME} + +${GHCUP_DIR}/ghcup install ghc $BOOTSTRAP_HASKELL_GHC_VERSION +${GHCUP_DIR}/ghcup install cabal $CABALVERSION +${GHCUP_DIR}/ghcup install hls $HLSVERSION +${GHCUP_DIR}/ghcup install stack $STACKVERSION + +${GHCUP_DIR}/ghcup set ghc $BOOTSTRAP_HASKELL_GHC_VERSION +${GHCUP_DIR}/ghcup set cabal $CABALVERSION +${GHCUP_DIR}/ghcup set hls $HLSVERSION +${GHCUP_DIR}/ghcup set stack $STACKVERSION + +# Clean up +rm -rf /var/lib/apt/lists/* + +echo "Done!" diff --git a/test/haskell/custom_version.sh b/test/haskell/custom_version.sh new file mode 100644 index 000000000..ffba722f3 --- /dev/null +++ b/test/haskell/custom_version.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "version" ~/.ghcup/bin/ghc --version | grep 9.2.6 + +# Report result +reportResults \ No newline at end of file diff --git a/test/haskell/default_version.sh b/test/haskell/default_version.sh new file mode 100644 index 000000000..652a43ea8 --- /dev/null +++ b/test/haskell/default_version.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +EXPECTED_VERSION=$(~/.ghcup/bin/ghcup list | grep "ghc " | grep recommended | awk '{print $3}') +echo ${EXPECTED_VERSION} +check "version" ~/.ghcup/bin/ghc --version | grep "${EXPECTED_VERSION}" + +# Report result +reportResults \ No newline at end of file diff --git a/test/haskell/mcr_version.sh b/test/haskell/mcr_version.sh new file mode 100644 index 000000000..ffba722f3 --- /dev/null +++ b/test/haskell/mcr_version.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "version" ~/.ghcup/bin/ghc --version | grep 9.2.6 + +# Report result +reportResults \ No newline at end of file diff --git a/test/haskell/scenarios.json b/test/haskell/scenarios.json new file mode 100644 index 000000000..e03bb5c83 --- /dev/null +++ b/test/haskell/scenarios.json @@ -0,0 +1,24 @@ +{ + "custom_version": { + "image": "ubuntu:focal", + "features": { + "haskell": { + "version": "9.2.6" + } + } + }, + "default_version": { + "image": "ubuntu:jammy", + "features": { + "haskell": {} + } + }, + "mcr_version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "haskell": { + "version": "9.2.6" + } + } + } +} \ No newline at end of file diff --git a/test/haskell/test.sh b/test/haskell/test.sh new file mode 100644 index 000000000..d15a996fd --- /dev/null +++ b/test/haskell/test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "version" ~/.ghcup/bin/ghcup list + +# Report result +reportResults \ No newline at end of file