From abac087bfe7b9ec2c6a1ded4d41095463b9313b3 Mon Sep 17 00:00:00 2001 From: Ross Younger Date: Thu, 16 Jan 2025 23:20:58 +1300 Subject: [PATCH] test: add coveralls --- .github/workflows/ci.yml | 13 ++++++++++++- CONTRIBUTING.md | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 687bb0f..a221ba5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,6 +91,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: taiki-e/install-action@cargo-llvm-cov - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true @@ -102,7 +103,17 @@ jobs: run: scripts/install-ubuntu-packages # Checks begin here! - run: cargo fmt --all --check - - run: cargo test --locked + #- run: cargo test --locked # replaced by cargo llvm-cov to run with coverage tests - run: cargo clippy --locked --all-targets - run: cargo build --locked --all-targets - run: cargo doc --no-deps --locked + - name: unit tests with coverage + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info --locked + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + with: + path: lcov.info + - name: Send to coveralls + uses: coverallsapp/github-action@v2.3.4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d31fd02..0e69c9b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,6 +14,7 @@ If you're thinking of contributing something non-trivial, it might be best to ra * Changes should normally be based on the `dev` branch. _(Exception: hotfixes may be branched against `main`.)_ * PRs must pass the full set of CI checks (see below). No exceptions. * Unit tests are encouraged, particularly those which fail before and pass after a fix. + * The CI workflow runs code coverage analysis. * Refactoring for its own sake is OK if driven by a feature or bugfix. * Clean commit histories are preferred, but don't be discouraged if you don't know how to do this. git can be a tricky tool. * Commit messages should follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). @@ -32,6 +33,7 @@ If you're thinking of contributing something non-trivial, it might be best to ra | Unit tests pass | `cargo test` | | Lints | `cargo clippy --all-targets` | This is a reasonably pedantic set of lints, which I make no apologies for | | Docs build | `cargo doc --no-deps` | +| Code coverage | `./scripts/coverage`, then examine `target/coverage/html` | [issue]: https://github.com/crazyscot/qcp/issues/new/choose