name: Test Coverage
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
toolchain: [stable, beta, nightly]
continue-on-error: false
steps:
- uses: actions/checkout@v4
- name: Update tool chain
run: |
rustup update ${{ matrix.toolchain }}
rustup default ${{ matrix.toolchain }}
- name: Test project
run: cargo test
coverage:
name: Coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
toolchain: [ nightly ]
steps:
- uses: actions/checkout@v4
- name: Update tool chain
run: |
rustup update ${{ matrix.toolchain }}
rustup default ${{ matrix.toolchain }}
rustup component add llvm-tools-preview --toolchain ${{ matrix.toolchain }}
- name: Install coverage tool
run: cargo +stable install cargo-llvm-cov --locked
- name: Test project and generate coverage report
run: cargo llvm-cov --remap-path-prefix --show-missing-lines --branch --doctests --lcov --output-path lcov.info
- name: Publish coverage summary to job summary
uses: livewing/lcov-job-summary@v1.1.0
with:
lcov: lcov.info
- name: Fail build if coverage below 80%
uses: bigmeech/gha-simple-coverage@master
with:
lcov-file-path: lcov.info
fail-if-below: 80