feat(build): cache-bust the WASM glue with the package version (#10) #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: "1" | |
| jobs: | |
| lint-test: | |
| name: Lint, test, build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| targets: wasm32-unknown-unknown | |
| - name: Cache cargo registry and target | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Format check | |
| run: cargo fmt --all -- --check | |
| - name: Clippy | |
| run: cargo clippy --workspace --all-targets -- -D warnings | |
| - name: Test | |
| run: cargo test --workspace --all-features | |
| - name: Build release | |
| run: cargo build --workspace --release | |
| - name: Build docs | |
| run: cargo doc --workspace --no-deps | |
| - name: Install cargo-audit | |
| run: cargo install cargo-audit --locked | |
| - name: Security audit | |
| run: cargo audit | |
| wasm: | |
| name: Build WASM | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Cache cargo registry and target | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Build WASM | |
| run: wasm-pack build crates/wasm --target web --release --no-opt | |
| - name: Run wasm-opt | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y binaryen | |
| wasm-opt --enable-bulk-memory --enable-sign-ext -Oz \ | |
| crates/wasm/pkg/long_multiplication_wasm_bg.wasm \ | |
| -o crates/wasm/pkg/long_multiplication_wasm_bg.wasm.opt | |
| mv crates/wasm/pkg/long_multiplication_wasm_bg.wasm.opt \ | |
| crates/wasm/pkg/long_multiplication_wasm_bg.wasm | |
| - name: Install Chromium | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y chromium-browser | |
| - name: Test WASM in headless Chromium | |
| run: wasm-pack test --chrome --headless crates/wasm | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wasm-pkg | |
| path: crates/wasm/pkg |