name: CI
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint (clippy + fmt)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
components: clippy, rustfmt
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
test:
name: Test on ${{ matrix.os }}
needs: lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust 1.85.1 (MSRV)
uses: dtolnay/rust-toolchain@v1
with:
toolchain: 1.85.1
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Run tests with all features
run: cargo test --verbose --all-features
- name: Test documentation
run: cargo test --doc
wasm:
name: WASM build
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
targets: wasm32-unknown-unknown
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Build for WASM
run: cargo build --target wasm32-unknown-unknown --features std
minimal-versions:
name: Minimal versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Check minimal versions
run: cargo hack check --all --ignore-private
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
components: llvm-tools-preview
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: Generate test coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: lcov.info
fail_ci_if_error: true
feature-checks:
name: Feature checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Check each feature
run: cargo hack check --each-feature --no-dev-deps
- name: Check feature combinations
run: cargo hack check --feature-powerset --no-dev-deps