name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
features: [ [ ], [ "--all-features" ], [ "--no-default-features" ] ]
steps:
- uses: actions/checkout@v4
- name: Check Formatting
run: cargo fmt --check
- name: Clippy
run: cargo clippy ${{ join(matrix.features, ' ') }}
- name: Build
run: cargo build --verbose ${{ join(matrix.features, ' ') }}
- name: Run build tests
run: cargo build --tests ${{ join(matrix.features, ' ') }}
- name: Run tests
run: cargo test --tests --verbose ${{ join(matrix.features, ' ') }}
- name: Run doctests
run: cargo test --doc --verbose ${{ join(matrix.features, ' ') }}
codecov:
name: Code Coverage
runs-on: ubuntu-latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Install Protocol Buffers Compiler
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- 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
- uses: actions/checkout@v4
- name: Generate code coverage
run: cargo llvm-cov nextest --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true