From f8413405b6986a5adf3ed51a02535e0ab9c70307 Mon Sep 17 00:00:00 2001 From: Bede Constantinides Date: Fri, 23 Oct 2026 16:15:45 +0100 Subject: [PATCH] Test wasm32 with and without simd128 in CI Make packed-seq's rand dev-only so builds work for wasm32-unknown-unknown as well as wasi target. --- .github/workflows/rust.yml | 16 ++++++++++++++++ Cargo.toml | 3 ++- scripts/wasi-node.mjs | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 scripts/wasi-node.mjs diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ead6b4b..784ab7f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -27,3 +27,19 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose + + test-wasm: + runs-on: ubuntu-latest + strategy: + matrix: + simd128: ["-simd128", "+simd128"] + env: + RUSTFLAGS: -C target-feature=${{ matrix.simd128 }} + CARGO_TARGET_WASM32_WASIP1_RUNNER: node --no-warnings scripts/wasi-node.mjs + steps: + - uses: actions/checkout@v4 + - run: rustup target add wasm32-wasip1 wasm32-unknown-unknown + - name: Check wasm32-unknown-unknown + run: cargo check --verbose --release --lib --features scalar --target wasm32-unknown-unknown + - name: Run release tests + run: cargo test --verbose --release --features scalar --target wasm32-wasip1 diff --git a/Cargo.toml b/Cargo.toml index d74e763..0461e1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,11 @@ authors = ["Ragnar Groot Koerkamp", "Igor Martayan"] description = "A SIMD-accelerated library to compute hashes of DNA sequences" [dependencies] -packed-seq = "5.0" +packed-seq = { version = "5.0", default-features = false } [dev-dependencies] itertools = "0.15" +packed-seq = { version = "5.0", features = ["rand"] } rand = "0.10" [features] diff --git a/scripts/wasi-node.mjs b/scripts/wasi-node.mjs new file mode 100644 index 0000000..1e9e6fb --- /dev/null +++ b/scripts/wasi-node.mjs @@ -0,0 +1,25 @@ +// Run a wasm32-wasip1 binary under Node's V8 engine, for use as a cargo runner: +// +// CARGO_TARGET_WASM32_WASIP1_RUNNER="node --no-warnings scripts/wasi-node.mjs" \ +// RUSTFLAGS="-C target-feature=+simd128" \ +// cargo test --release --features scalar --target wasm32-wasip1 +import { readFile } from 'node:fs/promises'; +import process from 'node:process'; +import { WASI } from 'node:wasi'; + +const [wasmPath, ...args] = process.argv.slice(2); +if (!wasmPath) { + console.error('usage: node wasi-node.mjs [args...]'); + process.exit(2); +} + +const wasi = new WASI({ + version: 'preview1', + args: [wasmPath, ...args], + env: process.env, + returnOnExit: true, +}); + +const module = await WebAssembly.compile(await readFile(wasmPath)); +const instance = await WebAssembly.instantiate(module, wasi.getImportObject()); +process.exitCode = wasi.start(instance);