Sub topic 3
Kinds of checks and what each one costs
This chapter assumes you know basic Git and pull request flow, have used a CI system such as GitHub Actions, and know what linting, unit tests, and integration tests are. Here you learn to describe any check by its cost and its failure signal. The next chapter uses those descriptions to decide where a check runs.
Four dimensions of a check
Every check has a cost profile. Four properties matter most when you place it:
- Runtime: wall-clock time from start to result. Developers wait on this.
- Compute and money: runner minutes, paid services, and test environments.
- Scope: how much of the system the check exercises, from one file to the whole deployed product.
- Failure signal: how clearly a failure points to a cause, and how often a failure is false.
Runtime and scope usually rise together. A wider scope tends to give a vaguer, less reliable failure signal.
Common categories
| Check | Typical runtime | Scope | Failure signal |
|---|---|---|---|
| Formatting and lint | seconds | One file at a time | Precise, rarely false |
| Type check and build | under a few minutes | Whole codebase, no runtime | Precise |
| Unit tests | seconds to minutes | One function or class | Precise, rarely flaky |
| Integration tests | minutes | Several components, often a database | Moderate, some flakiness |
| End-to-end tests | tens of minutes to hours | Full deployed system | Vague, most often flaky |
| Security and dependency scans | minutes | Code and dependencies | Can fail on new advisories, not on your change |
| Performance and load tests | long | Whole system under load | Noisy, needs baselines |
The security row deserves attention. A dependency scan can fail even if nobody touched the code, because a new advisory was published. That kind of failure blocks unrelated pull requests, so it often fits a scheduled run better.
Cost grows faster than scope
Moving from unit tests to end-to-end tests does not add a little cost. It adds setup (services, data, browsers), longer runs, and more sources of random failure. A suite that takes 40 minutes and fails 3% of the time by chance will, over many pull requests a day, block someone constantly.
Measuring your own checks
Do not rely on the table alone. Your numbers differ. Record these for each check:
- Median and 95th percentile runtime.
- Failure rate, split into real failures and reruns that passed.
- Cost per run, from runner minutes.
Most CI systems expose run durations. In GitHub Actions you can list recent runs of a workflow with the GitHub CLI:
gh run list --workflow=pr.yml --limit 50 --json conclusion,createdAt,updatedAtSubtract createdAt from updatedAt to approximate duration, and count failure conclusions. A run that failed and then passed on a rerun with no code change is evidence of flakiness.
Common errors
- Judging by name. A suite called "unit tests" that starts a database behaves like an integration suite. Classify by what it does and what it costs.
- Ignoring the tail. A median of 4 minutes with a 95th percentile of 25 minutes still stalls developers.
- Treating all failures alike. A lint failure and an end-to-end timeout need different responses. Note which kind each check usually produces.
Exercise
Your "unit tests" job takes 12 minutes, starts a Postgres container, and fails and then passes on rerun about 4% of the time. Which category does it behave like, and which two cost dimensions show that?
Show answer
It behaves like an integration suite. The runtime (12 minutes) and the failure signal (intermittent failures that pass on rerun) show it, and the database dependency widens its scope beyond a single unit.