name: CI
on:
push:
branches: [ master ]
paths:
- 'src/**'
- 'Cargo.*'
- '.github/workflows/ci.yml'
pull_request:
branches: [ master ]
paths:
- 'src/**'
- 'Cargo.*'
- '.github/workflows/ci.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
quick-test:
name: Quick Tests - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: github.event_name != 'push' || !contains(github.event.head_commit.message, 'Merge pull request')
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Build
run: cargo build --verbose
- name: Run unit tests
run: cargo test --lib --verbose
- name: Run doctests
run: cargo test --doc --verbose
full-test:
name: Full Test Suite
runs-on: ubuntu-latest
needs: quick-test
if: github.event_name != 'push' || !contains(github.event.head_commit.message, 'Merge pull request')
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Run all tests
run: cargo test --all --verbose
- name: Run tests with all features
run: cargo test --all-features --verbose
quality:
name: Code Quality
runs-on: ubuntu-latest
needs: quick-test
if: github.event_name != 'push' || !contains(github.event.head_commit.message, 'Merge pull request')
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build documentation
run: cargo doc --no-deps --document-private-items
env:
RUSTDOCFLAGS: -D warnings
security:
name: Security Audit
runs-on: ubuntu-latest
needs: quick-test
if: github.event_name != 'push' || !contains(github.event.head_commit.message, 'Merge pull request')
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Cache cargo-audit
id: cache-cargo-audit
uses: actions/cache@v5
with:
path: ~/.cargo/bin/cargo-audit
key: cargo-audit-${{ runner.os }}-v1
- name: Install cargo-audit
if: steps.cache-cargo-audit.outputs.cache-hit != 'true'
run: cargo install cargo-audit
- name: Run security audit
run: cargo audit