From 910a3ae7ec94d2ec671969a1545fbd3c6e1e712a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Deest?= Date: Sat, 9 Oct 2021 13:27:01 +0200 Subject: [PATCH 1/3] Upgrade GHCJS to 8.6 This allows us to deprecate GHCJS 8.4 (which makes sense, as vanilla GHC < 8.6 is already deprecated). We re-use GHCJS from reflex-platform, which unfortunately isn't up-to-date with latest GHC and is only 8.6. The benefit of using reflex-platform is that it provides nix expressions for GHCJS + a binary nix cache. reflex-platform patches text to use a JS-String based internal representation for performance reasons, so we provide a few haskell dependencies from reflex-platform as well: - hashable - attoparsec As those rely on text's internal representation but have been patched for reflex-platform. --- .github/run-ghcjs-tests.sh | 14 +++++++++++++ .github/workflows/master.yml | 40 ++++++++++++++++++++++++++++++++---- cabal.ghcjs.project | 4 +++- ghcjs.nix | 22 ++++++++++++++++++++ nix/nixpkgs.nix | 4 ++++ nix/shell.nix | 6 +----- 6 files changed, 80 insertions(+), 10 deletions(-) create mode 100755 .github/run-ghcjs-tests.sh create mode 100644 ghcjs.nix create mode 100644 nix/nixpkgs.nix diff --git a/.github/run-ghcjs-tests.sh b/.github/run-ghcjs-tests.sh new file mode 100755 index 00000000..19e0d9b7 --- /dev/null +++ b/.github/run-ghcjs-tests.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# +# cabal v2-test does not work with GHCJS +# See: https://github.com/haskell/cabal/issues/6175 +# +# This invokes cabal-plan to figure out test binaries, and invokes them with node. + +cabal-plan list-bins '*:test:*' | while read -r line +do + testpkg=$(echo "$line" | perl -pe 's/:.*//') + testexe=$(echo "$line" | awk '{ print $2 }') + echo "testing $textexe in package $textpkg" + (cd "$testpkg" && node "$testexe".jsexe/all.js) +done diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 2eea692c..642b4e30 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -172,8 +172,40 @@ jobs: - name: Run tests run: | - # cabal v2-test does not work with GHCJS - # See: https://github.com/haskell/cabal/issues/6175 - # - # This invokes cabal-plan to figure out test binaries, and invokes them with node. cabal-plan list-bins '*:test:*' | while read -r line; do testpkg=$(echo "$line" | perl -pe 's/:.*//'); testexe=$(echo "$line" | awk '{ print $2 }'); echo "testing $textexe in package $textpkg"; (cd "$(pkgdir $testpkg)" && nodejs "$testexe".jsexe/all.js); done + + ghcjs-test: + name: ghcjs-test + runs-on: "ubuntu-latest" + + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v13 + with: + extra_nix_config: | + trusted-public-keys = ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=1aba6f367982bd6dd78ec2fda75ab246a62d32c5 cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://nixcache.reflex-frp.org https://cache.nixos.org/ + - name: Setup + run: | + # Override cabal.project with the lightweight GHCJS one + cp cabal.ghcjs.project cabal.project + cat cabal.project + nix-shell ghcjs.nix --run "cabal v2-update && cabal v2-freeze" + + - uses: actions/cache@v2.1.3 + name: Cache ~/.cabal/store and dist-newstyle + with: + path: | + ~/.cabal/store + dist-newstyle + key: ${{ runner.os }}-ghcjs8.6-${{ hashFiles('cabal.project.freeze') }} + restore-keys: | + ${{ runner.os }}-ghcjs8.6- + + - name: Build + run: | + nix-shell ghcjs.nix --run "cabal v2-build --ghcjs --enable-tests --enable-benchmarks all" + + - name: Tests + run: | + nix-shell ghcjs.nix --run ".github/run-ghcjs-tests.sh" diff --git a/cabal.ghcjs.project b/cabal.ghcjs.project index 72902332..db1ef33a 100644 --- a/cabal.ghcjs.project +++ b/cabal.ghcjs.project @@ -8,4 +8,6 @@ packages: compiler: ghcjs tests: True -constraints: hashable <=1.3.3.0 +-- Constraints so that reflex-platform provided packages are selected. +constraints: attoparsec == 0.13.2.2 +constraints: hashable == 1.3.0.0 diff --git a/ghcjs.nix b/ghcjs.nix new file mode 100644 index 00000000..274d007c --- /dev/null +++ b/ghcjs.nix @@ -0,0 +1,22 @@ +let reflex-platform = import (builtins.fetchTarball + { name = "reflex-platform"; + url = "https://github.com/reflex-frp/reflex-platform/archive/1aba6f367982bd6dd78ec2fda75ab246a62d32c5.tar.gz"; + }) {}; + pkgs = import ./nix/nixpkgs.nix; in + +pkgs.stdenv.mkDerivation { + name = "ghcjs-shell"; + buildInputs = + [ (reflex-platform.ghcjs.ghcWithPackages (p: with p; [ + attoparsec + hashable + ])) + pkgs.cabal-install + pkgs.gmp + pkgs.haskellPackages.cabal-plan + pkgs.haskellPackages.hspec-discover + pkgs.nodejs + pkgs.perl + pkgs.zlib + ]; +} diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix new file mode 100644 index 00000000..744f982c --- /dev/null +++ b/nix/nixpkgs.nix @@ -0,0 +1,4 @@ +import (builtins.fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/21.05.tar.gz"; + sha256 = "sha256:1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36"; +}) {} diff --git a/nix/shell.nix b/nix/shell.nix index 715004f6..d178b60e 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -1,10 +1,6 @@ -let nixos = fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/21.05.tar.gz"; - sha256 = "sha256:1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36"; -}; in - { compiler ? "ghc8104" , tutorial ? false -, pkgs ? import nixos { config = {}; } +, pkgs ? import ./nixpkgs.nix }: with pkgs; From e9ae1eeed87fe6aa3e521158169ba7f804a33778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Deest?= Date: Sun, 10 Oct 2021 22:52:13 +0200 Subject: [PATCH 2/3] Remove the old Github action --- .github/workflows/master.yml | 54 +----------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 642b4e30..04b94995 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -123,59 +123,7 @@ jobs: stack test --system-ghc ghcjs: - name: ubuntu-18.04 / ghcjs 8.4 - runs-on: "ubuntu-18.04" - - steps: - - uses: actions/checkout@v2 - - - name: "Setup PATH" - run: | - echo "PATH=$HOME/.cabal/bin:/opt/ghcjs/8.4/bin:$PATH" >> $GITHUB_ENV - - - name: Install ghcjs and cabal - run: | - # Default GitHub image dropped ppa:hvr/ghc, so we add it ourselves - sudo add-apt-repository ppa:hvr/ghc - sudo add-apt-repository ppa:hvr/ghcjs - sudo apt-get update -y - sudo apt-get install ghcjs-8.4 - sudo apt-get install cabal-install - - # Override cabal.project with the lightweight GHCJS one - cp cabal.ghcjs.project cabal.project - cat cabal.project - - - name: Cabal update and freeze - run: | - cabal v2-update - cabal v2-freeze - - - uses: actions/cache@v2.1.3 - name: Cache ~/.cabal/store and dist-newstyle - with: - path: | - ~/.cabal/store - dist-newstyle - key: ubuntu-18.04-ghcjs8.4-${{ hashFiles('cabal.project.freeze') }} - restore-keys: | - ubuntu-18.04-ghcjs8.4- - - - name: Install cabal-plan and hspec-discover - run: | - cabal v2-install -w /opt/ghc/8.4.4/bin/ghc --ignore-project cabal-plan --constraint='cabal-plan ^>=0.6.0.0' --constraint='cabal-plan +exe' - cabal v2-install -w /opt/ghc/8.4.4/bin/ghc --ignore-project hspec-discover - - - name: Build - run: | - cabal v2-build --ghcjs -w /opt/ghcjs/8.4/bin/ghcjs --enable-tests --enable-benchmarks all - - - name: Run tests - run: | - cabal-plan list-bins '*:test:*' | while read -r line; do testpkg=$(echo "$line" | perl -pe 's/:.*//'); testexe=$(echo "$line" | awk '{ print $2 }'); echo "testing $textexe in package $textpkg"; (cd "$(pkgdir $testpkg)" && nodejs "$testexe".jsexe/all.js); done - - ghcjs-test: - name: ghcjs-test + name: ubuntu-latest / ghcjs 8.6 runs-on: "ubuntu-latest" steps: From b7c6a9592967da8d8df5804339a755e4125da83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Deest?= Date: Mon, 11 Oct 2021 10:35:40 +0200 Subject: [PATCH 3/3] Fix tested-with fields in Cabal files Also re-added `servant-client` to `cabal.ghcjs.project`, setting `buildable: False` on tests as they don't run with GHCJS. --- cabal.ghcjs.project | 1 + servant-client-core/servant-client-core.cabal | 2 +- servant-client/servant-client.cabal | 5 +++++ servant/servant.cabal | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cabal.ghcjs.project b/cabal.ghcjs.project index db1ef33a..46d74b2c 100644 --- a/cabal.ghcjs.project +++ b/cabal.ghcjs.project @@ -2,6 +2,7 @@ packages: servant/ + servant-client/ servant-client-core/ -- we need to tell cabal we are using GHCJS diff --git a/servant-client-core/servant-client-core.cabal b/servant-client-core/servant-client-core.cabal index b1008f36..e4bc3ba7 100644 --- a/servant-client-core/servant-client-core.cabal +++ b/servant-client-core/servant-client-core.cabal @@ -17,7 +17,7 @@ maintainer: haskell-servant-maintainers@googlegroups.com copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors build-type: Simple tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.2 || ==9.0.1 - , GHCJS == 8.4 + , GHCJS ==8.6.0.1 extra-source-files: CHANGELOG.md diff --git a/servant-client/servant-client.cabal b/servant-client/servant-client.cabal index 8f69a4ad..481dbd0a 100644 --- a/servant-client/servant-client.cabal +++ b/servant-client/servant-client.cabal @@ -21,6 +21,7 @@ maintainer: haskell-servant-maintainers@googlegroups.com copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors build-type: Simple tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.2 || ==9.0.1 + , GHCJS ==8.6.0.1 extra-source-files: CHANGELOG.md @@ -82,6 +83,8 @@ test-suite spec type: exitcode-stdio-1.0 ghc-options: -Wall -rtsopts -threaded "-with-rtsopts=-T -N2" default-language: Haskell2010 + if impl(ghcjs) + buildable: False hs-source-dirs: test main-is: Spec.hs other-modules: @@ -137,3 +140,5 @@ test-suite readme build-tool-depends: markdown-unlit:markdown-unlit ghc-options: -pgmL markdown-unlit default-language: Haskell2010 + if impl(ghcjs) + buildable: False diff --git a/servant/servant.cabal b/servant/servant.cabal index 8dd79c75..7c7af0a1 100644 --- a/servant/servant.cabal +++ b/servant/servant.cabal @@ -21,7 +21,7 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant build-type: Simple tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.2 || ==9.0.1 - , GHCJS == 8.4 + , GHCJS ==8.6.0.1 extra-source-files: CHANGELOG.md