- All playbooks
- Slow tests
- Build the test database once for all workers
Build the test database once for all workers
Have one parallel worker apply the schema while the others wait for it, so more workers stop repeating the same setup.
Company examples
How Ramp used this technique
Read what Ramp changed and follow the original sources.
Build the test database once for all workers
Ramp's test setup recreated the database from scratch by applying every migration, and each pytest-xdist worker ran that setup in parallel. At higher worker counts the concurrent schema changes ran Postgres out of working memory and repeated the same work. Ramp restructured the setup so one worker applies the schema, which let it run more workers on a machine twice the size.
Coordinating the schema setup let Ramp double the machine size and halve CI test times, which had been creeping up towards 20 minutes. Source
- Use it when
- Tests run in parallel workers that each repeat the same database or fixture setup, and raising the worker count stops paying off.
- Before applying it
- The other workers wait for the one that builds the schema, so the setup itself still sets a floor on the job's time.
Company Playbooks
- Read Anthropic’s playbookRun only affected tests
- Read DoorDash’s playbookRun build and test in parallel, sharded across CI agents
- Read Linear’s playbookBenchmark the same job on faster hardware
- Read Mastra’s playbookStarSling runners for the slowest test workflow
- Read OpenAI’s playbookRank CI fixes by the minutes they save
- Read Ramp’s playbookMove a CPU-bound test suite to a faster CPU
- Read Shopify’s playbookLet an agent iterate against one CI metric
- Read Spotify’s playbookBuild arm64 on native arm64 runners
- Read Stripe’s playbookRun only the tests a change can reach
- Read Uber’s playbookBuild the merge-queue speculations most likely to be needed