Skip to content

Commit

Permalink
Merge pull request #116 from holochain/fix/integration-wasmer-wamr
Browse files Browse the repository at this point in the history
Improve CI for wasmer_wamr feature
  • Loading branch information
mattyg authored Sep 11, 2024
2 parents 383b592 + cd985e0 commit 280f3ac
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 70 deletions.
33 changes: 0 additions & 33 deletions .circleci/config.yml

This file was deleted.

42 changes: 39 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
19 changes: 0 additions & 19 deletions .github/workflows/windows.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion bench.sh → scripts/bench-wasmer_sys.sh
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
10 changes: 10 additions & 0 deletions scripts/bench-wasmer_wamr.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions scripts/bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /usr/bin/env bash

./bench-wasmer_sys.sh && \
./bench-wasmer_wamr.sh
2 changes: 1 addition & 1 deletion fuzz.sh → scripts/fuzz-wasmer_sys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
cargo test
cargo test --manifest-path test/Cargo.toml

cargo test-fuzz "$FUZZ_TARGET"
cargo test-fuzz "$FUZZ_TARGET" --no-default-features --features wasmer_sys
5 changes: 5 additions & 0 deletions scripts/fuzz-wasmer_wamr.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions scripts/fuzz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /usr/bin/env bash

./fuzz-wasmer_sys.sh && \
./fuzz-wasmer_wamr.sh
15 changes: 6 additions & 9 deletions test.sh → scripts/test-wasmer_sys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions scripts/test-wasmer_wamr.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /usr/bin/env bash

./test-wasmer_sys.sh && \
./test-wasmer_wamr.sh
4 changes: 2 additions & 2 deletions test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 4 additions & 0 deletions test/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 1 addition & 0 deletions test/src/test.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down

0 comments on commit 280f3ac

Please sign in to comment.