Skip to content

Commit addec6e

Browse files
committed
Add a smoke test for netwatch wasm
1 parent a1410ad commit addec6e

File tree

5 files changed

+417
-0
lines changed

5 files changed

+417
-0
lines changed

.cargo/config.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[target.wasm32-unknown-unknown]
2+
runner = "wasm-bindgen-test-runner"
3+
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']

.github/workflows/ci.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,40 @@ jobs:
147147
env:
148148
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG' }}
149149

150+
wasm_test:
151+
name: Build & test wasm32 for browsers
152+
runs-on: ubuntu-latest
153+
steps:
154+
- name: Checkout sources
155+
uses: actions/checkout@v4
156+
157+
- name: Install stable toolchain
158+
uses: dtolnay/rust-toolchain@stable
159+
160+
- name: Add wasm target
161+
run: rustup target add wasm32-unknown-unknown
162+
163+
- name: Install cargo-binstall
164+
uses: cargo-bins/cargo-binstall@main
165+
166+
- name: Install wasm-bindgen-test-runner
167+
run: cargo binstall wasm-bindgen-cli --locked --no-confirm
168+
169+
- name: Install wasm-tools
170+
uses: bytecodealliance/actions/wasm-tools/setup@v1
171+
172+
- name: wasm32 build (netwatch)
173+
run: cargo build --target wasm32-unknown-unknown -p netwatch
174+
175+
# If the Wasm file contains any 'import "env"' declarations, then
176+
# some non-Wasm-compatible code made it into the final code.
177+
- name: Ensure no 'import "env"' in netwatch Wasm
178+
run: |
179+
! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/netwatch.wasm | grep 'import "env"'
180+
181+
- name: Run smoke test in wasm
182+
run: cargo test -p netwatch --test smoke --target=wasm32-unknown-unknown
183+
150184
check_semver:
151185
runs-on: ubuntu-latest
152186
env:

0 commit comments

Comments
 (0)