Sub topic 3
Kinds of checks and what each one costs
This chapter assumes you know basic Git and pull request workflow, have used a CI system such as GitHub Actions, and know what linting, unit tests, and integration tests are. Here you will learn to describe any check by its cost and by the kind of failure it reports. The later chapters on placement build on these descriptions.
Why classify checks at all
A check that "runs tests" tells you little about where it should run. Two checks with the same name can differ by a factor of fifty in runtime. One can fail for reasons the author controls, while the other fails because a third-party service was down.
Classifying checks gives you a shared vocabulary. When someone proposes adding a check, you can ask the same questions every time:
- How long does it take, and what does it consume?
- How much of the system does it exercise?
- When it fails, how reliably does that point to a real defect, and who can fix it?
The cost dimensions
Cost has more than one part. Runtime is the most visible, but it is not the only one that matters.
| Dimension | What it measures | Why it matters |
|---|---|---|
| Wall-clock time | Minutes from trigger to result | Sets how long a developer waits or switches tasks |
| Compute | Runner minutes, memory, GPUs | Drives the CI bill and queue pressure |
| Environment setup | Databases, containers, browsers, secrets | Adds failure points unrelated to your code |
| Scope | How much of the system is exercised | Determines what kinds of defects can be caught |
| Determinism | How often the same code gives the same result | Decides whether a failure can be trusted |
| Maintenance | Effort to keep the check working | Costs engineer time, which is often the largest cost |
Wall-clock time and compute are different. A suite split across eight parallel runners finishes in a quarter of the time, but it uses the same total compute, and slightly more because each runner repeats setup.
Common categories of checks
The categories below are ordered roughly from cheapest to most expensive. The times are typical ranges for a mid-sized web application. Your numbers will differ, so measure them before you rely on them.
Static checks: formatting, linting, type checking
These read the source without running it. Formatters and linters usually finish in seconds. A type checker may take a minute on a large codebase.
- Scope: single files or the type graph of the project.
- Determinism: very high. The same input gives the same output.
- Failure signal: precise. The tool names a file and a line, and the author can fix it locally.
Unit tests
Unit tests run small pieces of code in one process, with dependencies replaced by fakes. A healthy suite runs in tens of seconds to a few minutes.
- Scope: one function or class at a time.
- Determinism: high, unless tests depend on time, randomness, or shared state.
- Failure signal: usually points directly to the changed code.
Build and package checks
These confirm that the project compiles, bundles, or builds a container image. They catch missing files, bad imports, and broken build configuration that unit tests can miss. Cost ranges from one minute to over twenty for large images, and caching changes it a great deal.
Security and dependency scans
Secret scanners and static analysis are fast. Dependency vulnerability scans depend on an external advisory database, so their results can change without any change to your code. This is an important property: a scan that passed yesterday can fail today on the same commit.
Integration tests
Integration tests run several components together, often with a real database or message queue started in a container. They usually take several minutes.
- Scope: the boundaries between components, such as queries, serialization, and configuration.
- Determinism: moderate. Startup timing and shared services add variation.
- Failure signal: broader. A failure says something is wrong at a boundary, but the author must investigate where.
End-to-end tests
End-to-end tests drive the whole system the way a user would, often through a browser. They commonly take tens of minutes to hours.
- Scope: full user flows across the deployed stack.
- Determinism: lowest of the common categories. Timing, rendering, and network behavior introduce variation.
- Failure signal: the weakest locator. A failure shows that a flow broke, but the cause could be in any layer.
Performance, load, and compatibility checks
These measure speed, throughput, or behavior across many environments, such as several operating systems and runtime versions. A compatibility matrix multiplies cost: five versions on three operating systems is fifteen jobs for one suite. Performance results also need stable hardware, and shared runners add noise.
Comparing categories side by side
| Category | Typical runtime | Scope | Determinism | Failure points to |
|---|---|---|---|---|
| Format, lint | Seconds | One file | Very high | A line of code |
| Type check | 10 s to 2 min | Project types | Very high | A line of code |
| Unit tests | 30 s to 5 min | One unit | High | A unit |
| Build or package | 1 to 20 min | Whole build | High | Build configuration |
| Dependency scan | 1 to 5 min | Dependencies | Changes over time | An external advisory |
| Integration tests | 3 to 20 min | Component boundaries | Moderate | A boundary |
| End-to-end tests | 20 min to hours | Full system | Lowest | Any layer |
| Performance, matrix | 10 min to hours | Environment or load | Low to moderate | Environment or code |
Cost and signal pull in opposite directions
The cheapest checks have the narrowest scope. A linter cannot tell you that checkout is broken. The most expensive checks see the most of the system, but they say the least about the cause.
The diagram below places the main categories on one line from cheap and narrow to costly and broad.
Moving right, wall-clock time, setup effort, and scope increase. Determinism and the precision of the failure message decrease. This is the underlying reason checks end up at different stages, and the next chapter's decision framework uses it.
Reading cost from a real workflow
You can read part of a check's cost directly from its configuration. The workflow below runs a slower suite with a service container, a matrix, and a timeout. Each of those lines is a cost signal.
name: integration
on:
pull_request:
jobs:
integration:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
node-version: [18, 20, 22]
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm run test:integration
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgresReading it as a cost profile:
- The matrix creates three jobs, so compute is roughly three times that of one version.
- The Postgres service adds startup time and a new way to fail, since the health check can time out.
- The
timeout-minutesvalue caps the worst case. Without it, a hung job can hold a runner for hours. fail-fast: falselets all versions finish, which uses more compute but shows whether a failure is version-specific.
Measuring instead of guessing
Estimates drift. Collect three numbers for each check before you decide where it runs:
- Median and 95th percentile duration, over the last few weeks. The 95th percentile shows the slow runs developers actually remember.
- Failure rate, split into failures that led to a code fix and failures that were fixed by a rerun. The second group is flakiness.
- Escape count, meaning defects that reached main or production in an area the check was meant to cover.
A check with a long runtime and a high rerun-fix rate is costly twice: it wastes time on every run and teaches people to ignore red results.
You can list recent run durations for a workflow with the GitHub CLI.
gh run list --workflow=integration.yml --limit 50 \
--json databaseId,conclusion,createdAt,updatedAt \
--jq '.[] | [.databaseId, .conclusion, .createdAt, .updatedAt] | @tsv'Subtract createdAt from updatedAt to get an approximate duration. The result includes queue time, so use it for trends rather than exact runtimes.
Common errors when judging cost
- Counting only the test command. Checkout, dependency install, image pulls, and service startup often take longer than the tests.
- Using the average. A few very slow runs hide in a mean. Use the median and 95th percentile.
- Ignoring queue time. If runners are scarce, a two-minute check can take ten minutes to start.
- Treating one failed run as flakiness. Confirm by rerunning the same commit, not by assumption.
- Forgetting maintenance. A browser suite that needs weekly selector fixes costs more than its runner minutes suggest.
Summary of the working model
Describe each check with six properties: wall-clock time, compute, setup, scope, determinism, and maintenance. Cheap checks are narrow and precise. Expensive checks are broad and ambiguous. Determinism and failure precision decide how much a team will trust a result, and trust decides whether the check is useful at all.
Exercise
A team's end-to-end suite takes 45 minutes at the median and has a failure rate of 20%. In 15 of every 20 failures, a rerun of the same commit passes. Using the cost dimensions from this chapter, describe the suite's problems, and name two numbers you would collect before deciding where it should run.
Show answer
The suite is expensive in wall-clock time (45 minutes) and has low determinism: 15 of 20 failures (75%) disappear on rerun, so they are flaky and not real defects. Each run therefore wastes time and trains people to ignore red results, which also adds maintenance cost. Two useful numbers: the 95th percentile duration, because slow runs set what developers experience, and the escape count, meaning real defects in the covered area that reached main. The rerun-fix rate and the median duration are also valid answers. Together they show whether the suite's value justifies its cost.
Exercise
A workflow has a matrix of 4 Node versions and 3 operating systems. Each job takes 6 minutes, and jobs run in parallel with no queueing. How many jobs run, how long does a developer wait, and how much compute is used?
Show answer
The matrix creates 4 x 3 = 12 jobs. They run in parallel, so the developer waits about 6 minutes. Total compute is 12 x 6 = 72 runner minutes. Parallelism reduced the wait but not the compute.