Skip to content
Latchkey

How to Reduce CI Cost by Consolidating Jobs

Each job provisions a fresh runner, checks out the repo, and restores caches, so ten one-minute jobs cost far more than one ten-minute job.

Where jobs do not need real parallelism or different runners, fold them into one job with sequential steps to pay the setup tax once.

Steps

  • List jobs that each do a few seconds of work on the same runner.
  • Merge lint, typecheck, and unit tests into one job when they share setup.
  • Keep genuinely long or independent work as separate parallel jobs.

Workflow

.github/workflows/ci.yml
jobs:
  checks:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm run lint
      - run: npm run typecheck
      - run: npm test

Gotchas

  • Merging serializes steps, so it trades a little wall-clock time for lower cost.
  • Do not merge jobs that need different runner sizes or operating systems.
  • Billing rounds each job up to the nearest minute, so many short jobs round up repeatedly.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →