From 58cbde51d01e56fd3d514079f43ba4648ef99e26 Mon Sep 17 00:00:00 2001 From: Mac L Date: Tue, 9 Jul 2024 07:13:01 +0400 Subject: [PATCH] Add code coverage (#9) * Add code coverage * Rerun CI * Fix proc-macro dynamic lib * Fix github action --------- Co-authored-by: Michael Sproul --- .github/workflows/test-suite.yml | 16 ++++++++++++++++ .gitignore | 1 + Makefile | 10 ++++++++++ 3 files changed, 27 insertions(+) create mode 100644 Makefile diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index f120ac4..e5daf05 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index fa8d85a..a706d3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Cargo.lock target +cobertura.xml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c32cc4e --- /dev/null +++ b/Makefile @@ -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