name: CI
on:
push:
branches: [main]
pull_request:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"
permissions:
contents: read
jobs:
checks:
runs-on: ubuntu-latest
env:
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: allow
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Install Rust toolchain
run: rustup toolchain install --no-self-update
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
- name: Clippy (all features)
run: cargo clippy --workspace --all-targets --all-features
- name: Clippy (no default features)
run: cargo clippy --workspace --all-targets --no-default-features
- name: Rustfmt
run: cargo fmt --check --all
- name: Doc
env:
RUSTDOCFLAGS: "-Dwarnings"
run: cargo doc --workspace --no-deps
- name: Check
run: cargo check --workspace
- name: Verify no uncommitted changes
run: git diff --exit-code
test:
name: test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Install Rust toolchain
run: rustup toolchain install --no-self-update
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 if: matrix.os != 'windows-latest'
- name: Test
run: cargo test --workspace
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Install Rust toolchain
run: rustup toolchain install --no-self-update
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@ba47c86ac325773530516bb756137ac718732518 with:
tool: cargo-llvm-cov
- name: Generate coverage
run: cargo llvm-cov --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
msrv:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "" steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Install Rust toolchain
run: rustup toolchain install --no-self-update
- uses: taiki-e/install-action@ba47c86ac325773530516bb756137ac718732518 with:
tool: cargo-hack
- name: Check MSRV
run: cargo hack check --workspace --rust-version --ignore-private
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- uses: crate-ci/typos@8a48f81b6c64dcfea44b3633223084c4be58ac5f
collect:
needs: [checks, test, coverage, msrv, typos]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check results
run: |
results=("${{ needs.checks.result }}" "${{ needs.test.result }}" "${{ needs.coverage.result }}" "${{ needs.msrv.result }}" "${{ needs.typos.result }}")
for result in "${results[@]}"; do
if [[ "$result" != "success" ]]; then
echo "One or more jobs failed"
exit 1
fi
done
echo "All jobs passed"