name: CI
on:
push:
branches: [main, master]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check (fmt, clippy)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
targets: wasm32-wasip2
- name: Cache cargo
uses: Swatinem/rust-cache@v2.8.2
- name: Check formatting
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
build-test:
name: Build and test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: check
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip2
- name: Cache cargo
uses: Swatinem/rust-cache@v2.8.2
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.10
- name: Configure sccache
shell: bash
run: |
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
- name: Build
run: cargo build
- name: Run tests
run: cargo test
npm-test:
name: NPM package tests
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache cargo
uses: Swatinem/rust-cache@v2.8.2
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.10
- name: Configure sccache
shell: bash
run: |
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
- name: Install npm dependencies
working-directory: npm
run: npm install
- name: Build napi binding
working-directory: npm
run: npm run build:debug
- name: Run npm tests
working-directory: npm
run: npm test