Est.

Warm Dependency Caches and Parallel Jobs in GitHub Actions Pipelines

Pairing warm caches with parallel jobs shortens CI without weakening results.

Sponsored by Graphide

Shipped by Agents Editors
· 9 min read · Updated
Cover illustration for “Warm Dependency Caches and Parallel Jobs in GitHub Actions Pipelines”
CI for Agent-Written Code · November 12, 2026 · 9 min read · 1,918 words

Warm dependency caches and parallel tests make GitHub Actions faster by removing two different delays. Caches cut the time spent on dependency setup in each job, while parallel execution cuts the time jobs spend waiting for one another. The largest useful gain comes from fixing both together, then choosing runners that can use the available parallelism without weakening the pass/fail result.

Why most GitHub Actions pipelines are slower than they need to be

A fresh runner does not inherit the previous job’s installed dependencies. Without a cache, commands such as npm ci, pip install, and go mod download do work that an earlier run already did. Docker builds lose their local state in the same way. The cost compounds when jobs wait unnecessarily for one another. Four serial jobs that each do a cold install add all four installation delays to the workflow’s critical path.

GitHub Actions already runs independent jobs in parallel. The needs field adds ordering, which is appropriate when a job requires another job’s output or successful completion. It is not necessary merely because lint, typecheck, and test appear in that order in the workflow file. A warm cache makes those jobs shorter, but they still spend time waiting when they need not. Even when that waiting is gone, cold installs still use compute to rebuild the same dependency state.

How can you tell whether runner startup, cache restores, or tests are slowing CI?

Open a representative run in the Actions UI before changing the workflow. Record the gap between the queued and started timestamps, then inspect the duration of each step. Separate waiting from setup and compute. Queue time, runner setup, cache restoration, dependency installation, build execution, and tests need distinct entries in the baseline because they call for different fixes.

Dependency installation is a common place to find recoverable time. However, builds that repeat unchanged work, sequential tests, Docker builds without reusable layers, and unnecessary needs dependencies can each dominate a different workflow. Read the job graph as well as the step timings. A relatively short job can delay the whole run if several other jobs must wait for it.

Record cold-cache and warm-cache runs separately. A cache that restores quickly when present may still miss too often to help most runs. Its restore time also belongs in the setup cost. After each change, compare the targeted phase against the baseline and check total elapsed time. That comparison shows whether the change shortened the critical path or sped up work that was already finishing early.

Caching dependency installs for Node, Python, Go, and Java

The setup actions are the simplest way to set up a dependency cache for common ecosystems. For projects using this runtime, use actions/setup-node@v4 with cache set to 'npm'. The action uses the package-lock.json hash as a cache key, and a warm hit lets npm ci reuse cached dependency data. The installer still runs after cache restoration. Caching supports installation rather than replacing the command that establishes the job’s dependencies.

Python uses actions/setup-python@v5 with cache set to 'pip'. Go uses actions/setup-go@v5 with cache set to true for its module download cache. Java uses actions/setup-java with cache set to 'maven'. These built-in options avoid a separate cache action in common cases. Where the built-in behavior is insufficient, actions/cache@v6 exposes an explicit path, key, and restore-keys fallback.

The fallback is useful when a dependency change invalidates the exact key. It restores a previous matching cache, after which the installer reconciles the changed dependencies. A stale cache plus reinstall is faster than a cold install. Keep dependency and compiler caches in separate steps with separate keys so that a lockfile change does not also force the compiler cache under a new key. Restore only what each job needs, use actions/cache/restore for read-only jobs, and save from one authoritative job.

GitHub’s dependency caching reference describes least-recently-used eviction when repository cache storage exceeds its limit. Correct keys therefore do not guarantee persistent hits. Another option is a runner that keeps warm dependency caches between runs, as Graphide CI does for frequent CI cycles on code written by agents. That approach reduces cold misses and restore time without changing the pass/fail result.

Docker layer caching with the GHA cache backend

Dependency caching does not preserve Docker’s local layer cache. GitHub’s runner reference says that hosted runners start as new virtual machines, except for single-CPU runners. A later job therefore cannot rely on the previous machine’s Docker layers. Without an external cache, unchanged dependency layers lose their reuse value. Language package caches and Docker layer caches address separate stores of reusable work.

Use docker/setup-buildx-action with docker/build-push-action and the GHA cache backend. In the build action’s with configuration, set context to the build context, cache-from to type=gha, and cache-to to type=gha,mode=max. The first cache field restores layers from GitHub’s cache service. The second saves intermediate layers for later reuse. Registry push authentication is separate from this configuration.

A layer can be reused when its inputs have stayed the same. Base-image and dependency-install layers are worth caching because they need not be rebuilt every time the application code changes. Measure a subsequent warm build against the cold baseline rather than judging the configuration on its first run. The same limits on cache storage apply here as to dependency caches, so active repositories need to keep track of how much they use. Cache eviction can cause unexpected misses in a working Docker build.

Parallelizing jobs by removing unnecessary sequential dependencies

Caching reduces the duration of individual jobs. Removing unnecessary dependencies changes how those durations combine into total workflow time. For lint, typecheck, and test jobs that share no data, define three independent entries under jobs without dependencies on one another. Put the gate on deploy instead. Its needs field should contain [lint, typecheck, test], so deployment waits for all three checks to pass.

With that structure, elapsed time is roughly the longest of lint, typecheck, and test, followed by deploy. It is no longer the sum of all four durations. Parallel execution does not imply equivalent billing savings, however. GitHub’s billing documentation specifies billing per job-minute, rounded up. Three jobs running at the same time still use compute for each job, though the developer waits only as long as the overlapping jobs take.

Keep dependencies in the graph when a job needs data from another job. When tests and deployment require the same build output, build once and share it through actions/upload-artifact and actions/download-artifact. A build job can produce dist/ for downstream consumers to reuse. Separately, a workflow concurrency block with cancel-in-progress set to true can stop stale builds when commits arrive in quick succession.

Matrix builds for multi-version and cross-platform testing

A matrix extends parallelism from different jobs to different configurations of one job. The strategy.matrix field generates a job for each combination of its values. Two Node versions and two operating systems produce four jobs. This makes coverage easy to set up, but each added dimension uses more compute. Each combination should test a configuration that is worth supporting.

Set fail-fast to false when results from every matrix cell are needed for diagnosis. Otherwise, one failing cell can cancel others before their results are available. Use exclude to remove combinations that add no useful coverage, such as an older Node version on Windows when that combination is never deployed. With include, a specific important combination can be added without expanding every dimension.

A dynamic matrix can limit this expansion further. An initial job uses dorny/paths-filter to identify changed packages and outputs their list. A downstream job reads that list through fromJson and uses it as its matrix input. Only the affected packages become matrix jobs.

Path filtering to skip jobs when unchanged code makes them irrelevant

Path filtering removes jobs that a change does not require. dorny/paths-filter detects which repository areas changed, and downstream jobs use those results to decide whether to run. For workflows that need not report a required check, trigger-level paths-ignore rules can prevent documentation-only changes from starting the workflow. Patterns such as **.md and docs/** express that scope. A workflow that never starts consumes no job-minutes.

Required checks change the design. If a required workflow is skipped entirely, GitHub creates no check run, and the pull request can remain blocked with a pending check. A gate inside that skipped workflow cannot fix the problem. For a required workflow, keep the workflow running and filter the expensive jobs within it instead.

The aggregation pattern uses a synthetic ci-ok job that always runs and lists every real job in needs. Branch protection requires exactly ci-ok. The gate must preserve the verdict by distinguishing intentionally skipped work from failed work. When a new job is added, its addition to the gate’s dependency list belongs in the same file and pull request. Reviewers can then see the verification change together with the new work.

How runner choice determines whether extra cores actually help

A larger runner helps only when the slow phase can use more CPU, memory, or disk capacity. Network waits, queue delays, approvals, and serial commands do not become parallel because the machine has more cores. Return to the measured bottleneck before upgrading. CPU saturation during the slow phase suggests that the job is compute-bound, while a long cache miss or network pull suggests that the delay comes from somewhere else. Hardware selection follows the workload.

Controls such as jest --maxWorkers, pytest -n auto, and go test -parallel can distribute test work across cores. Yet auto-parallelism on a 2-core machine still serializes work that could be distributed on 8 cores, a constraint distinct from job ordering through needs. Both can constrain throughput, but changing one does not remove the other.

GitHub’s larger runners range from 4 to 96 vCPU. GitHub’s changelog dates general availability of the 96-vCPU runner to April 2025. Availability is limited to organizations on GitHub Team or Enterprise Cloud, and larger runners are not free for public repositories. Plan compute allowances can apply on those plans. The practical comparison with third-party runners is a specific job’s elapsed time under its normal cache configuration at an acceptable cost per job-minute.

Graphide CI runs existing GitHub Actions jobs on its own runners with warm caches, splitting long test steps only where a check shows every result stays the same. For supported jobs, the choice of runner changes while the workflow keeps the same job logic.

What faster CI actually requires when agents write most of the code

Coding agents such as Claude Code, Codex, and Cursor increase the rate at which changes reach review. CI feedback that was tolerable at human writing speed can then become the verification bottleneck. Throughput and correctness are coupled at that point. Warm caches, parallel jobs, and selective execution shorten the path to a verdict, but a failing test must still fail the job.

For workflows where agents write much of the code, Graphide CI pairs warm caches with tests split across parallel runners where a check shows every result stays the same, and every test the job runs today still runs. A team that also wants selective testing should treat it as a separate decision with its own evidence, because its role is to reduce execution while preserving the failure signal and the conditions for passing.

Graphide review is a separate, complementary product. It offers a pull request check that reports findings and the basis for each. Either product can be used independently. Faster feedback is useful only when the team can still rely on what the verdict means.

Sources

  1. GitHub Actions hosted runner fleet now includes 96 vCPU larger runner - GitHub Changelog
  2. How Graphide CI works · Graphide docs
  3. The always-on agents · Graphide docs
  4. Which tests run, and why · Graphide docs

More in CI for Agent-Written Code