How to keep PR feedback within 10 minutes
PR feedback is kept within 10 minutes by shortening the critical path: the longest chain of dependent jobs. First measure the breakdown by step, p50 and p90 and queue time, since often install or build is slow, not the tests. Then apply parallel jobs, caching, e2e sharding and selective runs, keeping a fallback full run on main and nightly for the latter.
CI/CD · Pipeline
A PR hangs for 25 minutes. Where does the time go: tests, install or the runner queue?
After ~10 minutes a developer switches to another task, and coming back to a red PR costs context. Often a pipeline is slow not because of tests: 6 minutes go to install, 4 to the build, 3 to the queue. Without measurements, optimizing blindly means speeding up what is already fast.
How it works and why. Measure first. You need a breakdown by job and step (checkout, install, build, tests), p50 and p90 duration and runner wait time. A run's duration is set by the critical path: the longest chain of dependent jobs. Only that is worth speeding up, because shortening a parallel branch outside it does not change the run time.
Sequential versus parallel
Levers, from cheap to expensive:
- Parallel jobs. lint, unit, the build, API and e2e do not wait for each other if there is no dependency.
- Cache. The npm cache, Docker layers, build output; the official docs advise against caching Playwright browsers, installing only the one you need is faster. Details in the lesson “Cache, matrix, concurrency and sharding”.
- E2E sharding.
--shard=i/Nin a matrix; duration ≈ the slowest shard, so evenness matters. - Selective runs. Path filters and affected-package analysis in a monorepo: a PR that changed documentation does not run e2e.
- The pyramid. Move checks from e2e to API and component tests; leave on the PR only the e2e of the critical path.
- Stability. Retries and re-runs also eat time: a lower flaky share speeds the pipeline up.
- Stronger runners. The last option: the bottleneck is usually not CPU.
Example. Skipping documentation by paths:
on:
pull_request:
paths-ignore:
- 'docs/**'
- '**/*.md'
# changes in shared code should run everything
# paths:
# - 'packages/shared/**'
This has the trap from the lesson “What to run on a PR, on merge and nightly”: if a workflow is skipped by a path filter, its required check stays Pending. So a required workflow always runs and checks the changed files itself: a step compares the changes with the base branch, and the expensive job gets an if on its result. A job skipped through if reports success and does not block the merge. Selective runs have one more risk: missing a dependency. A fallback is needed: a rule "a change to a shared library runs everything" and a full run on main and nightly.
How to speed up
Blind optimization
Take a stronger runner and add workers. If the time goes to install and the queue, the run barely speeds up.
Measure, then the longest chain
Break time down by step, find the critical path, remove the costliest part: cache, shards, duplicates.
Limits and alternatives. The 10-minute budget belongs to the PR, not to the whole pipeline: slow things move to main and nightly. Shards shorten e2e but add install overhead to every job, so past a certain number of shards the gain disappears. Run metrics and failure triage are in the lesson “CI metrics and failure triage”.
Typical mistakes.
- Optimizing without measurements.
- Too many shards: install and browser start eat the gain.
- Selective runs without a fallback full run.
- Caching
node_modulesinstead of the npm cache. - Ignoring time spent in the runner queue.
Check yourself
A run has lint (2 min), unit (3 min), a build (4 min) and e2e (12 min) in sequence. What should be done first?
Answer
Run the independent stages in parallel: lint, unit and the build do not depend on each other. The longest chain sets the time, and the next step is to shard e2e.
Why can path filters not be relied on completely?
Answer
A filter can miss indirect dependencies: a change to a shared library affects a service whose files did not change. So keep a fallback full run on main and nightly and a rule for shared code.