name: Web API (page command API) on: workflow_dispatch: push: branches: [main, next] paths: ['crates/web-api/**', 'Cargo.toml', 'Cargo.lock', '.github/workflows/web-api.yml'] pull_request: paths: ['crates/web-api/**', 'Cargo.toml', 'Cargo.lock', '.github/workflows/web-api.yml'] permissions: contents: read concurrency: # Pull requests share one group per branch, so a newer push cancels the older run. Every other # run (main, manual) gets a group of its own, so it is neither cancelled nor replaced while queued. group: web-api-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: web-api: # One OS: the crate is platform-independent JSON handling plus wasm32; no platform code. timeout-minutes: 30 runs-on: ubuntu-latest env: CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER: wasm-bindgen-test-runner steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - uses: actions/checkout@v7.0.1 with: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@v1.0.0 with: toolchain: stable components: rustfmt, clippy targets: wasm32-unknown-unknown - name: Read the wasm-bindgen version from Cargo.lock id: wasm-bindgen shell: bash run: | runner_version=$(python3 -c 'import tomllib; d=tomllib.load(open("Cargo.lock", "rb")); print(next(p["version"] for p in d["package"] if p["name"] == "wasm-bindgen"))') echo "version=$runner_version" >> "$GITHUB_OUTPUT" - name: Install the matching WASM test runner # A prebuilt, checksum-verified binary instead of building it from source on every run. # A version the pinned action does not list yet falls back to `cargo install --locked`. uses: step-security/taiki-e-install-action@v2.87.32 with: tool: wasm-bindgen@${{ steps.wasm-bindgen.outputs.version }} fallback: cargo-install - run: cargo fmt --check - run: cargo clippy -p craft-web-api --all-targets --locked -- -D warnings - run: cargo clippy -p craft-web-api --all-targets --locked --target wasm32-unknown-unknown -- -D warnings - name: Docs (links and missing docs) run: cargo doc -p craft-web-api --no-deps --locked env: RUSTDOCFLAGS: -D warnings - run: cargo test -p craft-web-api --locked - run: cargo test -p craft-web-api --locked --target wasm32-unknown-unknown