name: Rust CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, beta, nightly]
features: ["default"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Add Clippy
run: rustup component add clippy --toolchain ${{ matrix.rust }}
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Run Clippy
run: cargo clippy --no-default-features --features "${{ matrix.features }}" --all-targets -- -D warnings
- name: Run unit tests
run: cargo test --all-targets --no-default-features --features "${{ matrix.features }}"
- name: Run doctests
run: cargo test --doc --no-default-features --features "${{ matrix.features }}"