---
name: Rust
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- 'src/**'
- 'tests/**'
- '.codespellrc'
- '.github/workflows/rust.yml'
pull_request:
branches: [ "main" ]
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- 'src/**'
- 'tests/**'
- '.codespellrc'
- '.github/workflows/rust.yml'
env:
CARGO_TERM_COLOR: always
jobs:
codespell:
name: Check for spelling mistakes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check format
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-features
docs:
name: Build documentation
needs:
- codespell
- lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build documentation
run: cargo doc --all-features
build-linux:
name: Build on Linux
needs:
- lint
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.81.0, stable, nightly]
features: [ [ ], [ "--all-features" ], [ "--no-default-features" ] ]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- name: Build
run: cargo build --verbose ${{ join(matrix.features, ' ') }}
- name: Run doctests
run: cargo test --doc --verbose ${{ join(matrix.features, ' ') }}
- name: Run regular tests
run: cargo test --tests --verbose ${{ join(matrix.features, ' ') }}
codecov:
name: Code Coverage
needs:
- lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Generate code coverage
run: cargo llvm-cov nextest --all-features --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true