Skip to content

Commit 22dedee

Browse files
committed
CI: add WASM job (#656)
* Don't build tests with threaded runtime on WASM * Skip lifting tests on WASM * Tests: improve reporting of mismatches for IO tests * Add WASM CI job * CI: upgrade incantations for emualted tests
1 parent 1b0536f commit 22dedee

File tree

5 files changed

+58
-13
lines changed

5 files changed

+58
-13
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,18 @@ jobs:
127127
arch: ['s390x', 'ppc64le']
128128
steps:
129129
- uses: actions/checkout@v4
130-
- uses: uraimo/run-on-arch-action@v2.5.0
130+
- uses: uraimo/run-on-arch-action@v2.7.2
131131
timeout-minutes: 60
132132
with:
133133
arch: ${{ matrix.arch }}
134134
distro: ubuntu_rolling
135135
githubToken: ${{ github.token }}
136136
install: |
137137
apt-get update -y
138-
apt-get install -y curl ghc libghc-tasty-quickcheck-dev libghc-syb-dev
138+
apt-get install -y ghc libghc-tasty-quickcheck-dev libghc-syb-dev
139139
run: |
140-
curl -s https://hackage.haskell.org/package/data-array-byte-0.1/data-array-byte-0.1.tar.gz | tar xz
141140
ghc --version
142-
ghc --make -XHaskell2010 -XBangPatterns -XDeriveDataTypeable -XDeriveGeneric -XDeriveLift -XFlexibleContexts -XFlexibleInstances -XLambdaCase -XMagicHash -XMultiWayIf -XNamedFieldPuns -XPatternSynonyms -XRankNTypes -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XTypeOperators -XUnboxedTuples -optP-Wall -optP-Werror=undef -DPURE_HASKELL=0 -Iinclude -itests:tests/builder:data-array-byte-0.1 -o Main cbits/*.c tests/Main.hs +RTS -s
141+
ghc --make -XHaskell2010 -XBangPatterns -XDeriveDataTypeable -XDeriveGeneric -XDeriveLift -XFlexibleContexts -XFlexibleInstances -XLambdaCase -XMagicHash -XMultiWayIf -XNamedFieldPuns -XPatternSynonyms -XRankNTypes -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XTypeOperators -XUnboxedTuples -optP-Wall -optP-Werror=undef -DPURE_HASKELL=0 -Iinclude -itests:tests/builder -o Main cbits/*.c tests/Main.hs +RTS -s
143142
./Main +RTS -s
144143
145144
bounds-checking:
@@ -232,3 +231,38 @@ jobs:
232231
name: Run build (arm64v8 linux)
233232
with:
234233
args: sh -c "cabal update && cabal test"
234+
235+
wasi:
236+
runs-on: ubuntu-latest
237+
needs: build
238+
env:
239+
GHC_WASM_META_REV: a04cc1a2206d2030326e1d49be9c6a94ee4283a3
240+
strategy:
241+
matrix:
242+
ghc: ['9.10']
243+
fail-fast: false
244+
steps:
245+
- name: setup-ghc-wasm32-wasi
246+
run: |
247+
cd $(mktemp -d)
248+
curl -L https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/archive/$GHC_WASM_META_REV/ghc-wasm-meta.tar.gz | tar xz --strip-components=1
249+
./setup.sh
250+
~/.ghc-wasm/add_to_github_path.sh
251+
env:
252+
FLAVOUR: ${{ matrix.ghc }}
253+
- uses: actions/checkout@v4
254+
- uses: actions/cache@v3
255+
with:
256+
path: |
257+
~/.ghc-wasm/.cabal/store
258+
key: wasi-${{ runner.os }}-${{ env.GHC_WASM_META_REV }}-flavour-${{ matrix.ghc }}-${{ github.sha }}
259+
restore-keys: |
260+
wasi-${{ runner.os }}-${{ env.GHC_WASM_META_REV }}-flavour-${{ matrix.ghc }}-
261+
- name: Build
262+
run: |
263+
mv cabal.project.wasi cabal.project.local
264+
wasm32-wasi-cabal build --enable-tests
265+
wasm32-wasi-cabal list-bin test:bytestring-tests
266+
- name: Test
267+
run: |
268+
wasmtime.sh $(wasm32-wasi-cabal list-bin test:bytestring-tests)

bytestring.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ test-suite bytestring-tests
220220
syb
221221

222222
ghc-options: -fwarn-unused-binds
223-
-threaded -rtsopts
223+
-rtsopts
224+
if !arch(wasm32)
225+
ghc-options: -threaded
224226

225227
benchmark bytestring-bench
226228
import: language

cabal.project.wasi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- https://github.com/haskellari/splitmix/pull/73
2+
source-repository-package
3+
type: git
4+
location: https://github.com/amesgen/splitmix
5+
tag: 5f5b766d97dc735ac228215d240a3bb90bc2ff75

tests/Lift.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import qualified Data.ByteString.Short as SBS
1313
import qualified Language.Haskell.TH.Syntax as TH
1414

1515
testSuite :: TestTree
16+
#ifdef wasm32_HOST_ARCH
17+
testSuite = testGroup "Skipped, requires -fexternal-interpreter" []
18+
#else
1619
testSuite = testGroup "Lift"
1720
[ testGroup "strict"
1821
[ testProperty "normal" $
@@ -62,3 +65,4 @@ testSuite = testGroup "Lift"
6265
#endif
6366
]
6467
]
68+
#endif

tests/Properties.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -450,31 +450,31 @@ prop_read_write_file_P x = ioProperty $ do
450450
P.writeFile fn x
451451
y <- P.readFile fn
452452
removeFile fn
453-
return (x == y)
453+
return (x === y)
454454

455455
prop_read_write_file_C x = ioProperty $ do
456456
(fn, h) <- openTempFile "." "prop-compiled.tmp"
457457
hClose h
458458
C.writeFile fn x
459459
y <- C.readFile fn
460460
removeFile fn
461-
return (x == y)
461+
return (x === y)
462462

463463
prop_read_write_file_L x = ioProperty $ do
464464
(fn, h) <- openTempFile "." "prop-compiled.tmp"
465465
hClose h
466466
L.writeFile fn x
467467
y <- L.readFile fn
468468
L.length y `seq` removeFile fn
469-
return (x == y)
469+
return (x === y)
470470

471471
prop_read_write_file_D x = ioProperty $ do
472472
(fn, h) <- openTempFile "." "prop-compiled.tmp"
473473
hClose h
474474
D.writeFile fn x
475475
y <- D.readFile fn
476476
D.length y `seq` removeFile fn
477-
return (x == y)
477+
return (x === y)
478478

479479
------------------------------------------------------------------------
480480

@@ -485,7 +485,7 @@ prop_append_file_P x y = ioProperty $ do
485485
P.appendFile fn y
486486
z <- P.readFile fn
487487
removeFile fn
488-
return (z == x `P.append` y)
488+
return (z === x `P.append` y)
489489

490490
prop_append_file_C x y = ioProperty $ do
491491
(fn, h) <- openTempFile "." "prop-compiled.tmp"
@@ -494,7 +494,7 @@ prop_append_file_C x y = ioProperty $ do
494494
C.appendFile fn y
495495
z <- C.readFile fn
496496
removeFile fn
497-
return (z == x `C.append` y)
497+
return (z === x `C.append` y)
498498

499499
prop_append_file_L x y = ioProperty $ do
500500
(fn, h) <- openTempFile "." "prop-compiled.tmp"
@@ -503,7 +503,7 @@ prop_append_file_L x y = ioProperty $ do
503503
L.appendFile fn y
504504
z <- L.readFile fn
505505
L.length y `seq` removeFile fn
506-
return (z == x `L.append` y)
506+
return (z === x `L.append` y)
507507

508508
prop_append_file_D x y = ioProperty $ do
509509
(fn, h) <- openTempFile "." "prop-compiled.tmp"
@@ -512,7 +512,7 @@ prop_append_file_D x y = ioProperty $ do
512512
D.appendFile fn y
513513
z <- D.readFile fn
514514
D.length y `seq` removeFile fn
515-
return (z == x `D.append` y)
515+
return (z === x `D.append` y)
516516

517517
prop_packAddress = C.pack "this is a test"
518518
==

0 commit comments

Comments
 (0)