From 069adfa89190a1a140ccb50c06793c6ccdbfe63f Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Thu, 14 Mar 2024 13:11:08 +0100 Subject: [PATCH 1/2] Fix wasm32 dev-dependencies --- Cargo.toml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 075247357e..0519ddb34b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,8 +135,6 @@ features = ["parallel"] signal-hook = { version = "0.3", optional = true } [dev-dependencies] -assert_cmd = "2.0" -criterion = "0.5" pretty_assertions = "1.4.0" interpolate_name = "0.2.4" nom = "7.1.3" @@ -145,6 +143,14 @@ rand = "0.8" rand_chacha = "0.3" semver = "1.0" +# Exclude dependencies and features that don't work on wasm32: +[target.'cfg(target_arch = "wasm32")'.dev-dependencies] +criterion = { version = "0.5", default-features = false } + +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +assert_cmd = "2.0" +criterion = "0.5" + [target.'cfg(fuzzing)'.dependencies] arbitrary = "1.3" interpolate_name = "0.2.4" From 2a96ba403b5d2d5e0301aaac00572e87a65c26ad Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Thu, 14 Mar 2024 12:40:07 +0100 Subject: [PATCH 2/2] Add CI job that runs tests on wasm32-wasi --- .github/workflows/rav1e.yml | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rav1e.yml b/.github/workflows/rav1e.yml index a9f981fe93..d2706a7309 100644 --- a/.github/workflows/rav1e.yml +++ b/.github/workflows/rav1e.yml @@ -49,9 +49,11 @@ jobs: - name: Install Rust 1.70.0 uses: dtolnay/rust-toolchain@1.70.0 with: - targets: wasm32-unknown-unknown + targets: wasm32-unknown-unknown, wasm32-wasi - uses: Swatinem/rust-cache@v2 + with: + prefix-key: v1-rust - name: Run cargo check run: cargo check @@ -63,6 +65,39 @@ jobs: --no-default-features -F wasm + - name: Run cargo check (wasi) + run: > + cargo check + --target wasm32-wasi + --no-default-features + + wasi: + runs-on: ubuntu-22.04 + needs: [rustfmt-clippy, msrv] + + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: '-Dwarnings' + CARGO_TARGET_WASM32_WASI_RUNNER: wasmtime + + steps: + - uses: actions/checkout@v4 + + - name: Install wasmtime + uses: taiki-e/install-action@wasmtime + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-wasi + - uses: Swatinem/rust-cache@v2 + + - name: Run tests + run: > + cargo test + --target wasm32-wasi + --no-default-features + build-unix: strategy: matrix: