Skip to content

Commit

Permalink
Add code coverage (#9)
Browse files Browse the repository at this point in the history
* Add code coverage

* Rerun CI

* Fix proc-macro dynamic lib

* Fix github action

---------

Co-authored-by: Michael Sproul <[email protected]>
  • Loading branch information
macladson and michaelsproul authored Jul 9, 2024
1 parent 852ff75 commit 58cbde5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,19 @@ jobs:
run: cargo test --release
- name: Check all examples, binaries, etc
run: cargo check --all-targets
coverage:
runs-on: ubuntu-latest
name: cargo-tarpaulin
steps:
- uses: actions/checkout@v3
- name: Get latest version of stable Rust
run: rustup update stable
- name: Install cargo-tarpaulin
uses: taiki-e/install-action@cargo-tarpaulin
- name: Check code coverage with cargo-tarpaulin
run: make coverage
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Cargo.lock
target
cobertura.xml
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# These hacks are required for the test binaries depending on the dynamic library libstd-*.so
# See: https://github.com/rust-lang/cargo/issues/4651
#
# We also need to exclude the derive macro from coverage because it will always show as 0% by
# virtue of executing at compile-time outside the view of Tarpaulin.
coverage:
env LD_LIBRARY_PATH="$(shell rustc --print sysroot)/lib" \
cargo-tarpaulin --workspace --all-features --out xml --exclude tree_hash_derive

.PHONY: coverage

0 comments on commit 58cbde5

Please sign in to comment.