name: Rust CI
on:
push:
branches: ["main"]
pull_request:
branches: ["**"]
jobs:
ci:
name: ${{ matrix.job }}
runs-on: ubuntu-latest
timeout-minutes: ${{ matrix.timeout }}
continue-on-error: ${{ matrix.job == 'cargo-outdated' || matrix.job == 'cargo-udeps' || matrix.job == 'cargo-deny' }}
strategy:
matrix:
include:
- job: rustfmt
toolchain: stable
timeout: 10
command: cargo fmt --all -- --check
- job: clippy
toolchain: stable
timeout: 15
command: cargo clippy --all-targets --all-features -- -D warnings
- job: docs-rs
toolchain: nightly
timeout: 10
command: |
cargo docs-rs
- job: build
toolchain: stable
timeout: 15
command: cargo build --all --verbose
- job: test
toolchain: stable
timeout: 20
command: cargo test --all --all-features --no-fail-fast --verbose
- job: cargo-udeps
toolchain: nightly
timeout: 15
command: |
cargo +nightly install cargo-udeps --locked --version ^0.1 || true
cargo +nightly udeps --all-targets --all-features
- job: cargo-outdated
toolchain: stable
timeout: 10
command: |
cargo install cargo-outdated --version ^0.17 || true
cargo outdated --exit-code 1
- job: cargo-deny
toolchain: stable
timeout: 10
command: |
cargo install cargo-deny --locked --version ^0.18.5
cargo deny check all
- job: taplo
toolchain: stable
timeout: 5
command: |
cargo install taplo-cli --locked --version ^0.8
taplo format --check
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust (stable)
if: matrix.toolchain == 'stable'
uses: dtolnay/rust-toolchain@stable
- name: Install Rust (nightly)
if: matrix.toolchain == 'nightly'
uses: dtolnay/rust-toolchain@nightly
- name: Use docs-rs toolchain
if: matrix.job == 'docs-rs'
uses: dtolnay/install@cargo-docs-rs
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Run ${{ matrix.job }}
run: ${{ matrix.command }}