Gate CI on lint, types, and a coverage floor - #290
Merged
Conversation
CI ran only tests. The repo has a full pre-commit config -- isort, black, pylint, flake8, mypy -- but nothing enforced it outside a contributor's own machine, and the coverage job measured coverage, uploaded the XML, and never checked it. Both could regress silently. Add a lint job that runs the pre-commit hooks at their pinned versions, so CI and `pre-commit install` cannot disagree about what passes. pytest is skipped in that job because the matrix jobs already run the suite. Give coverage a floor. Scope measurement to the package (previously the report also counted the test files, which are ~100% by construction and inflate the total into something that cannot regress meaningfully) and set fail_under to 70, below the current 73% so kernel-gated tests that skip on hosts without Landlock/BPF/cgroup do not turn the floor into a flake. The XML upload now runs even when the check fails, so a regression is still inspectable. The gate found existing drift on main, which is the argument for having it: tests/test_landlock.py had an import block isort wanted to collapse and tests/test_ebpf_contract.py had three statements over the line limit. Both are fixed here so the new job starts green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ebvMQ3vLxdK3joymz6Feg
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.
The problem
CI ran only tests. The repo has a complete
.pre-commit-config.yaml— isort, black, pylint, flake8, mypy — but nothing enforced it outside a contributor's own machine. And thecoveragejob ran the suite, generatedcoverage.xml, uploaded it as an artifact, and never looked at the number. Both could regress silently, and one already had.The change
A
lintjob that runs the pre-commit hooks at their pinned versions. Using pre-commit rather than re-listing the tools means CI andpre-commit installcannot drift apart about what passes.pytestis skipped in that job viaSKIP=pytest— the matrix jobs already run the suite across six Python/OS combinations rather than once.A coverage floor. Two parts:
[tool.coverage.run] source = ["pyisolate"]). Previously the report also counted the test files, which are ~100% by construction and inflate the total into a number that cannot meaningfully regress.fail_under = 70, and the CI job now runscoverage reportso the threshold is actually checked.70 is deliberately below the current 73%: kernel-gated tests (Landlock, BPF, cgroup) skip on hosts lacking those features, so a floor set at the observed value would flake depending on the runner. It's a floor, not a target. The XML upload moved to
if: always()so a regression is still inspectable when the check fails.The gate immediately found drift on
mainWhich is rather the point:
tests/test_landlock.py— an import block isort wants collapsed to one linetests/test_ebpf_contract.py— three statements over the line limit that black reformatsBoth are fixed in this PR so the new job starts green. Neither is a behavior change.
Verified locally
mypy is clean across 46 source files and pylint is 9.17 (above the existing
fail-under = 8.0), so this gate reflects where the repo already is rather than imposing new debt.Follow-up worth considering separately
Coverage is inverted: enforcement code is the least tested (
child.py27%,confine.py45%,landlock.py57%,thread.py55%) while telemetry sits at 100%. A repo-wide floor doesn't capture that — per-module floors on the security-critical modules would, but that's a bigger conversation than this PR.Generated by Claude Code