Repository navigation
ci: gate coverage and complexity (tarpaulin + cargo-crap, pinned) - #24
Merged
Merged
Conversation
Turn the upload-only coverage job into two gates fed by one instrumented test run: cargo-tarpaulin 0.37.5 with --fail-under (the run doubles as the test run, since tarpaulin exits non-zero on test failure) and cargo-crap 0.6.1 with --threshold/--fail-above scored from the same lcov.info. Both tools install from pinned per-arch release tarballs with asserted versions, so runs cannot disagree on tool version. Measured on this tree (ptrace, --all-features, non-integration suite): line coverage 63.72% (1823/2861), 339 tests green; worst CRAP 380.0 crawl_site (src/tools/crawl.rs:521, CC 19, 0% covered). Floor 61 (measured -3pp), ceiling 420 (worst +10%); the ceiling was proven able to fail (threshold 100 exits 1 on this tree, 420 exits 0). The gate covers the suite the repo already gates on: the integration tests hit live network backends and are skipped here as in the test job.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gates added
Converts the existing upload-only
coveragejob (cargo llvm-cov+ Codecov withfail_ci_if_error: false) into a job that actually gates, running two gates off ONE instrumented test run:cargo-tarpaulin 0.37.5with--fail-under. Tarpaulin's run is also the test run (it exits non-zero on any test failure), so this becomes the repo's hermetic test gate for the non-integration suite too.cargo-crap 0.6.1with--threshold+--fail-above, parsed from the same run'slcov.info. CRAP(m) = CC²·(1−cov)³ + CC, so it only means anything with a coverage feed — hence one job, not two.always()summary step posts coverage %, function count, and worst CRAP to the run summary. The Codecov upload stays, still non-gating.Runner choice
runs-on: ubuntu-latest, unchanged — this is a public repo and its existing ubuntu-latest jobs work; the job follows the repo's own conventions (actions/checkout@v4,dtolnay/rust-toolchain@stable+llvm-tools-preview,actions/cache@v4keyed on Cargo.lock). The coverage engine is--engine Llvmfor estate-wide consistency (the ptrace engine is blocked inside confined runner containers — "ASLR disable failed: EPERM" — measured on the fleet); thellvm-tools-previewcomponent the toolchain step already installs backs it.Measured first-run numbers (local, build host)
Measured with the pinned binaries (tarpaulin 0.37.5) under the ptrace engine,
--all-features,--locked, suite filtered-- --skip integration:crawl_site(src/tools/crawl.rs:521, CC 19, 0% coverage — behind the opt-incrawlbergfeature, measured under--all-features). Next: 99.5Commands::run(src/main.rs:291), then 90.0 ×3 (run_crawl,expand_sitemap_children,crawl_site_with_crawlberg) and 86.3FetchClient::fetch_with_retry. 333 functions scored; no file needs excluding — the clap entry point insrc/main.rspeaks at 99.5, far under the ceiling.Thresholds + rationale
Both gates were proven able to fail before merge:
--fail-aboveat threshold 100 exits 1 on this tree; at 420 it exits 0. The coverage floor likewise fails the build if the suite drops below 61% or any test fails.Ratchet rule
src/(floor rises 61 → 63 → 65 …); lowered only with an explicit measurement-based reason in the PR.crawl_siteat 380 and the three 90-scored crawl functions — a few tests covering thecrawlbergmove collapses all four); hard floor at 30 CRAP before the gate may be tightened further.DB needs
None. No Postgres, no services, no secrets.
Caveats / blockers
integration_tests.rssuite hits live search backends, example.com, arXiv, and celiachia.it; it cannot run hermetically, which is why this repo's owntestjob gates on-- --skip integrationand itsintegration-testjob runscontinue-on-error: true. The coverage gate runs exactly the suite the repo already gates on. Retiring the skip means hermeticizing that suite (e.g. wiremock fixtures), not a CI change.