Skip to content

Commit

Permalink
CI: add WASM job (#656)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Bodigrim authored Sep 19, 2024
1 parent 378d4c3 commit 3f9773d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 13 deletions.
42 changes: 38 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,18 @@ jobs:
arch: ['s390x', 'ppc64le']
steps:
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2.5.0
- uses: uraimo/run-on-arch-action@v2.7.2
timeout-minutes: 60
with:
arch: ${{ matrix.arch }}
distro: ubuntu_rolling
githubToken: ${{ github.token }}
install: |
apt-get update -y
apt-get install -y curl ghc libghc-tasty-quickcheck-dev libghc-syb-dev
apt-get install -y ghc libghc-tasty-quickcheck-dev libghc-syb-dev
run: |
curl -s https://hackage.haskell.org/package/data-array-byte-0.1/data-array-byte-0.1.tar.gz | tar xz
ghc --version
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
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
./Main +RTS -s
bounds-checking:
Expand Down Expand Up @@ -232,3 +231,38 @@ jobs:
name: Run build (arm64v8 linux)
with:
args: sh -c "cabal update && cabal test"

wasi:
runs-on: ubuntu-latest
needs: build
env:
GHC_WASM_META_REV: a04cc1a2206d2030326e1d49be9c6a94ee4283a3
strategy:
matrix:
ghc: ['9.10']
fail-fast: false
steps:
- name: setup-ghc-wasm32-wasi
run: |
cd $(mktemp -d)
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
./setup.sh
~/.ghc-wasm/add_to_github_path.sh
env:
FLAVOUR: ${{ matrix.ghc }}
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.ghc-wasm/.cabal/store
key: wasi-${{ runner.os }}-${{ env.GHC_WASM_META_REV }}-flavour-${{ matrix.ghc }}-${{ github.sha }}
restore-keys: |
wasi-${{ runner.os }}-${{ env.GHC_WASM_META_REV }}-flavour-${{ matrix.ghc }}-
- name: Build
run: |
mv cabal.project.wasi cabal.project.local
wasm32-wasi-cabal build --enable-tests
wasm32-wasi-cabal list-bin test:bytestring-tests
- name: Test
run: |
wasmtime.sh $(wasm32-wasi-cabal list-bin test:bytestring-tests)
4 changes: 3 additions & 1 deletion bytestring.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ test-suite bytestring-tests
syb

ghc-options: -fwarn-unused-binds
-threaded -rtsopts
-rtsopts
if !arch(wasm32)
ghc-options: -threaded

benchmark bytestring-bench
import: language
Expand Down
5 changes: 5 additions & 0 deletions cabal.project.wasi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- https://github.com/haskellari/splitmix/pull/73
source-repository-package
type: git
location: https://github.com/amesgen/splitmix
tag: 5f5b766d97dc735ac228215d240a3bb90bc2ff75
4 changes: 4 additions & 0 deletions tests/Lift.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import qualified Data.ByteString.Short as SBS
import qualified Language.Haskell.TH.Syntax as TH

testSuite :: TestTree
#ifdef wasm32_HOST_ARCH
testSuite = testGroup "Skipped, requires -fexternal-interpreter" []
#else
testSuite = testGroup "Lift"
[ testGroup "strict"
[ testProperty "normal" $
Expand Down Expand Up @@ -62,3 +65,4 @@ testSuite = testGroup "Lift"
#endif
]
]
#endif
16 changes: 8 additions & 8 deletions tests/Properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -450,31 +450,31 @@ prop_read_write_file_P x = ioProperty $ do
P.writeFile fn x
y <- P.readFile fn
removeFile fn
return (x == y)
return (x === y)

prop_read_write_file_C x = ioProperty $ do
(fn, h) <- openTempFile "." "prop-compiled.tmp"
hClose h
C.writeFile fn x
y <- C.readFile fn
removeFile fn
return (x == y)
return (x === y)

prop_read_write_file_L x = ioProperty $ do
(fn, h) <- openTempFile "." "prop-compiled.tmp"
hClose h
L.writeFile fn x
y <- L.readFile fn
L.length y `seq` removeFile fn
return (x == y)
return (x === y)

prop_read_write_file_D x = ioProperty $ do
(fn, h) <- openTempFile "." "prop-compiled.tmp"
hClose h
D.writeFile fn x
y <- D.readFile fn
D.length y `seq` removeFile fn
return (x == y)
return (x === y)

------------------------------------------------------------------------

Expand All @@ -485,7 +485,7 @@ prop_append_file_P x y = ioProperty $ do
P.appendFile fn y
z <- P.readFile fn
removeFile fn
return (z == x `P.append` y)
return (z === x `P.append` y)

prop_append_file_C x y = ioProperty $ do
(fn, h) <- openTempFile "." "prop-compiled.tmp"
Expand All @@ -494,7 +494,7 @@ prop_append_file_C x y = ioProperty $ do
C.appendFile fn y
z <- C.readFile fn
removeFile fn
return (z == x `C.append` y)
return (z === x `C.append` y)

prop_append_file_L x y = ioProperty $ do
(fn, h) <- openTempFile "." "prop-compiled.tmp"
Expand All @@ -503,7 +503,7 @@ prop_append_file_L x y = ioProperty $ do
L.appendFile fn y
z <- L.readFile fn
L.length y `seq` removeFile fn
return (z == x `L.append` y)
return (z === x `L.append` y)

prop_append_file_D x y = ioProperty $ do
(fn, h) <- openTempFile "." "prop-compiled.tmp"
Expand All @@ -512,7 +512,7 @@ prop_append_file_D x y = ioProperty $ do
D.appendFile fn y
z <- D.readFile fn
D.length y `seq` removeFile fn
return (z == x `D.append` y)
return (z === x `D.append` y)

prop_packAddress = C.pack "this is a test"
==
Expand Down

0 comments on commit 3f9773d

Please sign in to comment.