Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code coverage to the CI #915

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 10 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
coverage:
status:
project:
default:
target: 89% # the required coverage value
threshold: 0.5% # the leniency in hitting the target
patch:
default:
target: 90% # the required coverage value
threshold: 0.5% # the leniency in hitting the target
31 changes: 31 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ on:
- "ipa-*/src/**/*"
- "ipa-core/benches/**/*"
- "ipa-core/tests/**/*"
- ".github/**/*"
pull_request:
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
- "ipa-*/src/**/*"
- "ipa-core/benches/**/*"
- "ipa-core/tests/**/*"
- ".github/**/*"
workflow_dispatch:

env:
Expand Down Expand Up @@ -155,3 +157,32 @@ jobs:
run: rustup component add rust-src
- name: Run tests with sanitizer
run: RUSTFLAGS="-Z sanitizer=${{ matrix.sanitizer }} -Z sanitizer-memory-track-origins" cargo test -Z build-std --target $TARGET --no-default-features --features "cli web-app real-world-infra test-fixture descriptive-gate"

coverage:
name: Measure coverage
runs-on: ubuntu-latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools

- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov

- name: Measure coverage
run: ./scripts/coverage-ci --lcov --output-path ipa.cov

- name: Report to codecov.io
uses: codecov/codecov-action@v3
with:
file: ipa.cov
fail_ci_if_error: false

17 changes: 17 additions & 0 deletions scripts/coverage-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# shamelessly stolen from https://github.com/rustls/rustls/blob/c296594db33c7d50ab642ab48f8302e6a88dcebf/admin/coverage

set -e

source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov clean --workspace

cargo build --all-targets

# Need to be kept in sync manually with tests we run inside check.yml.
cargo test
for gate in "compact" "descriptive"; do
cargo test --no-default-features --features "cli web-app real-world-infra test-fixture $gate-gate"
done

cargo llvm-cov report "$@"