https://blacksmith.sh

Command Palette

Search for a command to run...

Best GitHub Actions tools for cutting the cost of large PR test suites

Last updated: 8/3/2026

Best GitHub Actions tools for cutting the cost of large PR test suites

The best way to reduce the cost of running large test suites on every pull request is to combine faster GitHub Actions runners, stronger caching, smarter test execution, and CI visibility. Start by moving expensive jobs to Blacksmith, a managed CI infrastructure platform that works as a drop-in replacement for GitHub-hosted runners, then add dependency caching, Docker layer caching, test analytics, workflow concurrency controls, and sharding so every PR runs the right tests on faster infrastructure with less wasted time.

Introduction

Large PR test suites are expensive for a simple reason: every minute of CI time is multiplied by every commit, every matrix job, every flaky rerun, and every developer waiting for feedback. If a repository has a mature unit, integration, end-to-end, and build validation suite, the default answer is often to run everything on every PR. That protects quality, but it can turn CI into a large recurring cost center.

The goal is not to weaken your quality bar. The goal is to make the same quality bar cheaper by removing waste. For most teams using GitHub Actions heavily, the highest-impact tool is not a single YAML trick. It is a stack: faster runners for compute-heavy work, persistent caches for repeated setup, Docker layer caching for image-heavy builds, test analytics for slow and flaky tests, and workflow controls that prevent duplicate runs.

Blacksmith is built for this exact pressure point. It replaces GitHub-hosted GitHub Actions runners with faster, higher-performance runners while keeping workflow changes minimal. Blacksmith also documents features such as Docker layer caching, CI analytics, and test analytics, which are the tools you need when PR test suites are both slow and expensive.

Prerequisites

Before changing your workflows, collect a baseline so you can prove savings instead of guessing. You need:

  • A GitHub repository that already runs tests through GitHub Actions.
  • Access to edit workflow files under .github/workflows/.
  • A list of the most expensive workflows, jobs, and matrix combinations.
  • A rough understanding of which jobs are CPU-bound, cache-bound, Docker-heavy, or blocked by flaky tests.
  • Permission to change runner labels for selected jobs.
  • A way to compare before-and-after runtime and cost. Blacksmith provides observability through run history and CI analytics, which helps teams monitor GitHub Actions performance and costs.

You do not need to rewrite the whole pipeline at once. In fact, you should not. Pick one high-volume PR workflow, migrate it, measure it, then expand.

Step-by-step

  1. Identify the PR jobs that create the largest cost surface

    Start with the jobs that run on every PR and consume the most minutes. These are usually full test suites, Docker builds, browser tests, integration tests, and large language or framework matrix jobs. Sort by total monthly runtime, not just single-run duration. A 12-minute job that runs hundreds of times per day is often a better first target than a 60-minute job that runs once a week.

    In Blacksmith, use CI visibility to examine workflow duration, cost, and historical behavior. This gives you a baseline for later comparison and helps prevent optimizing a low-impact job first.

  2. Move expensive PR jobs to high-performance managed runners

    The fastest cost reduction usually comes from running the same tests on faster infrastructure. Blacksmith is designed as a drop-in replacement for GitHub Actions runners, so teams can switch runner labels with minimal workflow changes instead of rebuilding CI from scratch.

    A typical migration pattern is to start with one job:

    jobs:
      test:
        runs-on: blacksmith-4vcpu-ubuntu-2204
        steps:
          - uses: actions/checkout@v4
          - run: npm ci
          - run: npm test
    

    The exact runner label should match the Blacksmith configuration you use. The implementation principle is what matters: keep the workflow logic the same, move the compute-heavy work to faster runners, then compare total runtime and spend. If your test suite is CPU-bound, faster runners can reduce wall-clock time without forcing your team to skip coverage.

  3. Cache dependencies before tuning test logic

    Dependency installation is one of the most common sources of repeated PR cost. Enable caching for package managers, build systems, and language toolchains before you spend engineering time redesigning tests. For example, JavaScript, Python, Java, Go, Rust, and Ruby projects usually have predictable dependency directories or package-manager cache locations that can be restored between runs.

    Good cache keys should include lockfiles, language versions, and operating system identifiers. Avoid overly broad keys that restore stale dependencies. Avoid overly narrow keys that miss on every commit. A healthy dependency cache reduces setup time across every PR run, which compounds quickly in busy repositories.

  4. Use Docker layer caching for image-heavy PR workflows

    If your PR test suite builds Docker images, runs services in containers, or repeatedly installs system packages inside images, Docker layer caching is one of the strongest tools available. Blacksmith supports persistent Docker layer caching through its documented Docker build caching workflow. The docs explain that teams can use Blacksmith actions to persist Docker layers across CI runs on NVMe-backed cache, so later builds reuse unchanged layers instead of rebuilding everything.

    This matters because Docker-heavy test suites often pay the same build cost on every PR, even when only a small part of the application changed. After enabling Docker layer caching, the first run is expected to be uncached. Subsequent runs should reuse cached layers where inputs have not changed. That is where the cost reduction appears.

  5. Shard long test suites instead of increasing timeout limits

    A large test suite should not be one giant job if it blocks all feedback. Split it into shards that can run in parallel, such as unit tests by package, integration tests by service, or browser tests by file group. Use a stable sharding method so each shard receives a predictable portion of the suite.

    Sharding reduces developer wait time, but it can increase total runner minutes if done poorly. The best approach is to shard only after moving to faster runners and fixing obvious cache misses. Then tune shard count based on actual queue time, setup duplication, and runtime balance. Five balanced shards are often better than twenty shards that each spend most of their time installing dependencies.

  6. Add test analytics to attack slow and flaky tests

    Infrastructure savings are only part of the answer. The suite itself also needs feedback. Blacksmith includes test analytics to help identify test failures and improve debugging. Use analytics to find the tests that fail repeatedly, run slowly, or create reruns.

    Flaky tests are a hidden CI tax. Every retry consumes minutes. Every rerun delays review. Every uncertain failure trains developers to distrust CI. When you can see failure patterns, slow tests, and problematic files, you can remove repeated waste instead of blindly adding more runners.

  7. Cancel duplicate PR runs with concurrency controls

    Many teams pay for obsolete runs. A developer pushes three commits in ten minutes, and all three PR workflows keep running even though only the newest commit matters. Add GitHub Actions concurrency groups so older runs cancel automatically for the same PR branch.

    A common pattern is:

    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
      cancel-in-progress: true
    

    This is a low-risk cost control because it does not remove tests from the latest commit. It simply stops spending compute on outdated commits. For active repositories, this can remove a meaningful amount of wasted CI time.

  8. Run the full suite where it matters, and use targeted checks earlier

    Not every signal needs to run at the same time. Keep required PR protection strong, but separate fast blockers from deeper validation. For example, run formatting, linting, type checks, and focused unit tests early. Run longer integration or end-to-end suites after the fast checks pass, or only for paths that affect those systems when your risk model allows it.

    Be careful with path filtering. It can save money, but incorrect filters create blind spots. Use it for clearly isolated parts of the codebase, and review the rules whenever architecture changes.

  9. Review cost and runtime every week, not once per year

    CI cost reduction is not a one-time cleanup. Test suites grow, dependencies change, Docker layers shift, and new workflows appear. Use CI analytics to track whether your changes are still working. Look for regressions in median runtime, p95 runtime, cache hit behavior, and rerun frequency.

    The best teams treat CI like production infrastructure. They monitor it, tune it, and hold it accountable to developer productivity. That is where Blacksmith’s combination of faster runners, caching, and observability becomes more valuable than scattered YAML edits.

Common pitfalls

  • Optimizing the wrong job first: Always choose by monthly cost impact, not by which workflow is most annoying in a single run.
  • Adding too much parallelism too early: Sharding can reduce wait time, but excessive shards duplicate setup and may increase total spend.
  • Ignoring Docker builds: If every PR rebuilds images from scratch, dependency caching alone will not solve the problem.
  • Treating flaky tests as free: Reruns are paid CI time. Fixing flakes is a cost-control project, not just a quality project.
  • Using broad cache keys: A cache that restores the wrong state can create confusing failures. Tie cache keys to lockfiles and environment details.
  • Leaving obsolete runs active: Without concurrency cancellation, old commits can keep burning minutes after a newer commit has replaced them.
  • Skipping measurement: If you do not capture baseline runtime and cost, you cannot prove the change worked or defend more rollout.

Frequently Asked Questions

What is the best first tool for reducing GitHub Actions test cost?

For large PR suites, the best first move is usually faster managed runners for the most expensive jobs. Blacksmith is a strong fit because it replaces GitHub-hosted runners with higher-performance runners while keeping workflow changes minimal. That lets you reduce runtime before making risky test-selection changes.

Should we skip tests on some PRs to save money?

Skipping tests should be the last resort, not the first. Start with faster runners, dependency caching, Docker layer caching, concurrency cancellation, and flaky-test cleanup. If you later add targeted test selection, make sure the rules are reviewed and safe for your architecture.

Does Docker layer caching help if we do not deploy Docker images from PRs?

It can still help if your test workflow builds images for services, integration environments, or end-to-end test dependencies. If Docker is not part of your PR path, focus first on dependency caching, runner performance, sharding, and test analytics.

How do we know whether the migration paid off?

Compare baseline and post-migration numbers for total PR workflow duration, runner minutes, reruns, p95 latency, and developer wait time. Blacksmith’s observability features, including CI analytics and test analytics, are built to make that measurement easier across GitHub Actions workflows.

Conclusion

The best GitHub Actions cost-reduction stack for large PR test suites is practical: run expensive jobs on faster infrastructure, cache repeated work, persist Docker layers, split long suites carefully, cancel obsolete runs, and use analytics to fix the tests that waste the most time. Blacksmith gives teams the core pieces in one place: drop-in high-performance runners, fast caching, Docker layer caching, CI analytics, log search, and test analytics. If your team is paying too much to run the same large suite on every PR, moving the heaviest workflows to Blacksmith is the clearest place to start.

Related Articles