Skip to content

Commit

Permalink
feat: Wasm32 wasi 0.41.0 (#888)
Browse files Browse the repository at this point in the history
feat: Add wasi compatibility.

- wasip2 will require +nightly until rust-lang/rust#130323 is resolved and/or std::os::wasip2 is available in stable.
- Support was added to rustix for version 0.38.39 bytecodealliance/rustix#1205
- Support was added to tempfile for version 3.14 Stebalien/tempfile#305
- Tempfile is not supported in wasip1
- Working remote manifest fetch.

Tests passing with WASI.
CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime -S common -S http --dir ."
  • Loading branch information
cdmurph32 authored Feb 18, 2025
1 parent 49667a0 commit 1c046d0
Show file tree
Hide file tree
Showing 48 changed files with 1,103 additions and 592 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,56 @@ jobs:
run: wasm-pack test --chrome --headless
working-directory: ./cawg_identity

tests-wasi:
name: Unit tests (WASI)
if: |
github.event_name != 'pull_request' ||
github.event.pull_request.author_association == 'COLLABORATOR' ||
github.event.pull_request.author_association == 'MEMBER' ||
github.event.pull_request.user.login == 'dependabot[bot]' ||
contains(github.event.pull_request.labels.*.name, 'safe to test')
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

# nightly required for testing until this issue is resolved:
# wasip2 target should not conditionally feature gate stdlib APIs rust-lang/rust#130323 https://github.com/rust-lang/rust/issues/130323
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly

- name: Install wasmtime
run: |
curl https://wasmtime.dev/install.sh -sSf | bash
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
- name: Install WASI SDK
run: |
if [ "${RUNNER_ARCH}" = "X64" ]; then
ARCH="x86_64";
else
ARCH="${RUNNER_ARCH}";
fi
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-${ARCH}-${RUNNER_OS}.tar.gz
tar xvf wasi-sdk-25.0-${ARCH}-${RUNNER_OS}.tar.gz
mv $(echo wasi-sdk-25.0-${ARCH}-${RUNNER_OS} | tr '[:upper:]' '[:lower:]') /opt/wasi-sdk
- name: Add wasm32-wasip2 target
run: rustup target add --toolchain nightly wasm32-wasip2

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Run WASI tests (c2pa-rs)
env:
CARGO_TARGET_WASM32_WASIP2_RUNNER: "wasmtime -S cli -S http --dir ."
CC: /opt/wasi-sdk/bin/clang
WASI_SDK_PATH: /opt/wasi-sdk
RUST_MIN_STACK: 16777216
run: cargo +nightly test --target wasm32-wasip2 -p c2pa -p c2pa-crypto --all-features

test-direct-minimal-versions:
name: Unit tests with minimum versions of direct dependencies
if: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/target/

**/*.rs.bk
**/*.tmp*

.DS_Store
.idea
Expand Down
Loading

0 comments on commit 1c046d0

Please sign in to comment.