From 34f6171664098359d88429bf2e2bb0605b1332de Mon Sep 17 00:00:00 2001 From: Alex Koshelev Date: Fri, 12 Jan 2024 10:26:45 -0800 Subject: [PATCH 1/3] Add code coverage to CI --- .github/codecov.yml | 10 ++++++++++ .github/workflows/check.yml | 29 +++++++++++++++++++++++++++++ scripts/coverage-ci | 17 +++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .github/codecov.yml create mode 100755 scripts/coverage-ci diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 000000000..d687995b3 --- /dev/null +++ b/.github/codecov.yml @@ -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 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index b6e31d477..7825dfbfa 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -155,3 +155,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 + diff --git a/scripts/coverage-ci b/scripts/coverage-ci new file mode 100755 index 000000000..eefcbb21d --- /dev/null +++ b/scripts/coverage-ci @@ -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 "$@" From cfb97e41811c0e0252409071cdab86b7b71f6b6c Mon Sep 17 00:00:00 2001 From: Alex Koshelev Date: Fri, 12 Jan 2024 11:20:16 -0800 Subject: [PATCH 2/3] Run CI on workflow changes --- .github/workflows/check.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 7825dfbfa..ef8f615ba 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -7,6 +7,7 @@ on: - "ipa-*/src/**/*" - "ipa-core/benches/**/*" - "ipa-core/tests/**/*" + - ".github/**/*" pull_request: paths: - "**/Cargo.toml" @@ -14,6 +15,7 @@ on: - "ipa-*/src/**/*" - "ipa-core/benches/**/*" - "ipa-core/tests/**/*" + - ".github/**/*" workflow_dispatch: env: From 0169c2512b572de3b521e6efefd3523fd03a5f8b Mon Sep 17 00:00:00 2001 From: Alex Koshelev Date: Mon, 15 Jan 2024 09:51:47 -0800 Subject: [PATCH 3/3] Feedback --- .github/workflows/check.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ef8f615ba..aba7c292a 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -161,8 +161,6 @@ jobs: coverage: name: Measure coverage runs-on: ubuntu-latest - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} steps: - name: Checkout sources uses: actions/checkout@v4 @@ -183,6 +181,7 @@ jobs: - name: Report to codecov.io uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} file: ipa.cov fail_ci_if_error: false