Quality Gates Clinic
Deliverable: a capstone repo with pre-commit hooks, lint and type checking, a coverage floor, and one contract test all running as blocking CI gates.
Retrieval Prompts
- List the three checks that belong in the pre-commit stage for a typical capstone.
- State why coverage works as a floor but not as a target.
- Explain when a contract test is cheaper than an integration test against the real external system.
- Name one check that should block a merge and one that should stay advisory, with rationale.
Compare and Distinguish
- formatter versus linter versus type checker
- line coverage versus branch coverage
- consumer-driven contract test versus schema-based contract test
- pre-commit hook running locally versus CI stage running on push
Common Mistake Check
For each statement, identify the error:
- "Warnings from the linter are advisory in CI because engineers know what they are doing."
- "We hit 95% coverage by deleting the hard-to-test edge cases."
- "Our contract test passes, so we do not need an integration test for that adapter."
- "Pre-commit hooks slow down commits, so we skip them locally and let CI catch issues."
Mini Application
In one 2-hour session, wire the gates:
- Pre-commit stage -- add a
pre-commitconfig (or language equivalent) with formatter, linter, and type checker. Commit the config. Run it once across the entire repo and fix (or baseline) the findings. - CI lint job -- add a
lintCI job that runs the same tools and blocks the pipeline if they fail. - Coverage -- configure coverage in CI with per-directory floors and at least one exclusion. Confirm a deliberate deletion of one test drops coverage below the floor and fails CI; then restore.
- Contract test -- pick one external seam. Write one consumer-driven contract test (or schema-based equivalent). Replay it against a local stub in CI.
- Documentation -- update the repo README with a short "Quality gates" section that names each gate, its tool, and where its config lives.
Evidence Check
pre-commithooks installed and green on a fresh clone- CI pipeline has a dedicated
lintstage that runs before tests - a coverage floor is configured and fails CI when violated
- at least one contract test runs in CI against a local stub
- README documents the gates
Stretch
- Add a secrets scanner (e.g.,
gitleaks) to the pre-commit stage. - Schedule a nightly job that runs the contract test against the real external provider and alerts on drift.