From a22d44f2b2574e1c520a6a6a810157d400aaa89d Mon Sep 17 00:00:00 2001 From: Illia Polosukhin Date: Wed, 4 Mar 2026 02:14:15 +0000 Subject: [PATCH] ci: add code coverage with cargo-llvm-cov and Codecov (#511) * ci: add code coverage with cargo-llvm-cov and Codecov Add a Coverage workflow that runs on PRs and pushes to main using cargo-llvm-cov with --all-features, uploading LCOV results to Codecov. Include codecov.yml config with project/patch targets and ignore rules for stub files. Co-Authored-By: Claude Opus 4.6 * ci: switch Codecov upload to OIDC (tokenless) Use GitHub OIDC tokens instead of CODECOV_TOKEN secret so coverage uploads work for fork PRs where secrets are not available. Co-Authored-By: Claude Opus 4.6 * ci: fail coverage upload strictly on push, leniently on PRs Use a conditional so pushes to main fail if Codecov upload breaks (preventing silent reporting gaps) while PRs stay lenient to avoid blocking fork PRs where OIDC may not be available. Co-Authored-By: Claude Opus 4.6 * ci: disable Codecov auto-detection to suppress warnings We provide lcov.info explicitly, so disable auto-search for gcov, coverage.py, and Xcode formats that produce noisy warnings. Co-Authored-By: Claude Opus 4.6 * ci: include channels-src and tools-src in coverage reporting These WASM source directories should be tracked for test coverage rather than ignored. Co-Authored-By: Claude Opus 4.6 * ci: remove stale ignore entries from codecov.yml The marketplace, ecommerce, taskrabbit, and restaurant stub files no longer exist in the codebase. Co-Authored-By: Claude Opus 4.6 * ci: run coverage on push to main only Avoids running tests twice on PRs (once in test.yml, once for coverage). Coverage runs on merge to main instead. Simplify fail_ci_if_error to always true since it only runs on push now. Co-Authored-By: Claude Opus 4.6 --------- Co-authored-by: Claude Opus 4.6 --- .github/workflows/coverage.yml | 32 ++++++++++++++++++++++++++++++++ codecov.yml | 10 ++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/coverage.yml create mode 100644 codecov.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..19e75340 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,32 @@ +name: Code Coverage +on: + push: + branches: [main] + +permissions: + id-token: write + contents: read + +jobs: + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: dtolnay/rust-toolchain@stable + with: + components: llvm-tools-preview + - uses: Swatinem/rust-cache@v2 + with: + key: coverage + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate coverage + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + - name: Upload to Codecov + uses: codecov/codecov-action@v5 + with: + files: lcov.info + disable_search: true + use_oidc: true + fail_ci_if_error: true diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..3e31b00a --- /dev/null +++ b/codecov.yml @@ -0,0 +1,10 @@ +coverage: + status: + project: + default: + target: auto + threshold: 1% + patch: + default: + target: 80% + threshold: 5% \ No newline at end of file