123DevOps··2 min read

7 techniques to cut your CI pipeline time in half

Dependency caching, parallelism, selective testing, and other tactics that shave minutes — and money — off every build.

CI/CD

A slow pipeline isn’t just annoying: it makes PRs bigger, delays feedback, and encourages the infamous “I’ll just skip CI this once”. Here are seven techniques that usually bring quick wins.

1. Dependency caching

In GitHub Actions, the setup actions already come with built-in caching:

- uses: actions/setup-node@v4
  with:
    node-version: 22
    cache: npm
- run: npm ci

2. Docker layer caching

Use BuildKit with a remote cache so you don’t rebuild layers that haven’t changed:

- uses: docker/build-push-action@v6
  with:
    push: true
    tags: ghcr.io/org/api:${{ github.sha }}
    cache-from: type=gha
    cache-to: type=gha,mode=max

3. Parallelize your tests

Split the suite into shards using a matrix. Four 3-minute jobs beat one 12-minute job.

4. Run only what changed

In monorepos, path filters (paths) or tools like Nx and Turborepo run only the affected projects.

5. Fail fast

Put linting and type checking before the heavy tests. If lint fails in 30 seconds, nobody has to wait 10 minutes.

6. Cancel outdated runs

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

7. Measure before you optimize

Track the duration of each step over time. Without data, you’ll optimize the wrong step.

Summary: start with caching and canceling old runs — they’re the changes with the best cost-benefit ratio.

Get updates on new posts and stay in the loop!