2025-10-05 23:10:39 +02:00

71 lines
1.8 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

on:
pull_request:
push:
branches:
- master
name: Codecov
jobs:
test-and-coverage:
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C instrument-coverage"
LLVM_PROFILE_FILE: "coverage-%p-%m.profraw"
steps:
# 1⃣ Checkout the repo
- name: Checkout code
uses: actions/checkout@v4
# 2⃣ Install Rust toolchain (nightly required for coverage)
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: llvm-tools-preview
# 3⃣ Cache build artifacts for faster CI
- name: Cache cargo build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# 4⃣ Build and test with coverage instrumentation
- name: Run tests
run: |
cargo build --all-features
cargo test --all-features
# 5⃣ Install grcov
- name: Install grcov
run: cargo install grcov
# 6⃣ Generate lcov report
- name: Generate coverage report
run: |
mkdir -p coverage
grcov . \
--binary-path ./target/debug/ \
-s . \
-t lcov \
--branch \
--ignore-not-existing \
--ignore '../*' \
--ignore "/*" \
-o coverage/tests.lcov
# 7⃣ Upload to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }} # only needed for private repos
files: coverage/tests.lcov
fail_ci_if_error: true
flags: unittests
name: rust-codecov