Skip to content

Commit

Permalink
tests(issue-28): Introduce code coverage
Browse files Browse the repository at this point in the history
Add script for local coverage checking and extended tests job in ci to produce code coverage and publish to codecov.
  • Loading branch information
Tomasz-Kluczkowski committed Dec 30, 2024
1 parent 9067a5f commit 873d100
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,19 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo test --workspace
- run: |
export RUSTFLAGS="-Cinstrument-coverage"
export LLVM_PROFILE_FILE="cargo-tests-%p-%m.profraw"
cargo test --workspace
grcov . --binary-path ./target/debug/deps/ \
--source-dir . \
--output-types cobertura \
--branch \
--ignore-not-existing \
--ignore **/tests.rs \
--ignore "/*" \
--output-path .
bash <(curl -s https://codecov.io/bash) && echo "Uploaded code coverage"
build:
name: Build
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ target
.secrets
.test_data
.run
logs
logs
**/*.profraw
15 changes: 15 additions & 0 deletions scripts/generate_coverage_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

export RUSTFLAGS="-Cinstrument-coverage"
export LLVM_PROFILE_FILE="cargo-tests-%p-%m.profraw"
cargo test --workspace
mkdir -p target/coverage
grcov . --binary-path ./target/debug/deps/ \
--source-dir . \
--output-types lcov,html,markdown,cobertura \
--branch \
--ignore-not-existing \
--ignore **/tests.rs \
--ignore "/*" \
--output-path target/coverage
find . -name '*.profraw' -type f -delete

0 comments on commit 873d100

Please sign in to comment.