From 96104cf638a36cb4324a654b4e1d2ac3954a0064 Mon Sep 17 00:00:00 2001 From: Boshen Date: Fri, 3 Oct 2025 18:48:57 +0800 Subject: [PATCH 1/5] ci: add pnpm tests for wasm32-wasip1 and wasm32-unknown-unknown targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously these jobs only ran `cargo check`. Now they build the NAPI bindings and run the full test suite for better coverage of WebAssembly targets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/workflows/ci.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d36ba198..be0aa5de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: files: . wasm32-wasip1: - name: Check wasm32-wasip1 + name: Test wasm32-wasip1 runs-on: ubuntu-latest steps: - uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 @@ -71,13 +71,20 @@ jobs: cache-key: wasm32-wasip1 save-cache: ${{ github.ref_name == 'main' }} - - name: Check + - uses: ./.github/actions/pnpm + + - name: Build run: | rustup target add wasm32-wasip1 - cargo check --all-features --target wasm32-wasip1 + pnpm build --target wasm32-wasip1 + + - name: Test + run: pnpm run test + env: + WASI_TEST: 1 wasm32-unknown-unknown: - name: Check wasm32-unknown-unknown + name: Test wasm32-unknown-unknown runs-on: ubuntu-latest steps: - uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 @@ -87,10 +94,17 @@ jobs: cache-key: wasm32-unknown-unknown save-cache: ${{ github.ref_name == 'main' }} - - name: Check + - uses: ./.github/actions/pnpm + + - name: Build run: | rustup target add wasm32-unknown-unknown - cargo check --all-features --target wasm32-unknown-unknown + pnpm build --target wasm32-unknown-unknown + + - name: Test + run: pnpm run test + env: + WASI_TEST: 1 wasi: name: Test wasi target From ba43ff6b8e61d263db2d77ba972db0918103c496 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 4 Oct 2025 13:12:46 +0800 Subject: [PATCH 2/5] Update test config --- .cargo/config.toml | 3 +++ .github/workflows/ci.yml | 30 +++++++++++++----------------- Cargo.toml | 5 +++++ src/tests/mod.rs | 1 + src/tests/symlink.rs | 5 +++++ 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index f5411f2f..7920242c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,3 +3,6 @@ # See https://x.com/Brooooook_lyn/status/1895848334692401270 [target.'cfg(target_env = "gnu")'] rustflags = ["-C", "link-args=-Wl,-z,nodelete"] + +[target.wasm32-wasip1-threads] +rustflags = ["-Clink-args=--initial-memory=2621440 --max-memory=2621440"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be0aa5de..84e571fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,21 +70,18 @@ jobs: with: cache-key: wasm32-wasip1 save-cache: ${{ github.ref_name == 'main' }} - - - uses: ./.github/actions/pnpm + tools: wasmtime - name: Build - run: | - rustup target add wasm32-wasip1 - pnpm build --target wasm32-wasip1 + run: rustup target add wasm32-wasip1 - name: Test - run: pnpm run test + run: cargo test --target wasm32-wasip1 --profile wasm-test -- --nocapture env: - WASI_TEST: 1 + CARGO_TARGET_WASM32_WASIP1_RUNNER: 'wasmtime run -W bulk-memory=y --dir ${{ github.workspace }}::/ --' wasm32-unknown-unknown: - name: Test wasm32-unknown-unknown + name: Check wasm32-unknown-unknown runs-on: ubuntu-latest steps: - uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 @@ -94,17 +91,10 @@ jobs: cache-key: wasm32-unknown-unknown save-cache: ${{ github.ref_name == 'main' }} - - uses: ./.github/actions/pnpm - - - name: Build + - name: Check run: | rustup target add wasm32-unknown-unknown - pnpm build --target wasm32-unknown-unknown - - - name: Test - run: pnpm run test - env: - WASI_TEST: 1 + cargo check --all-features --target wasm32-unknown-unknown wasi: name: Test wasi target @@ -116,6 +106,7 @@ jobs: with: cache-key: wasi save-cache: ${{ github.ref_name == 'main' }} + tools: wasmtime - uses: ./.github/actions/pnpm @@ -129,4 +120,9 @@ jobs: env: WASI_TEST: 1 + - name: Cargo Test + run: cargo test --target wasm32-wasip1-threads --profile wasm-test -- --nocapture + env: + CARGO_TARGET_WASM32_WASIP1_THREADS_RUNNER: 'wasmtime run -W bulk-memory=y -W threads=y -S threads=y --dir ${{ github.workspace }}::/ --' + - run: git diff --exit-code # Must commit index.d.ts diff --git a/Cargo.toml b/Cargo.toml index 11a17717..eac8438c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,6 +131,11 @@ debug = false # and we don't rely on it for debugging that much. debug = false +[profile.wasm-test] +inherits = "test" +debug = true +opt-level = "z" # Avoid too many locals errors during wasmtime testing + [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] diff --git a/src/tests/mod.rs b/src/tests/mod.rs index d5daf3e2..437e9ac3 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -43,6 +43,7 @@ pub fn fixture() -> PathBuf { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] fn threaded_environment() { let cwd = env::current_dir().unwrap(); let resolver = Arc::new(Resolver::default()); diff --git a/src/tests/symlink.rs b/src/tests/symlink.rs index 7a849765..f15e0084 100644 --- a/src/tests/symlink.rs +++ b/src/tests/symlink.rs @@ -31,6 +31,10 @@ fn symlink, Q: AsRef>( FileType::File => std::os::windows::fs::symlink_file(original.as_ref().normalize(), link), FileType::Dir => std::os::windows::fs::symlink_dir(original.as_ref().normalize(), link), } + #[cfg(target_family = "wasm")] + { + Err(io::Error::new(io::ErrorKind::Other, "not supported")) + } } fn init(dirname: &Path, temp_path: &Path) -> io::Result<()> { @@ -119,6 +123,7 @@ fn prepare_symlinks>( } #[test] +#[cfg_attr(target_family = "wasm", ignore)] fn test() { let Some(SymlinkFixturePaths { root, temp_path }) = prepare_symlinks("temp").unwrap() else { return; From 889b430896a9f309412871f7585be9a95d47ad3b Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 4 Oct 2025 13:16:14 +0800 Subject: [PATCH 3/5] pnpm install --- .cargo/config.toml | 2 +- .github/workflows/ci.yml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 7920242c..fbafa14d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,4 +5,4 @@ rustflags = ["-C", "link-args=-Wl,-z,nodelete"] [target.wasm32-wasip1-threads] -rustflags = ["-Clink-args=--initial-memory=2621440 --max-memory=2621440"] +rustflags = ["-Clink-args=--initial-memory=64144016 --max-memory=64144016"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84e571fd..7ff4b287 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,9 @@ jobs: save-cache: ${{ github.ref_name == 'main' }} tools: wasmtime - - name: Build + - uses: ./.github/actions/pnpm + + - name: Install target run: rustup target add wasm32-wasip1 - name: Test From 3ca909e58fb497d3c1bf648fb467cf7f3311aba0 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 4 Oct 2025 13:21:12 +0800 Subject: [PATCH 4/5] Fix wasip1-threads memory size --- .cargo/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index fbafa14d..ddc5a082 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,4 +5,4 @@ rustflags = ["-C", "link-args=-Wl,-z,nodelete"] [target.wasm32-wasip1-threads] -rustflags = ["-Clink-args=--initial-memory=64144016 --max-memory=64144016"] +rustflags = ["-Clink-args=-zstack-size=64000000 --max-memory=4294967296"] From 879531674d84dbf71975c3cbafe5b1fd0efa583e Mon Sep 17 00:00:00 2001 From: Boshen Date: Sat, 4 Oct 2025 14:27:32 +0800 Subject: [PATCH 5/5] fmt --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ff4b287..3fa76e61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,7 +80,7 @@ jobs: - name: Test run: cargo test --target wasm32-wasip1 --profile wasm-test -- --nocapture env: - CARGO_TARGET_WASM32_WASIP1_RUNNER: 'wasmtime run -W bulk-memory=y --dir ${{ github.workspace }}::/ --' + CARGO_TARGET_WASM32_WASIP1_RUNNER: "wasmtime run -W bulk-memory=y --dir ${{ github.workspace }}::/ --" wasm32-unknown-unknown: name: Check wasm32-unknown-unknown @@ -125,6 +125,6 @@ jobs: - name: Cargo Test run: cargo test --target wasm32-wasip1-threads --profile wasm-test -- --nocapture env: - CARGO_TARGET_WASM32_WASIP1_THREADS_RUNNER: 'wasmtime run -W bulk-memory=y -W threads=y -S threads=y --dir ${{ github.workspace }}::/ --' + CARGO_TARGET_WASM32_WASIP1_THREADS_RUNNER: "wasmtime run -W bulk-memory=y -W threads=y -S threads=y --dir ${{ github.workspace }}::/ --" - run: git diff --exit-code # Must commit index.d.ts