Skip to content

Commit 910a3ae

Browse files
author
Gaël Deest
committed
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.
1 parent 48bc247 commit 910a3ae

File tree

6 files changed

+80
-10
lines changed

6 files changed

+80
-10
lines changed

.github/run-ghcjs-tests.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,40 @@ jobs:
172172
173173
- name: Run tests
174174
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.
179175
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
176+
177+
ghcjs-test:
178+
name: ghcjs-test
179+
runs-on: "ubuntu-latest"
180+
181+
steps:
182+
- uses: actions/checkout@v2
183+
- uses: cachix/install-nix-action@v13
184+
with:
185+
extra_nix_config: |
186+
trusted-public-keys = ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=1aba6f367982bd6dd78ec2fda75ab246a62d32c5 cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
187+
substituters = https://nixcache.reflex-frp.org https://cache.nixos.org/
188+
- name: Setup
189+
run: |
190+
# Override cabal.project with the lightweight GHCJS one
191+
cp cabal.ghcjs.project cabal.project
192+
cat cabal.project
193+
nix-shell ghcjs.nix --run "cabal v2-update && cabal v2-freeze"
194+
195+
- uses: actions/[email protected]
196+
name: Cache ~/.cabal/store and dist-newstyle
197+
with:
198+
path: |
199+
~/.cabal/store
200+
dist-newstyle
201+
key: ${{ runner.os }}-ghcjs8.6-${{ hashFiles('cabal.project.freeze') }}
202+
restore-keys: |
203+
${{ runner.os }}-ghcjs8.6-
204+
205+
- name: Build
206+
run: |
207+
nix-shell ghcjs.nix --run "cabal v2-build --ghcjs --enable-tests --enable-benchmarks all"
208+
209+
- name: Tests
210+
run: |
211+
nix-shell ghcjs.nix --run ".github/run-ghcjs-tests.sh"

cabal.ghcjs.project

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ packages:
88
compiler: ghcjs
99
tests: True
1010

11-
constraints: hashable <=1.3.3.0
11+
-- Constraints so that reflex-platform provided packages are selected.
12+
constraints: attoparsec == 0.13.2.2
13+
constraints: hashable == 1.3.0.0

ghcjs.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

0 commit comments

Comments
 (0)