name: Rust
permissions:
contents: read
id-token: write
pull-requests: write
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: llvm-tools-preview, clippy, rustfmt
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Check formatting
run: cargo fmt --check
- name: Run Clippy lint
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo llvm-cov --lcov --output-path coverage.lcov
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v7
with:
files: coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true