How to Batch Small CI Jobs to Cut Startup Overhead
Ten tiny jobs each pay the same checkout and setup cost; one batched job pays it once.
Every job re-checks-out the repo and re-installs tooling before doing seconds of real work. When many jobs are that small, the fixed setup overhead dominates. Batching related work into fewer jobs amortizes it.
Steps
- Find jobs whose real work is short relative to their setup.
- Merge related short jobs into one job with sequential steps.
- Keep genuinely parallel, long jobs separate so total wall time does not grow.
Workflow
.github/workflows/ci.yml
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run lint
- run: npm run typecheck
- run: npm run test:unitTradeoffs
- Batching serializes work, so it can add wall-clock time versus parallel jobs.
- Batch only where setup dominates; keep long independent jobs parallel.
Related guides
How to Replace Polling Loops in CI With WaitsReplace busy sleep-and-poll loops in CI with health-check waits and webhooks so a job stops burning idle CPU…
How to Parallelize CI Without Wasting Machine-HoursSplit a slow CI suite across shards to finish faster, weighing the honest tradeoff that more parallel machine…