Repository navigation
Measure coverage in CI and gate it - #13
Merged
Merged
Conversation
pytest-cov joins the dev extra; [tool.coverage.run] sets the source and turns on branch coverage; [tool.coverage.report] carries the project floor so there is one place to edit when ratcheting. The test job gains --cov and a second, tighter floor over cli/commands/, which holds 1699 of the 2158 missed statements. coverage.xml ships as an artifact from the 3.14 run. --cov stays out of addopts: a bare `pytest` would then fail for anyone without pytest-cov installed. Note that with branch = true both floors compare the combined statement-and-branch percentage that coverage report prints, not line coverage alone. Today those are 60.25% combined against 64.11% line and 43.62% branch, so the gate numbers (60 and 36) read four points lower than a line-coverage floor would. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Measure coverage in CI and gate it
CI measures test coverage and enforces two floors.
Changes
pytest-cov>=5.0added to thedevextra.[tool.coverage.run]:source = ["cryptnox_id_cli"],branch = true.[tool.coverage.report]:show_missing,skip_covered,fail_under = 60.testjob runspytest -q -m "not real_card" --cov --cov-report=term-missing --cov-report=xml, then a second report oversrc/cryptnox_id_cli/cli/commands/with--fail-under=36, and uploadscoverage.xmlfrom the 3.14 matrix entry.coverage.xmladded to.gitignore.Constraints
The floors compare combined coverage, not line coverage. With
branch = true,fail_underis checked against the combined statement-and-branch percentage thatcoverage reportprints. On this commit that is 60.25% combined, against 64.11% line and43.62% branch, so both floor numbers read about four points below what a line-coverage floor
with the same name would mean.
coverage report --fail-under=64exits 2 against this data.Read
fail_under = 60as the combined metric or the suite looks four points better than it is.--covis deliberately not inaddopts. Putting it there makes a barepytestfail foranyone without pytest-cov installed, and slows every local run. CI passes the flags explicitly.
The commands-layer floor is a separate
coverage reportinvocation because coverage.py hasno per-file
fail_under. It reads the same data file, so it adds no test time. The commandmodules hold 1699 of the 2158 missed statements, which is why they carry a floor of their own.
Both matrix entries are measured.
srchas noversion_infochecks or conditionalimports outside already-pragma'd blocks, so 3.10 and 3.14 are expected to report the same
number; a divergence would be worth seeing rather than suppressing.
Verification
ruff check,ruff format --check,mypy, 347 tests,sphinx-build -W --keep-going, andpython -m buildall pass. Both floors were negative-tested: raising either by one pointmakes the step exit 2.
🤖 Generated with Claude Code