name: Code Coverage
on: push
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: "macos-latest"
steps:
- name: Install grcov
run: cargo install grcov
- name: Install llvm-tools
run: rustup component add llvm-tools
- name: Check out code
uses: actions/checkout@v5
- name: Make coverage folder
run: mkdir -p ./target/debug/coverage/profraw
- name: Run Tests
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Cinstrument-coverage -Clink-dead-code"
RUSTDOCFLAGS: "-Cpanic=abort"
LLVM_PROFILE_FILE: "target/debug/coverage/profraw/tray-wrapper-%p-%m.profraw"
run: cargo test
- name: Generate Coverage Report
run: grcov --source-dir . --binary-path ./target/debug/ -p $GITHUB_WORKSPACE -t lcov --log-level DEBUG --branch --ignore-not-existing --keep-only 'src/*' -o ./lcov.info target/debug/coverage/profraw
- name: List what we have
run: |
ls -l target/debug/coverage && \
ls -l target/debug/coverage/profraw
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: lcov.info
path: ./lcov.info