Repository navigation
ci: adopt the engineering quality gates - #54
Merged
Merged
Conversation
The gate itself follows; these pin its behaviour first: changed-line parsing, Go coverage profiles, the CRAP ratchet, duplicate matching, waivers from the rendered PR description and the mutation budget. They fail now because .quality/gate.py does not exist yet.
8 tasks
Judges only the lines a pull request adds or changes, per the engineering quality standard: gofmt, coverage of changed lines, CRAP under 10 with the base ratchet, no new duplicate at 0.8 and no surviving mutant within a budget sized to the change. go test writes module paths into the coverage profile, which mutator cannot match to a checkout, so the gate rewrites it with repository paths before crapper and mutator read it. All 93 self-tests pass locally.
A quality job on ubuntu-latest renders the PR description for waivers (the only step with the token, before any PR code runs), installs the pinned tools, runs the gate's self-tests and the Go tests with coverage, then the gate. Checkout keeps no credentials and the setup actions get no token. The timeout leaves room for the 30-minute mutation cap; the repository is public, so the minutes are not metered.
parsilver
force-pushed
the
feat/43-quality-gates
branch
from
November 20, 2026 17:22
b56f101 to
1f8bec2
Compare
go test lists an empty function as a block of 0 statements, so its line read as untested even though there is nothing in it to run. Also keep __pycache__ out of the tree. Found by running the gate on a throwaway branch; 94 self-tests pass.
The report printed the first 8 characters of the name it was given, so a local run against origin/main showed "origin/m". 95 self-tests pass.
Statement coverage 87.88%, 59 functions with 10 over CRAP 10, no duplicate pair at 0.8, and a full mutation run of 425 sites: 293 killed, 102 survived, 30 uncovered (score 74.18%). Numbers may only improve; a PR that improves one updates this file.
Runs gate.main on a throwaway Go module with the real tools: the CRAP ratchet against a measured base, every check failing on a bad change, a weak test failing mutation, and no Go change. Splits uncovered_changed so its complexity stays under 10, drops a default that could never be read in the repo total, and adds tests for the mutants that survived (gofmt failing outright, an inert last line, a namespace without a slash, cpu_count returning None, a quota under one CPU). Gate functions: highest CRAP 8.0, 96% line coverage under coverage.py. Mutation on the Go-specific functions: 60 killed, 0 survived. 108 self-tests pass.
parsilver
marked this pull request as ready for review
November 20, 2026 18:19
parsilver
commented
Nov 20, 2026
parsilver
left a comment
Contributor
Author
There was a problem hiding this comment.
No Blocker. The gate follows the standard:
- Changed lines only. It gates only the lines the PR changes, and it takes the old CRAP debt rule from 2026-11-05.
- Mutation. It runs on the changed files and lines through
--linesrather than--changed; the PR explains why--changedwould mutate nothing on a CI checkout. The budget is 5 to 30 minutes. - Coverage. It is judged on added lines, with the repo total ratcheted in
baseline.json, measured on08061db.
The job is safe on a public repo:
- It runs on
pull_request, notpull_request_target, withcontents: readandpull-requests: read. persist-credentials: false.- The token appears only in the description-render step, which runs before any code from the PR.
- The setup actions get an empty token, and the rendered description is pinned by a sha256 output.
One thing from the same gate in another repo: a waiver paragraph with inline code (backticks) isn't counted, so write waivers as plain text. Merging.
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.
Closes #43
Adds a
qualityjob to CI that runs.quality/gate.pyon every pull request. The gate judges only what the PR adds or changes (the engineering quality standard's ratchet), so existing debt never blocks a PR. Rules, waivers and local use are in.quality/README.md.Acceptance criteria
A
qualityjob runs on every pull request onubuntu-latestand adds at most about 5 minutes. The job isquality gateinci.yml. It runs only onpull_requestevents, alongside the existing jobs, andimagesdoes not wait for it. On this PR, which changes no Go code, it took 59 s from start to finish: about 16 s to install the tools, 20 s of self-tests and 12 s of tests with coverage. Mutation scales with the change: the budget is sized from one timed mutant, with a floor of 5 and a cap of 30 minutes, per the standard's 2026-11-12 time amendment. A one-function change mutated in about 3 s locally. The timeout is 45 minutes, so the job can never time out before the gate reports. GitHub-hosted minutes are not metered on a public repo.gofmt -lis clean on the PR's changed files. The Format check runsgofmt -lon every Go file the PR adds or changes, tests included. It fails on a file gofmt would change, or one gofmt cannot parse.CRAP fails when an added or changed function scores 10 or more; untouched functions are not gated. Uses crapper with the owner's 2026-11-05 rule: a touched function already at 10 or more on base passes when it is no worse. The base is measured in a throwaway worktree only when that case comes up. Functions are keyed by file, receiver plus name, and order.
Duplication fails when the PR adds a pair at 0.8 or above. dryer runs on base and head. A head pair touching a changed line is new unless a base pair between the same two files still holds both sides.
Mutation runs on the PR's changed files only; a survivor fails unless the PR body says why it is equivalent. This differs from the literal
mutator --changed: that flag readsgit status, which is empty on a clean CI checkout, so it would mutate nothing. The gate gives mutator each changed file and its changed lines (--lines) instead. A site with no verdict also fails. A waiver is a paragraph of its own in the PR description, in the formEquivalent mutant: <file>:<line> <reason>. It is read from GitHub's own rendering of the description, so it counts only where a reviewer can see it.Coverage is reported on every PR, and the job fails when repo coverage drops below the baseline. Implemented per the standard's "Coverage on deletions" section, as agreed in the plan on the issue. Every executable line the PR adds or changes must be run by a test, or carry a waiver. The repo total is printed next to the baseline on every PR and ratcheted in
baseline.json, but a drop caused only by deleting covered code does not fail the PR. Review, not the gate, keepsbaseline.jsonfrom getting worse..quality/baseline.jsonis committed with coverage, functions over CRAP 10, duplicate pairs and mutation score measured on the default branch. Measured onmainat08061db. The Go code on this branch is identical to it.The gate asks for an update when coverage or the pair count improves.
No threshold is lowered or gate removed. Limits are CRAP under 10, similarity 0.8, and mutation 5 to 30 minutes, all as in the standard. No existing job changed.
Go specifics
go test -coverprofilewrites module paths. At the pinned commit, mutator matches a profile entry only when the checkout path ends with the module path, so on CI it would mark every site UNCOVERED and mutate nothing. The gate writes a copy of the profile with repository paths totarget/coverage/coverage.out, and both crapper and mutator read that copy. Checked oninternal/webhook/webhook.go: 15 sites went from UNCOVERED to 15 killed.go test -count=1on its own package, as mutator does for Go. The coverage profile is built without-coverpkgto match, so a line counts as covered only when its own package's tests run it. Mutants run in parallel, one per CPU of the cgroup quota.CI security
The description render is the only step that holds the token, and it runs before any code from the PR. Its sha256 is passed on as a step output, and the gate checks it. Checkout uses
persist-credentials: false, setup-go and setup-python gettoken: '', and permissions are explicit (contents: read,pull-requests: read). Untrusted values reach the shell only throughenv:. A PR runs its own copy of the gate, so review of.quality/and.github/stays the control.Commands run
The gate was also run on throwaway branches:
Abs. Mutation failed with> -> >=and0 -> 1surviving. With a rendered waiver paragraph and its hash, it passed and listed the reason.The same cases are now self-tests (
EndToEnd) using the real go, crapper, dryer and mutator.Gate numbers on the gate's own code
The gate is Python, which is outside its own Go scope, so these were run by hand:
main,held,coverage_verdict), with 96% line coverage from coverage.py..quality: no duplicate candidates.The waiver parser, duplicate matching and mutation plumbing are ported from the gate already reviewed on other repos. The waiver tests reuse its fixtures of GitHub renderings, with a Go path.
Risks
ci.ymlmakes thechangesjob rebuild all six images. After merge, their sha tags are pushed to GHCR. Nothing deploys.func mainwill fail Coverage, since no test runs it. It passes only with a waiver line that gives the reason, or a refactor that makesmaintestable./proc, so it is Linux only, which is fine onubuntu-latest.Not verified
EndToEndcases, which run the gate with the real go, crapper, dryer and mutator on a throwaway module, mutation and the CRAP base measurement included. The whole job took 59 s.