Debian Codegraph @

.github/workflows/wasi.yml

raw
1 # spell-checker:ignore wasip wasmtime
2 name: WASI
3
4 # spell-checker:ignore TRIGGERPATH
5 on:
6 pull_request:
7 push:
8 branches:
9 - main
10
11 permissions:
12 contents: read
13
14 # End the current execution if there is a new changeset in the PR.
15 concurrency:
16 group: ${{ github.workflow }}-${{ github.ref }}
17 cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
18
19 jobs:
20 test_wasi:
21 name: Tests
22 runs-on: ubuntu-latest
23 strategy:
24 fail-fast: false
25 matrix:
26 job:
27 - { target: wasm32-wasip1, rust-flags: "--cfg wasi_runner" }
28 - { target: wasm32-wasip2, rust-flags: "--cfg wasi_runner --cfg wasip2_runner" }
29 steps:
30 - uses: actions/[email protected]
31 with:
32 persist-credentials: false
33 - uses: dtolnay/rust-toolchain@stable
34 with:
35 targets: ${{ matrix.job.target }}
36 - uses: Swatinem/rust-cache@v2
37 with:
38 key: "${{ matrix.job.target }}"
39 - name: Install wasmtime
40 run: |
41 curl https://wasmtime.dev/install.sh -sSf | bash
42 echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
43 - name: Run unit tests
44 env:
45 CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime
46 CARGO_TARGET_WASM32_WASIP2_RUNNER: wasmtime
47 run: |
48 # Get all utilities and exclude ones that don't compile for ${{ matrix.job.target }}
49 EXCLUDE="df|du|env|more|tac"
50 UTILS=$(./util/show-utils.sh | tr ' ' '\n' | grep -vE "^($EXCLUDE)$" | sed 's/^/-p uu_/' | tr '\n' ' ')
51 cargo test --target ${{ matrix.job.target }} --no-default-features $UTILS
52 - name: Run integration tests via wasmtime
53 if: matrix.job.target == 'wasm32-wasip1'
54 env:
55 RUSTFLAGS: ${{ matrix.job.rust-flags }}
56 run: |
57 # Build the WASI binary
58 cargo build --target ${{ matrix.job.target }} --no-default-features --features feat_wasm
59 # Run host-compiled integration tests against the WASI binary.
60 # Tests incompatible with WASI are annotated with
61 # #[cfg_attr(wasi_runner, ignore)] in the test source files.
62 # The binary above is built without default features, so it has no
63 # caret diagnostics; the host test crate does have them, hence the
64 # not(wasi_runner) in the cfg guarding every `mod diagnostics`.
65 # TODO: add integration tests for these tools as WASI support is extended:
66 # arch b2sum cksum csplit date dir dircolors fmt join
67 # ls md5sum mkdir mv nproc pathchk pr printenv ptx pwd readlink
68 # realpath rm rmdir seq sha1sum sha224sum sha256sum sha384sum
69 # sha512sum shred sleep sort split tsort uname uniq vdir
70 UUTESTS_BINARY_PATH="$(pwd)/target/${{ matrix.job.target }}/debug/coreutils.wasm" \
71 UUTESTS_WASM_RUNNER=wasmtime \
72 cargo test --test tests -- \
73 test_base32:: test_base64:: test_basenc:: test_basename:: \
74 test_cat:: test_comm:: test_cp:: test_cut:: test_dirname:: test_echo:: \
75 test_expand:: test_expr:: test_factor:: test_false:: test_fold:: \
76 test_head:: test_link:: test_ln:: test_mktemp:: test_nl:: test_numfmt:: \
77 test_od:: test_paste:: test_printf:: test_shuf:: test_sum:: \
78 test_tail:: test_tee:: test_test:: test_touch:: test_tr:: \
79 test_true:: test_truncate:: \
80 test_unexpand:: test_unlink:: test_wc:: test_yes::