Faster CI usually comes down to a dozen fixable habits, not new hardware. A practical checklist for GitHub Actions ranks twelve of them, starting with the cheapest and working toward the ones that cost money.
Split queue time from run time
Every run has two clocks. One counts the wait for a runner, the other counts the work itself. A quick suite that sits in a queue for five minutes needs more capacity, and a slow suite that starts at once needs less work.
The GitHub CLI can print both numbers per job through the Actions API. Sort the slowest job’s steps by duration and the culprits tend to be the same: installing dependencies, running tests and building.
Kill outdated runs and reuse downloads
Push three commits in a minute and two of the resulting runs are already worthless. A concurrency group cancels them and frees runners for everyone else. Leave cancellation off for the main branch so each commit there still gets a verdict.
Re-downloading identical packages is frequently the biggest single step. The setup actions for Node and Python accept a cache option keyed on the lockfile, so downloads happen only when dependencies change. Docker builds get the same benefit from layer caching on the GitHub Actions cache backend.
Rerun only what changed
Most pull requests touch little code, but plenty of pipelines rerun every test anyway. There are three common ways to narrow the run.
- Path filters skip a workflow when a folder is untouched. They’re simple, but they go stale, and an unlisted shared file lets breakage through.
- Monorepo tools like nx and Turborepo work from a declared project graph. They’re exact between projects and blind to undeclared links, such as a test that reads a fixture.
- Read recording logs each file a test command opens and reruns that command only when one of those files changes. No declarations are needed.
Whatever the method, it can only skip what it can tell apart. A suite run as one command reruns in full after any edit, so split it by test file if you want finer skipping.
Pull requests get pushed repeatedly, too. If CI remembers only main, each push repeats the work the last push already passed. Keeping a result history for each pull request means the fifth push reruns only what the fifth push changed.
Use every core before adding machines
GitHub’s standard Linux runners have 4 cores, yet a test runner on default settings often uses one. Switch on parallel workers first, since they’re free: pytest-xdist for Python, and sharding flags in Vitest and Jest.
A matrix of machines comes second, because each added machine repeats checkout and install. Balance shards by how long tests take. Balancing by file count leaves one shard running long after the rest finish.
Fix flakiness and pin everything
A flaky test costs more than its runtime. Someone has to investigate a failure that no change caused. Rerunning the failed test alone separates the cases: if it passes, it’s either flaky or leaning on another test’s leftovers, and both belong in quarantine until fixed.
Floating versions create similar false alarms. An unpinned apt-get install, a latest image tag or a loose Node version can turn main red when nobody touched anything. Use ubuntu-24.04 instead of ubuntu-latest, read the Node version from an .nvmrc file and commit the lockfile.
Test merges as a group and surface failures
Two pull requests can pass separately and still break main together. GitHub’s merge queue tests each one on top of those ahead of it, as long as the workflow listens for the merge_group event.
Debug time includes the hunt through logs. Output JUnit XML and publish it as annotations so the failing assertion shows up on the pull request. Turning off fail-fast in a matrix returns every failure from one run.
Pay for bigger runners last
Larger runners from GitHub, Blacksmith, Depot or Namespace speed up every step with no workflow edits. They make the most sense after the free fixes, because they accelerate the work you kept, while the fixes remove work you didn’t need.
Everything above runs on GitHub’s free runners. Teams with several people and coding agents merging into main at once can look next at tooling that groups finished branches into a single test run and names the one that broke it. For most teams, the order is simple: measure, cancel, cache, select tests, then buy hardware.
Source: useland.dev