Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Add test coverage reporting #162

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
CARGO_TERM_COLOR: always
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

jobs:
skip_check:
Expand All @@ -30,7 +31,12 @@ jobs:
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
run: make test
- name: Upload coverage reports to Codecov
run: |
curl -o target/test_coverage/codecov -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x target/test_coverage/codecov
./target/test_coverage/codecov -t ${CODECOV_TOKEN}

clippy_check:
needs: [skip_check]
Expand Down
22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,24 @@ build:
cargo build
maturin develop

.PHONY: precommit build
test:
# clean test coverage directory
rm -rf ./target/test_coverage
mkdir -p ./target/test_coverage

# install dependencies
rustup component add llvm-tools-preview
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "./target/test_coverage"
chmod +x ./target/test_coverage/grcov

# run tests
CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='target/test_coverage/profraw/cargo-test-%p-%m.profraw' cargo test --verbose

# generate html coverage report
./target/test_coverage/grcov . --binary-path ./target/debug/deps/ -s . -t html --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/test_coverage/html

# generate lcov coverage report
./target/test_coverage/grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/test_coverage/tests.lcov


.PHONY: precommit build test