name: Rust
on:
push:
branches:
- "main"
paths:
- 'Cargo.toml'
- '.config/**'
- 'src/**'
- '.github/workflows/rust.yml'
pull_request:
branches:
- "main"
paths:
- 'Cargo.toml'
- '.config/**'
- 'src/**'
- '.github/workflows/rust.yml'
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build and run tests
runs-on: ubuntu-latest
strategy:
matrix:
features:
- no-default-features
- all-features
steps:
- uses: actions/checkout@v4
- name: Check formatting
run: cargo fmt --check
- name: Build
run: cargo build --${{ matrix.features }}
- name: Run tests
run: cargo test --verbose --${{ matrix.features }}
- name: Run doctests
run: cargo test --doc --verbose --${{ matrix.features }}
- name: Build docs
run: cargo doc --${{ matrix.features }}
codecov:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Generate code coverage
run: cargo llvm-cov nextest --all-features --lcov --output-path lcov.info --profile=ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
file: target/nextest/ci/junit.xml
token: ${{ secrets.CODECOV_TOKEN }}