feat: Add code coverage to CI

This commit is contained in:
RedEtherbloom 2024-11-13 17:02:07 +01:00
parent b05539b3ab
commit ad449a53a3
4 changed files with 100 additions and 95 deletions

68
.github/workflows/generate_coverage.yml vendored Normal file
View file

@ -0,0 +1,68 @@
name: generate_coverage
on:
workflow_call
jobs:
grcov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Taskwarrior
uses: ./.github/actions/install-taskwarrior
with:
secret_gh_token: ${{ secrets.GITHUB_TOKEN }}
- run: |
# prepare taskwarrior, initial setup
task rc.confirmation=off || echo 0
- name: Install Rust toolchain for grcov compilation
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true
- name: Install grcov
uses: clechasseur/rs-cargo@v2
with:
command: install
args: grcov
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
override: true
components: llvm-tools-preview
- name: Checkout testdata
uses: actions/checkout@v4
with:
repository: kdheepak/taskwarrior-testdata
path: taskwarrior-testdata
- name: Build taskwarrior-tui with coverage
uses: clechasseur/rs-cargo@v2
with:
command: build
env:
RUSTFLAGS: "-Cinstrument-coverage"
- name: Run taskwarrior-tui tests in coverage environment
uses: clechasseur/rs-cargo@v2
with:
command: test
args: --workspace -- --nocapture
env:
TASKRC: taskwarrior-testdata/.taskrc
TASKDATA: taskwarrior-testdata/.task
RUST_BACKTRACE: full
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "your_name-%p-%m.profraw"
- name: Gather coverage data
run: |
mkdir ./target/debug/coverage/
grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/coverage/
shell: bash
- name: Coveralls upload
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ./target/debug/coverage/lcov