Skip to content

Commit ed3e653

Browse files
committed
Add test runs for examples
1 parent c5deb00 commit ed3e653

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.github/workflows/test.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,14 @@ jobs:
8282
- name: Test
8383
shell: bash
8484
run: COMPONENTIZE_PY_TEST_COUNT=20 PROPTEST_MAX_SHRINK_ITERS=0 cargo test --release
85+
86+
- uses: taiki-e/install-action@v2
87+
with:
88+
tool: wasmtime-cli
89+
- uses: actions/setup-python@v5
90+
with:
91+
python-version: "3.12"
92+
- run: pip install wasmtime
93+
- name: Test examples
94+
shell: bash
95+
run: bash .github/workflows/test_examples.sh

.github/workflows/test_examples.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
export COMPONENTIZE_PY_TEST_COUNT=0
6+
export COMPONENTIZE_PY_TEST_SEED=bc6ad1950594f1fe477144ef5b3669dd5962e49de4f3b666e5cbf9072507749a
7+
export WASMTIME_BACKTRACE_DETAILS=1
8+
9+
cargo build --release
10+
11+
# CLI
12+
(cd examples/cli \
13+
&& ../../target/release/componentize-py -d ../../wit -w wasi:cli/command@0.2.0 componentize app -o cli.wasm \
14+
&& wasmtime run cli.wasm)
15+
16+
# HTTP
17+
# Just compiling for now
18+
(cd examples/http \
19+
&& ../../target/release/componentize-py -d ../../wit -w wasi:http/proxy@0.2.0 componentize app -o http.wasm)
20+
21+
# Matrix Math
22+
(cd examples/matrix-math \
23+
&& curl -OL https://github.com/dicej/wasi-wheels/releases/download/v0.0.1/numpy-wasi.tar.gz \
24+
&& tar xf numpy-wasi.tar.gz \
25+
&& ../../target/release/componentize-py -d ../../wit -w matrix-math componentize app -o matrix-math.wasm \
26+
&& wasmtime run matrix-math.wasm '[[1, 2], [4, 5], [6, 7]]' '[[1, 2, 3], [4, 5, 6]]')
27+
28+
# Sandbox
29+
(cd examples/sandbox \
30+
&& ../../target/release/componentize-py -d sandbox.wit componentize --stub-wasi guest -o sandbox.wasm \
31+
&& python -m wasmtime.bindgen sandbox.wasm --out-dir sandbox \
32+
&& python host.py "2 + 2")
33+
34+
# TCP
35+
# Just compiling for now
36+
(cd examples/tcp \
37+
&& ../../target/release/componentize-py -d ../../wit -w wasi:cli/command@0.2.0 componentize app -o tcp.wasm)

0 commit comments

Comments
 (0)