Skip to main content

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

  1. List the three checks that belong in the pre-commit stage for a typical capstone.
  2. State why coverage works as a floor but not as a target.
  3. Explain when a contract test is cheaper than an integration test against the real external system.
  4. 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:

  1. "Warnings from the linter are advisory in CI because engineers know what they are doing."
  2. "We hit 95% coverage by deleting the hard-to-test edge cases."
  3. "Our contract test passes, so we do not need an integration test for that adapter."
  4. "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:

  1. Pre-commit stage -- add a pre-commit config (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.
  2. CI lint job -- add a lint CI job that runs the same tools and blocks the pipeline if they fail.
  3. 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.
  4. Contract test -- pick one external seam. Write one consumer-driven contract test (or schema-based equivalent). Replay it against a local stub in CI.
  5. 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-commit hooks installed and green on a fresh clone
  • CI pipeline has a dedicated lint stage 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.