on master help sign in
Merge pull request #1462 from haskell-servant/upgrade-ghcjs

Upgrade GHCJS

commitabc53b54e390ea3cb2abecca03414f999eb1d310 authorGaël Deest <gael.deest@tweag.io> dateMon 11 Oct 2021, 13:40 (5 years ago) parentb0f8c89b7c6a95
9 files changed+66−42
.github/run-ghcjs-tests.sh+14 .github/workflows/master.yml+14−34 cabal.ghcjs.project+4−1 ghcjs.nix+22 nix/nixpkgs.nix+4 nix/shell.nix+1−5 servant-client-core/servant-client-core.cabal+1−1 servant-client/servant-client.cabal+5 servant/servant.cabal+1−1
.github/run-ghcjs-tests.shnew file+14
@@ -0,0 +1,14 @@
1+#!/usr/bin/env bash
2+#
3+# cabal v2-test does not work with GHCJS
4+# See: https://github.com/haskell/cabal/issues/6175
5+#
6+# This invokes cabal-plan to figure out test binaries, and invokes them with node.
7+
8+cabal-plan list-bins '*:test:*' | while read -r line
9+do
10+ testpkg=$(echo "$line" | perl -pe 's/:.*//')
11+ testexe=$(echo "$line" | awk '{ print $2 }')
12+ echo "testing $textexe in package $textpkg"
13+ (cd "$testpkg" && node "$testexe".jsexe/all.js)
14+done
.github/workflows/master.yml+14−34
@@ -123,33 +123,22 @@ jobs:
123123 stack test --system-ghc
124124
125125 ghcjs:
126− name: ubuntu-18.04 / ghcjs 8.4
127− runs-on: "ubuntu-18.04"
126+ name: ubuntu-latest / ghcjs 8.6
127+ runs-on: "ubuntu-latest"
128128
129129 steps:
130130 - uses: actions/checkout@v2
131−
132− - name: "Setup PATH"
133− run: |
134− echo "PATH=$HOME/.cabal/bin:/opt/ghcjs/8.4/bin:$PATH" >> $GITHUB_ENV
135−
136− - name: Install ghcjs and cabal
131+ - uses: cachix/install-nix-action@v13
132+ with:
133+ extra_nix_config: |
134+ trusted-public-keys = ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=1aba6f367982bd6dd78ec2fda75ab246a62d32c5 cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
135+ substituters = https://nixcache.reflex-frp.org https://cache.nixos.org/
136+ - name: Setup
137137 run: |
138− # Default GitHub image dropped ppa:hvr/ghc, so we add it ourselves
139− sudo add-apt-repository ppa:hvr/ghc
140− sudo add-apt-repository ppa:hvr/ghcjs
141− sudo apt-get update -y
142− sudo apt-get install ghcjs-8.4
143− sudo apt-get install cabal-install
144−
145138 # Override cabal.project with the lightweight GHCJS one
146139 cp cabal.ghcjs.project cabal.project
147140 cat cabal.project
148−
149− - name: Cabal update and freeze
150− run: |
151− cabal v2-update
152− cabal v2-freeze
141+ nix-shell ghcjs.nix --run "cabal v2-update && cabal v2-freeze"
153142
154143 - uses: actions/cache@v2.1.3
155144 name: Cache ~/.cabal/store and dist-newstyle
@@ -157,23 +146,14 @@ jobs:
157146 path: |
158147 ~/.cabal/store
159148 dist-newstyle
160− key: ubuntu-18.04-ghcjs8.4-${{ hashFiles('cabal.project.freeze') }}
149+ key: ${{ runner.os }}-ghcjs8.6-${{ hashFiles('cabal.project.freeze') }}
161150 restore-keys: |
162− ubuntu-18.04-ghcjs8.4-
163−
164− - name: Install cabal-plan and hspec-discover
165− run: |
166− 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'
167− cabal v2-install -w /opt/ghc/8.4.4/bin/ghc --ignore-project hspec-discover
151+ ${{ runner.os }}-ghcjs8.6-
168152
169153 - name: Build
170154 run: |
171− cabal v2-build --ghcjs -w /opt/ghcjs/8.4/bin/ghcjs --enable-tests --enable-benchmarks all
155+ nix-shell ghcjs.nix --run "cabal v2-build --ghcjs --enable-tests --enable-benchmarks all"
172156
173− - name: Run tests
157+ - name: Tests
174158 run: |
175− # cabal v2-test does not work with GHCJS
176− # See: https://github.com/haskell/cabal/issues/6175
177− #
178− # This invokes cabal-plan to figure out test binaries, and invokes them with node.
179− 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
159+ nix-shell ghcjs.nix --run ".github/run-ghcjs-tests.sh"
cabal.ghcjs.project+4−1
@@ -2,10 +2,13 @@
22
33packages:
44 servant/
5+ servant-client/
56 servant-client-core/
67
78-- we need to tell cabal we are using GHCJS
89compiler: ghcjs
910tests: True
1011
11−constraints: hashable <=1.3.3.0
12+-- Constraints so that reflex-platform provided packages are selected.
13+constraints: attoparsec == 0.13.2.2
14+constraints: hashable == 1.3.0.0
ghcjs.nixnew file+22
@@ -0,0 +1,22 @@
1+let reflex-platform = import (builtins.fetchTarball
2+ { name = "reflex-platform";
3+ url = "https://github.com/reflex-frp/reflex-platform/archive/1aba6f367982bd6dd78ec2fda75ab246a62d32c5.tar.gz";
4+ }) {};
5+ pkgs = import ./nix/nixpkgs.nix; in
6+
7+pkgs.stdenv.mkDerivation {
8+ name = "ghcjs-shell";
9+ buildInputs =
10+ [ (reflex-platform.ghcjs.ghcWithPackages (p: with p; [
11+ attoparsec
12+ hashable
13+ ]))
14+ pkgs.cabal-install
15+ pkgs.gmp
16+ pkgs.haskellPackages.cabal-plan
17+ pkgs.haskellPackages.hspec-discover
18+ pkgs.nodejs
19+ pkgs.perl
20+ pkgs.zlib
21+ ];
22+}
nix/nixpkgs.nixnew file+4
@@ -0,0 +1,4 @@
1+import (builtins.fetchTarball {
2+ url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/21.05.tar.gz";
3+ sha256 = "sha256:1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
4+}) {}
nix/shell.nix+1−5
@@ -1,10 +1,6 @@
1−let nixos = fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/21.05.tar.gz";
2− sha256 = "sha256:1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
3−}; in
4−
51{ compiler ? "ghc8104"
62, tutorial ? false
7−, pkgs ? import nixos { config = {}; }
3+, pkgs ? import ./nixpkgs.nix
84}:
95
106 with pkgs;
servant-client-core/servant-client-core.cabal+1−1
@@ -17,7 +17,7 @@ maintainer: haskell-servant-maintainers@googlegroups.com
1717copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors
1818build-type: Simple
1919tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.2 || ==9.0.1
20− , GHCJS == 8.4
20+ , GHCJS ==8.6.0.1
2121
2222extra-source-files:
2323 CHANGELOG.md
servant-client/servant-client.cabal+5
@@ -21,6 +21,7 @@ maintainer: haskell-servant-maintainers@googlegroups.com
2121copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors
2222build-type: Simple
2323tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.2 || ==9.0.1
24+ , GHCJS ==8.6.0.1
2425
2526extra-source-files:
2627 CHANGELOG.md
@@ -82,6 +83,8 @@ test-suite spec
8283 type: exitcode-stdio-1.0
8384 ghc-options: -Wall -rtsopts -threaded "-with-rtsopts=-T -N2"
8485 default-language: Haskell2010
86+ if impl(ghcjs)
87+ buildable: False
8588 hs-source-dirs: test
8689 main-is: Spec.hs
8790 other-modules:
@@ -137,3 +140,5 @@ test-suite readme
137140 build-tool-depends: markdown-unlit:markdown-unlit
138141 ghc-options: -pgmL markdown-unlit
139142 default-language: Haskell2010
143+ if impl(ghcjs)
144+ buildable: False
servant/servant.cabal+1−1
@@ -21,7 +21,7 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant
2121build-type: Simple
2222
2323tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.2 || ==9.0.1
24− , GHCJS == 8.4
24+ , GHCJS ==8.6.0.1
2525
2626extra-source-files:
2727 CHANGELOG.md