name: Test and Coverage
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run tests
run: cargo llvm-cov --all-features --lcov --output-path lcov.info --workspace
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: lcov.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Check coverage threshold
run: |
coverage=$(cargo llvm-cov --all-features --summary-only | grep -oP 'Total.*\K\d+\.\d+' | head -1)
echo "Coverage: ${coverage}%"
if (( $(echo "$coverage < 100.0" | bc -l) )); then
echo "Coverage is below 100% threshold"
exit 1
fi