
Our CI/CD Pipeline Went From 45 Minutes to 8 Minutes. Here's Every Optimization.
Our test suite took 38 minutes. Docker build took 7 minutes. Deploy took 3 minutes. Total: 48 minutes from push to production. Engineers were batching changes because deploying was painful. Batching caused bigger PRs. Bigger PRs caused more bugs. More bugs caused more hotfixes. Hotfixes went through the same 48-minute pipeline. It was a doom loop. Here's how we broke it. Optimization 1: Parallel Tests (38 min → 12 min) Our 2,400 tests ran sequentially in one process. The fix was embarrassingly simple: # .github/workflows/ci.yml jobs : test : strategy : matrix : shard : [ 1 , 2 , 3 , 4 ] steps : - uses : actions/checkout@v4 - run : npm ci - run : npx jest --shard=${{ matrix.shard }}/4 4 parallel runners, each running 1/4 of the tests. 38 minutes → 12 minutes. The 4 runners cost us nothing extra — GitHub gives parallel runners on the free tier. Key insight: Test parallelization has almost linear scaling up to 8 shards. After that, the overhead of spinning up runners starts eating into th
Continue reading on Dev.to DevOps
Opens in a new tab




