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

Commit

Permalink
Add test coverage reporting (#162)
Browse files Browse the repository at this point in the history
Adds test coverage reporting to the Chiquito project.


## Demo
Check out the code coverage report on my fork
https://app.codecov.io/github/nullbitx8/chiquito  

Check out my fork to see how the `Rust` workflow in the project's Github
Actions now runs tests with coverage reporting.

https://github.com/nullbitx8/chiquito/actions/runs/6653135943/job/18078525896

It looks like Chiquito already has a codecov access token, so we can
already see the results here

https://app.codecov.io/github/privacy-scaling-explorations/chiquito/tree/add-test-coverage-reporting
  • Loading branch information
nullbitx8 authored Oct 26, 2023
1 parent d0933d7 commit 009690b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
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

0 comments on commit 009690b

Please sign in to comment.