name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
name: Check, Lint and Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: install cargo utilities
run: |
cargo binstall cargo-rdme
cargo binstall cargo-nextest
- name: Check formatting
run: cargo fmt --all -- --check
- name: Readme check
run: cargo rdme --check
- name: Build
run: cargo build --verbose
- name: Run clippy
run: |
cargo fmt --all -- --check || exit 1
cargo clippy --all-features -- -D warnings || exit 1
- name: Run tests
run: |
cargo nextest run --workspace --all-features --no-tests warn || exit 1
cargo test --doc --workspace || exit 1
- name: Minimal example test
run: |
cd examples/minimal && cargo test -- --no-capture || exit 1
- name: Run clippy in all examples
if: ${{ false }} run: |
for dir in $(python scripts/rust-crates.py list-workspaces); do
if [[ "$dir" == "." ]]; then
continue
fi
echo "Running clippy in $dir"
pushd $dir
cargo clippy --all-features -- -D warnings || exit 1
popd
done
- name: Run tests in all examples
if: ${{ false }} run: |
for dir in $(python scripts/rust-crates.py list-workspaces); do
if [[ "$dir" == "." ]]; then
continue
fi
echo "Running tests in $dir"
pushd $dir
cargo nextest run --verbose || exit 1
cargo test --doc --verbose || exit 1
popd
done
test-on-multiple-os:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: install cargo utilities
run: |
cargo binstall cargo-nextest
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo nextest run --verbose
- name: Run test for minimal example
run: cd examples/minimal && cargo nextest run --no-capture