name: CI
on:
push:
branches: [ dev ]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target/
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Check formatting
run: cargo fmt --all -- --check
- name: Show formatting diff (if check failed)
if: failure()
run: |
echo "❌ Formatting check failed. Run 'cargo fmt --all' to fix."
echo "Here's what would be changed:"
cargo fmt --all -- --check --verbose || true
echo ""
echo "To fix locally, run: cargo fmt --all"
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Show clippy fixes (if check failed)
if: failure()
run: |
echo "❌ Clippy check failed. Some issues might be auto-fixable."
echo "To fix locally, run: cargo clippy --fix --allow-dirty --allow-staged --all-targets --all-features"
echo "Then run: cargo clippy --all-targets --all-features -- -D warnings"
- name: Run tests (includes compilation and doc tests)
run: cargo test --verbose
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Check documentation
run: cargo doc --no-deps --document-private-items --all-features
env:
RUSTDOCFLAGS: -D warnings
msrv:
name: Minimum Supported Rust Version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust 1.70
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.70.0
- name: Check with MSRV
run: cargo check --verbose