From 7d90d4b0ed94bcdf293a3c5459b71ba6d24bef51 Mon Sep 17 00:00:00 2001 From: klezm <20573323+klezm@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:14:37 +0200 Subject: [PATCH 1/3] Fix issue 584 Add globalLibraries option --- src/haskell/devcontainer-feature.json | 13 +++++++++++-- src/haskell/install.sh | 12 ++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/haskell/devcontainer-feature.json b/src/haskell/devcontainer-feature.json index aa7246f99..3d4ee75ed 100644 --- a/src/haskell/devcontainer-feature.json +++ b/src/haskell/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Haskell (via ghcup)", "id": "haskell", - "version": "2.2.1", + "version": "2.2.2", "description": "Installs Haskell. An advanced, purely functional programming language", "documentationURL": "https://github.com/devcontainers-contrib/features/tree/main/src/haskell", "options": { @@ -31,11 +31,20 @@ "proposals": [ "", "hlint", - "hlint hspec pandoc" + "hlint pandoc-cli" ], "default": "", "description": "Packages to install via `cabal install`, such as `hlint` for linting. Separate with spaces. This will add significant initial build time." }, + "globalLibraries": { + "type": "string", + "proposals": [ + "", + "hspec hspec-contrib" + ], + "default": "", + "description": "Libraries to install via `cabal install --lib`, such as `hspec` for testing. Separate with spaces. This will add significant initial build time." + }, "installHLS": { "type": "boolean", "default": true, diff --git a/src/haskell/install.sh b/src/haskell/install.sh index ff23529ca..6390b0aec 100755 --- a/src/haskell/install.sh +++ b/src/haskell/install.sh @@ -9,6 +9,7 @@ ADJUST_BASHRC="${ADJUSTBASH:-"true"}" INSTALL_STACK_GHCUP_HOOK="${INSTALLSTACKGHCUPHOOK:-"true"}" CABAL_INSTALLS=`echo "${GLOBALPACKAGES:-""}" | tr ',' ' '` +CABAL_INSTALLS_LIBS=`echo "${GLOBALLIBRARIES:-""}" | tr ',' ' '` # Clean up rm -rf /var/lib/apt/lists/* @@ -85,8 +86,15 @@ sudo -iu "$_REMOTE_USER" < Date: Fri, 1 Nov 2024 11:35:33 +0000 Subject: [PATCH 2/3] Add test for Haskell globalLibraries option --- src/haskell/devcontainer-feature.json | 2 +- test/haskell/scenarios.json | 8 ++++++++ test/haskell/test_libraries.sh | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 test/haskell/test_libraries.sh diff --git a/src/haskell/devcontainer-feature.json b/src/haskell/devcontainer-feature.json index 3d4ee75ed..da5eb3e31 100644 --- a/src/haskell/devcontainer-feature.json +++ b/src/haskell/devcontainer-feature.json @@ -40,7 +40,7 @@ "type": "string", "proposals": [ "", - "hspec hspec-contrib" + "hspec hspec-contrib QuickCheck HUnit" ], "default": "", "description": "Libraries to install via `cabal install --lib`, such as `hspec` for testing. Separate with spaces. This will add significant initial build time." diff --git a/test/haskell/scenarios.json b/test/haskell/scenarios.json index 0475ebac3..3b027dee9 100644 --- a/test/haskell/scenarios.json +++ b/test/haskell/scenarios.json @@ -4,5 +4,13 @@ "features": { "haskell": {} } + }, + "test_libraries": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "haskell": { + "globalLibraries": "hspec hspec-contrib QuickCheck HUnit" + } + } } } \ No newline at end of file diff --git a/test/haskell/test_libraries.sh b/test/haskell/test_libraries.sh new file mode 100755 index 000000000..f4d55bf4b --- /dev/null +++ b/test/haskell/test_libraries.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + +check "cabal install --lib" ghc -e "import Test.Hspec; import Test.QuickCheck" + +reportResults From ee5094b5e788a0b16c58762f01d0d57aec394f16 Mon Sep 17 00:00:00 2001 From: klezm <20573323+klezm@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:52:43 +0000 Subject: [PATCH 3/3] Use smaller package for testing --- test/haskell/scenarios.json | 2 +- test/haskell/test_libraries.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/haskell/scenarios.json b/test/haskell/scenarios.json index 3b027dee9..d5985ce5a 100644 --- a/test/haskell/scenarios.json +++ b/test/haskell/scenarios.json @@ -9,7 +9,7 @@ "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { "haskell": { - "globalLibraries": "hspec hspec-contrib QuickCheck HUnit" + "globalLibraries": "stm" } } } diff --git a/test/haskell/test_libraries.sh b/test/haskell/test_libraries.sh index f4d55bf4b..b624d68a9 100755 --- a/test/haskell/test_libraries.sh +++ b/test/haskell/test_libraries.sh @@ -4,6 +4,6 @@ set -e source dev-container-features-test-lib -check "cabal install --lib" ghc -e "import Test.Hspec; import Test.QuickCheck" +check "cabal install --lib" ghc -e "import Control.Concurrent.STM" reportResults