name: CI
on:
push:
branches: [main, master]
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_TEST_DEBUG: 0
jobs:
check:
name: Check (fmt, clippy)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Install Rust
uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec with:
components: rustfmt, clippy
targets: wasm32-wasip2
- name: Cache cargo
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0
- name: Setup runtime wasm cache
uses: ./.github/actions/setup-runtime-cache
- name: Check formatting
run: cargo fmt --all --check
- name: Clippy
run: cargo clippy --workspace --all-features -- -D warnings
- name: Runtime and build-tool unit tests
run: cargo test --locked -p componentize-qjs-runtime -p xtask
build-test:
name: ${{ matrix.name || format('Build and test ({0})', matrix.os) }}
runs-on: ${{ matrix.os }}
needs: check
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
configuration: [default]
include:
- os: ubuntu-latest
configuration: sync
name: Build and test (ubuntu-latest, sync)
cargo-args: --no-default-features
- os: ubuntu-latest
configuration: opt-size
name: Build and test (ubuntu-latest, opt-size)
cargo-args: --features opt-size
- os: ubuntu-latest
configuration: sync-opt-size
name: Build and test (ubuntu-latest, sync-opt-size)
cargo-args: --no-default-features --features opt-size
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Install Rust
uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec with:
targets: wasm32-wasip2
- name: Cache cargo
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0
- name: Setup sccache
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba
- name: Configure sccache
shell: bash
run: |
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
- name: Setup runtime wasm cache
uses: ./.github/actions/setup-runtime-cache
- name: Build Windows runtime from source
if: runner.os == 'Windows'
run: cargo run --locked -p xtask -- --sync-only --output target/runtime-source-check
- name: Run tests
run: cargo test --locked -p componentize-qjs-cli -p componentize-qjs ${{ matrix.cargo-args }}
npm-test:
name: NPM package tests
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Install Rust
uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec with:
targets: wasm32-wasip2
- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 with:
node-version: 24
- name: Cache cargo
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0
- name: Setup sccache
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba
- name: Configure sccache
shell: bash
run: |
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
- name: Setup runtime wasm cache
uses: ./.github/actions/setup-runtime-cache
- 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