diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index dfe9f697..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: 2.1 - -jobs: - build: - docker: - - image: holochain/holonix:latest.develop - steps: - - checkout - - run: nix-shell --fallback --run ./test.sh - - deploy-crates: - docker: - - image: holochain/holonix:latest - steps: - - checkout - - run: - no_output_timeout: 20m - command: nix-shell --fallback --run "hn-release-hook-publish-crates-io 'common host guest'" - -workflows: - version: 2.1 - tests: - jobs: - - build - - deploy: - jobs: - - deploy-crates: - filters: - branches: - ignore: /.*/ - tags: - only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa6762b1..a227266c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,15 +6,31 @@ on: - develop pull_request: {} +concurrency: + group: test-${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: - test: + test-and-bench: strategy: fail-fast: false matrix: - script: ["./test.sh", "./bench.sh"] + script: ["test", "bench"] os: ["ubuntu-latest", "macos-latest"] + wasmer-feature: ["wasmer_sys", "wasmer_wamr"] + exclude: + # TODO bench suite on macos-latest is killed by system due to running out of swap space + # All benches run fine individually + - script: bench + os: macos-latest + wasmer-feature: wasmer_wamr runs-on: ${{ matrix.os }} steps: + - name: increase swap space + if: matrix.os == 'ubuntu-latest' + uses: actionhippie/swap-space@v1 + with: + size: 15G - uses: actions/checkout@v4 - name: Install nix uses: cachix/install-nix-action@v26 @@ -24,4 +40,24 @@ jobs: with: name: holochain-ci authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - run: nix develop --command ${{ matrix.script }} + - run: nix develop --command ./scripts/${{ matrix.script }}-${{ matrix.wasmer-feature }}.sh + + test-windows: + strategy: + fail-fast: false + matrix: + wasmer-feature: + - "wasmer_sys" + # TODO Building with wasmer_wamr feature flag on windows is not currently working. + # See https://github.com/holochain/holochain-wasmer/issues/117 + # - "wasmer_wamr" + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + - name: test root + run: cargo test --release --no-default-features --features error_as_host,${{ matrix.wasmer-feature }} -- --nocapture + - name: test + run: cargo test --release --manifest-path test/Cargo.toml --no-default-features --features ${{ matrix.wasmer-feature }} -- --nocapture diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index b0e8fe72..00000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: run tests windows - -on: - push: - branches: - - develop - pull_request: {} - -jobs: - test: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - targets: wasm32-unknown-unknown - - run: cargo test -- --nocapture - - run: cargo test --manifest-path test/Cargo.toml -- --nocapture - - run: cd test && cargo bench diff --git a/README.md b/README.md index 5841b28c..e7caa3b3 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ very reasonable overhead for the host to build a completely fresh instance. Calling a function with `holochain_wasmer_host::guest::call()` takes several `us` for small input/output values and some `ms` for ~1mb of input/output data. -To see benchmarks on your system run `nix-shell --run ./bench.sh`. +To see benchmarks on your system run `nix-shell --run ./scripts/bench.sh`. With low overhead like this, core is relatively free to decide when it wants to re-instantiate an already-in-memory module. diff --git a/bench.sh b/scripts/bench-wasmer_sys.sh similarity index 74% rename from bench.sh rename to scripts/bench-wasmer_sys.sh index 7e00b729..63909ae5 100755 --- a/bench.sh +++ b/scripts/bench-wasmer_sys.sh @@ -1,7 +1,7 @@ #! /usr/bin/env bash ( cd test && \ - cargo bench + cargo bench --no-default-features --features wasmer_sys ) # it's possible to flamegraph the benchmarks like this: diff --git a/scripts/bench-wasmer_wamr.sh b/scripts/bench-wasmer_wamr.sh new file mode 100755 index 00000000..0fe9b6a8 --- /dev/null +++ b/scripts/bench-wasmer_wamr.sh @@ -0,0 +1,10 @@ +#! /usr/bin/env bash +( + cd test && \ + cargo bench --no-default-features --features wasmer_wamr +) + +# it's possible to flamegraph the benchmarks like this: +# +# cd test +# flamegraph cargo bench --bench bench -- --profile-time 10 diff --git a/scripts/bench.sh b/scripts/bench.sh new file mode 100644 index 00000000..ec8a8bb4 --- /dev/null +++ b/scripts/bench.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash + +./bench-wasmer_sys.sh && \ +./bench-wasmer_wamr.sh \ No newline at end of file diff --git a/fuzz.sh b/scripts/fuzz-wasmer_sys.sh similarity index 50% rename from fuzz.sh rename to scripts/fuzz-wasmer_sys.sh index b094610c..80472e81 100755 --- a/fuzz.sh +++ b/scripts/fuzz-wasmer_sys.sh @@ -2,4 +2,4 @@ cargo test cargo test --manifest-path test/Cargo.toml -cargo test-fuzz "$FUZZ_TARGET" \ No newline at end of file +cargo test-fuzz "$FUZZ_TARGET" --no-default-features --features wasmer_sys \ No newline at end of file diff --git a/scripts/fuzz-wasmer_wamr.sh b/scripts/fuzz-wasmer_wamr.sh new file mode 100755 index 00000000..88c39567 --- /dev/null +++ b/scripts/fuzz-wasmer_wamr.sh @@ -0,0 +1,5 @@ +#! /usr/bin/env bash +cargo test +cargo test --manifest-path test/Cargo.toml + +cargo test-fuzz "$FUZZ_TARGET" --no-default-features --features wasmer_wamr \ No newline at end of file diff --git a/scripts/fuzz.sh b/scripts/fuzz.sh new file mode 100644 index 00000000..c2b47543 --- /dev/null +++ b/scripts/fuzz.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash + +./fuzz-wasmer_sys.sh && \ +./fuzz-wasmer_wamr.sh \ No newline at end of file diff --git a/test.sh b/scripts/test-wasmer_sys.sh similarity index 56% rename from test.sh rename to scripts/test-wasmer_sys.sh index 0a7ce3fa..e748cad9 100755 --- a/test.sh +++ b/scripts/test-wasmer_sys.sh @@ -3,24 +3,21 @@ set -euxo pipefail export RUST_BACKTRACE=full export WASMER_BACKTRACE=1 + +# static tests cargo fmt -( cd test && cargo fmt ) -( cd crates/guest && cargo fmt ) +( cd test && cargo fmt --check ) +( cd crates/guest && cargo fmt --check ) cargo clippy ( cd test && cargo clippy ) ( cd crates/guest && cargo clippy --target wasm32-unknown-unknown ) -cargo clippy --no-default-features --features wasmer_wamr -( cd test && cargo clippy --no-default-features --features wasmer_wamr ) # tests the root workspace that doesn't include any wasm code -cargo test ${1-} -- --nocapture +cargo test --no-default-features --features error_as_host,wasmer_sys ${1-} -- --nocapture # test that everything builds cargo build --release --manifest-path test/test_wasm/Cargo.toml --target wasm32-unknown-unknown # build wasm and run the "full" tests for wasmer_sys -cargo test --release --manifest-path test/Cargo.toml ${1-} -- --nocapture - -# build wasm and run the "full" tests for wasmer_wamr -cargo test --release --manifest-path test/Cargo.toml --no-default-features --features wasmer_wamr ${1-} -- --nocapture +cargo test --release --manifest-path test/Cargo.toml --no-default-features --features wasmer_sys ${1-} -- --nocapture diff --git a/scripts/test-wasmer_wamr.sh b/scripts/test-wasmer_wamr.sh new file mode 100755 index 00000000..46b1d639 --- /dev/null +++ b/scripts/test-wasmer_wamr.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euxo pipefail + +export RUST_BACKTRACE=full +export WASMER_BACKTRACE=1 + + +# tests the root workspace that doesn't include any wasm code +cargo test --no-default-features --features error_as_host,wasmer_wamr ${1-} -- --nocapture + +# build wasm and run the "full" tests for wasmer_wamr +cargo test --release --manifest-path test/Cargo.toml --no-default-features --features wasmer_wamr ${1-} -- --nocapture diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100644 index 00000000..30908fcb --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash + +./test-wasmer_sys.sh && \ +./test-wasmer_wamr.sh \ No newline at end of file diff --git a/test/Cargo.lock b/test/Cargo.lock index 9cb796ab..cbb07f9e 100644 --- a/test/Cargo.lock +++ b/test/Cargo.lock @@ -361,9 +361,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "cmake" -version = "0.1.50" +version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a" dependencies = [ "cc", ] diff --git a/test/Cargo.toml b/test/Cargo.toml index c5d531ad..5d34c246 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] holochain_wasmer_common = { path = "../crates/common" } -holochain_wasmer_host = { path = "../crates/host", default-features = false } +holochain_wasmer_host = { path = "../crates/host", default-features = false, features = ["error_as_host"] } holochain_serialized_bytes = "=0.0.55" serde = "1" test_common = { path = "./common", default-features = false } diff --git a/test/benches/bench.rs b/test/benches/bench.rs index 72338627..bd096706 100644 --- a/test/benches/bench.rs +++ b/test/benches/bench.rs @@ -1,3 +1,7 @@ +// Temporarily include a fork of wasmer from the git branch 'wamr', until it is officially released in wasmer v5 +#[cfg(feature = "wasmer_wamr")] +extern crate hc_wasmer as wasmer; + use criterion::BenchmarkId; use criterion::Throughput; use criterion::{criterion_group, criterion_main, Criterion}; diff --git a/test/src/test.rs b/test/src/test.rs index 2461f366..f5b02324 100644 --- a/test/src/test.rs +++ b/test/src/test.rs @@ -1,6 +1,7 @@ pub mod import; pub mod wasms; +// Temporarily include a fork of wasmer from the git branch 'wamr', until it is officially released in wasmer v5 #[cfg(feature = "wasmer_wamr")] extern crate hc_wasmer as wasmer;