Skip to content

Commit 1dbc88f

Browse files
authored
ci: add pnpm tests for wasm32-wasip1 and wasm32-unknown-unknown targets (#745)
1 parent 4eb1051 commit 1dbc88f

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
# See https://x.com/Brooooook_lyn/status/1895848334692401270
44
[target.'cfg(target_env = "gnu")']
55
rustflags = ["-C", "link-args=-Wl,-z,nodelete"]
6+
7+
[target.wasm32-wasip1-threads]
8+
rustflags = ["-Clink-args=-zstack-size=64000000 --max-memory=4294967296"]

.github/workflows/ci.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
files: .
6262

6363
wasm32-wasip1:
64-
name: Check wasm32-wasip1
64+
name: Test wasm32-wasip1
6565
runs-on: ubuntu-latest
6666
steps:
6767
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
@@ -70,11 +70,17 @@ jobs:
7070
with:
7171
cache-key: wasm32-wasip1
7272
save-cache: ${{ github.ref_name == 'main' }}
73+
tools: wasmtime
7374

74-
- name: Check
75-
run: |
76-
rustup target add wasm32-wasip1
77-
cargo check --all-features --target wasm32-wasip1
75+
- uses: ./.github/actions/pnpm
76+
77+
- name: Install target
78+
run: rustup target add wasm32-wasip1
79+
80+
- name: Test
81+
run: cargo test --target wasm32-wasip1 --profile wasm-test -- --nocapture
82+
env:
83+
CARGO_TARGET_WASM32_WASIP1_RUNNER: "wasmtime run -W bulk-memory=y --dir ${{ github.workspace }}::/ --"
7884

7985
wasm32-unknown-unknown:
8086
name: Check wasm32-unknown-unknown
@@ -102,6 +108,7 @@ jobs:
102108
with:
103109
cache-key: wasi
104110
save-cache: ${{ github.ref_name == 'main' }}
111+
tools: wasmtime
105112

106113
- uses: ./.github/actions/pnpm
107114

@@ -115,4 +122,9 @@ jobs:
115122
env:
116123
WASI_TEST: 1
117124

125+
- name: Cargo Test
126+
run: cargo test --target wasm32-wasip1-threads --profile wasm-test -- --nocapture
127+
env:
128+
CARGO_TARGET_WASM32_WASIP1_THREADS_RUNNER: "wasmtime run -W bulk-memory=y -W threads=y -S threads=y --dir ${{ github.workspace }}::/ --"
129+
118130
- run: git diff --exit-code # Must commit index.d.ts

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ debug = false
133133
# and we don't rely on it for debugging that much.
134134
debug = false
135135

136+
[profile.wasm-test]
137+
inherits = "test"
138+
debug = true
139+
opt-level = "z" # Avoid too many locals errors during wasmtime testing
140+
136141
[package.metadata.docs.rs]
137142
all-features = true
138143
rustdoc-args = ["--cfg", "docsrs"]

src/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub fn fixture() -> PathBuf {
4343
}
4444

4545
#[test]
46+
#[cfg_attr(target_os = "wasi", ignore)]
4647
fn threaded_environment() {
4748
let cwd = env::current_dir().unwrap();
4849
let resolver = Arc::new(Resolver::default());

src/tests/symlink.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(
3131
FileType::File => std::os::windows::fs::symlink_file(original.as_ref().normalize(), link),
3232
FileType::Dir => std::os::windows::fs::symlink_dir(original.as_ref().normalize(), link),
3333
}
34+
#[cfg(target_family = "wasm")]
35+
{
36+
Err(io::Error::new(io::ErrorKind::Other, "not supported"))
37+
}
3438
}
3539

3640
fn init(dirname: &Path, temp_path: &Path) -> io::Result<()> {
@@ -119,6 +123,7 @@ fn prepare_symlinks<P: AsRef<Path>>(
119123
}
120124

121125
#[test]
126+
#[cfg_attr(target_family = "wasm", ignore)]
122127
fn test() {
123128
let Some(SymlinkFixturePaths { root, temp_path }) = prepare_symlinks("temp").unwrap() else {
124129
return;

0 commit comments

Comments
 (0)