From b39001699a1e3810c1b5015a2fc3d27e329e1d86 Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Thu, 30 Nov 2023 20:40:21 +0100 Subject: [PATCH 1/4] Build on JS and WASM backends Rename `ci.yml` to `ci.yaml` --- .github/workflows/{ci.yml => ci.yaml} | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) rename .github/workflows/{ci.yml => ci.yaml} (74%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yaml similarity index 74% rename from .github/workflows/ci.yml rename to .github/workflows/ci.yaml index 0ba092e..955a5bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yaml @@ -96,6 +96,48 @@ jobs: ghc --make -Isrc:test -isrc:test -DUseSIMD -o Tests cbits/bitvec_simd.c test/Main.hs +RTS -s ./Tests +RTS -s + js: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup + run: | + ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/develop/ghcup-cross-0.0.8.yaml + cabal update + - name: Install JS toolchain + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install latest + ./emsdk activate latest + source ./emsdk_env.sh + cd .. + emconfigure ghcup install ghc --set javascript-unknown-ghcjs-9.6.2 + - name: Build + run: | + cabal --with-compiler=javascript-unknown-ghcjs-ghc --with-hc-pkg=javascript-unknown-ghcjs-ghc-pkg build + + wasm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup + run: | + ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/develop/ghcup-cross-0.0.8.yaml + cabal update + - name: Install WASM toolchain + run: | + git clone https://gitlab.haskell.org/ghc/ghc-wasm-meta.git + cd ghc-wasm-meta/ + export SKIP_GHC=yes + ./setup.sh + source ~/.ghc-wasm/env + cd .. + ghcup install ghc --set wasm32-wasi-9.8.0.20230927 -- --host=x86_64-linux --with-intree-gmp --with-system-libffi + - name: Build + run: | + cabal --with-compiler=wasm32-wasi-ghc --with-hc-pkg=wasm32-wasi-ghc-pkg build + bounds-checking: needs: build runs-on: ubuntu-latest From 3ba23e198eeb4f125d331bca5763321091433bf8 Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Thu, 30 Nov 2023 23:04:16 +0100 Subject: [PATCH 2/4] Add caching for js and wasm jobs Use `haskell-actions/setup` instead of `haskell/actions/setup` --- .github/workflows/ci.yaml | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 955a5bb..5a910c0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,7 +19,7 @@ jobs: ghc: ['9.6', '9.4', '9.2', '9.0', '8.10', '8.8.4', '8.8.2', '8.8.1', '8.6', '8.4'] steps: - uses: actions/checkout@v3 - - uses: haskell/actions/setup@v2 + - uses: haskell-actions/setup@v2 id: setup-haskell-cabal with: ghc-version: ${{ matrix.ghc }} @@ -31,8 +31,6 @@ jobs: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} dist-newstyle key: ${{ runner.os }}-${{ matrix.ghc }} - restore-keys: | - ${{ runner.os }}-${{ matrix.ghc }}- - name: Build run: | echo packages:. > cabal.project @@ -97,9 +95,19 @@ jobs: ./Tests +RTS -s js: + needs: build runs-on: ubuntu-latest + env: + version: javascript-unknown-ghcjs-9.6.2 steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + name: Cache cabal stuff + with: + path: | + ~/.cabal/store + dist-newstyle + key: ${{ env.version }} - name: Setup run: | ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/develop/ghcup-cross-0.0.8.yaml @@ -112,15 +120,25 @@ jobs: ./emsdk activate latest source ./emsdk_env.sh cd .. - emconfigure ghcup install ghc --set javascript-unknown-ghcjs-9.6.2 + emconfigure ghcup install ghc --set ${{ env.version }} - name: Build run: | cabal --with-compiler=javascript-unknown-ghcjs-ghc --with-hc-pkg=javascript-unknown-ghcjs-ghc-pkg build wasm: + needs: build runs-on: ubuntu-latest + env: + version: wasm32-wasi-9.8.0.20230927 steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + name: Cache cabal stuff + with: + path: | + ~/.cabal/store + dist-newstyle + key: ${{ env.version }} - name: Setup run: | ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/develop/ghcup-cross-0.0.8.yaml @@ -133,7 +151,7 @@ jobs: ./setup.sh source ~/.ghc-wasm/env cd .. - ghcup install ghc --set wasm32-wasi-9.8.0.20230927 -- --host=x86_64-linux --with-intree-gmp --with-system-libffi + ghcup install ghc --set ${{ env.version }} -- --host=x86_64-linux --with-intree-gmp --with-system-libffi - name: Build run: | cabal --with-compiler=wasm32-wasi-ghc --with-hc-pkg=wasm32-wasi-ghc-pkg build @@ -143,7 +161,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: haskell/actions/setup@v2 + - uses: haskell-actions/setup@v2 id: setup-haskell-cabal with: ghc-version: 'latest' From 5080716b4c0a100f93184b0af65bd4862b75533a Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Fri, 1 Dec 2023 19:18:05 +0100 Subject: [PATCH 3/4] Add `cabal.project` Add `.vscode` to `.gitignore` --- .cirrus.yaml | 11 +++++++++++ .cirrus.yml | 11 ----------- .github/workflows/ci.yaml | 14 ++++---------- .gitignore | 6 ++++++ cabal.project | 4 ++++ 5 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 .cirrus.yaml delete mode 100644 .cirrus.yml create mode 100644 cabal.project diff --git a/.cirrus.yaml b/.cirrus.yaml new file mode 100644 index 0000000..a430812 --- /dev/null +++ b/.cirrus.yaml @@ -0,0 +1,11 @@ +freebsd_instance: + image_family: freebsd-13-1 + +task: + install_script: pkg install -y ghc hs-cabal-install git + script: + - ghc --version + - cabal --version + - cabal update + - cabal test --test-show-details=direct --enable-tests + - cabal test -f-simd --test-show-details=direct --enable-tests diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index b984c60..0000000 --- a/.cirrus.yml +++ /dev/null @@ -1,11 +0,0 @@ -freebsd_instance: - image_family: freebsd-13-1 - -task: - install_script: pkg install -y ghc hs-cabal-install git - script: - - ghc --version - - cabal --version - - cabal update - - cabal test --test-show-details=direct -c 'quickcheck-classes -semigroupoids -aeson -semirings' --enable-tests - - cabal test -f-simd --test-show-details=direct -c 'quickcheck-classes -semigroupoids -aeson -semirings' --enable-tests diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5a910c0..21af1bb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,16 +33,13 @@ jobs: key: ${{ runner.os }}-${{ matrix.ghc }} - name: Build run: | - echo packages:. > cabal.project - echo tests:True >> cabal.project - echo "constraints:quickcheck-classes -semigroupoids -aeson -semirings" >> cabal.project - cabal test --test-show-details=direct + cabal test --enable-tests --test-show-details=direct cabal bench --benchmark-option=-l cabal sdist cabal check - name: Build without SIMD run: | - cabal test -f-simd --test-show-details=direct + cabal test -f-simd --enable-tests --test-show-details=direct - name: Haddock if: ${{ matrix.ghc != '8.0' && matrix.ghc != '8.2' && matrix.ghc != '8.4' }} run: cabal haddock @@ -176,11 +173,8 @@ jobs: key: ${{ runner.os }}-latest - name: Test run: | - echo packages:. > cabal.project - echo tests:True >> cabal.project - echo "constraints:quickcheck-classes -semigroupoids -aeson -semirings" >> cabal.project echo "constraints:vector +unsafechecks +internalchecks" >> cabal.project # Some tests are filtered out because of # https://gitlab.haskell.org/ghc/ghc/-/issues/23132 - cabal run tests --test-show-details=direct --ghc-options='-fcheck-prim-bounds -fno-ignore-asserts' -- -p '$NF!~/cloneFromWords8/&&$NF!~/cloneToByteString/' - cabal run tests -f-simd --test-show-details=direct --ghc-options='-fcheck-prim-bounds -fno-ignore-asserts' -- -p '$NF!~/cloneFromWords8/&&$NF!~/cloneToByteString/' + cabal run tests --enable-tests --test-show-details=direct --ghc-options='-fcheck-prim-bounds -fno-ignore-asserts' -- -p '$NF!~/cloneFromWords8/&&$NF!~/cloneToByteString/' + cabal run tests -f-simd --enable-tests --test-show-details=direct --ghc-options='-fcheck-prim-bounds -fno-ignore-asserts' -- -p '$NF!~/cloneFromWords8/&&$NF!~/cloneToByteString/' diff --git a/.gitignore b/.gitignore index 80e2db4..334f427 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,9 @@ dist-newstyle cabal.sandbox.config .cabal-sandbox + +######## +# IDEs # +######## + +.vscode diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..868d232 --- /dev/null +++ b/cabal.project @@ -0,0 +1,4 @@ +packages: . + +package quickcheck-classes + flags: -aeson -semigroupoids -semirings From 65fe3cdb9991aeea610bac53abed23df8f497cb0 Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Sat, 2 Dec 2023 15:12:46 +0100 Subject: [PATCH 4/4] Run WASM tests --- .github/workflows/ci.yaml | 6 +++++- bitvec.cabal | 4 +++- cabal.project.wasi | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 cabal.project.wasi diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 21af1bb..dd32e22 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -147,11 +147,15 @@ jobs: export SKIP_GHC=yes ./setup.sh source ~/.ghc-wasm/env + ~/.ghc-wasm/add_to_github_path.sh cd .. ghcup install ghc --set ${{ env.version }} -- --host=x86_64-linux --with-intree-gmp --with-system-libffi - name: Build run: | - cabal --with-compiler=wasm32-wasi-ghc --with-hc-pkg=wasm32-wasi-ghc-pkg build + mv cabal.project.wasi cabal.project.local + cabal --with-compiler=wasm32-wasi-ghc --with-hc-pkg=wasm32-wasi-ghc-pkg build --enable-tests + cabal --with-compiler=wasm32-wasi-ghc --with-hc-pkg=wasm32-wasi-ghc-pkg list-bin test:bitvec-tests --enable-tests + wasmtime $(cabal --with-compiler=wasm32-wasi-ghc --with-hc-pkg=wasm32-wasi-ghc-pkg list-bin test:bitvec-tests --enable-tests) bounds-checking: needs: build diff --git a/bitvec.cabal b/bitvec.cabal index 858596d..43e9191 100644 --- a/bitvec.cabal +++ b/bitvec.cabal @@ -128,7 +128,9 @@ test-suite bitvec-tests Tests.SetOps Tests.SetOpsTS Tests.Vector - ghc-options: -Wall -threaded -rtsopts -Wcompat + ghc-options: -Wall -Wcompat + if !arch(wasm32) + ghc-options: -threaded -rtsopts include-dirs: test if impl(ghc <9.0) diff --git a/cabal.project.wasi b/cabal.project.wasi new file mode 100644 index 0000000..386cf71 --- /dev/null +++ b/cabal.project.wasi @@ -0,0 +1,5 @@ +-- https://github.com/haskellari/splitmix/pull/73 +source-repository-package + type: git + location: https://github.com/amesgen/splitmix.git + tag: 83b906c4bcdc2720546f1779a16eb65e8e12ecba