You have a monorepo with 40 services. Every commit builds and tests all of them. How do you fix that?
AdvancedScenarioPipelines at scale
Answer
Situation read → You need a dependency graph so a change builds and tests only the affected services plus whatever depends on them.
What I'd do →
- Use a monorepo build tool that understands the graph: Nx or Turborepo (JS/TS), Bazel or Pants (polyglot), or Go workspaces with a change detector.
npx nx affected -t test build --base=origin/main --head=HEAD
- Without a tool: compute changed paths from
git diff --name-only origin/main...HEADand map them to services, including shared libraries that trigger all their dependants. - Generate a dynamic matrix in CI from that list.
- Use remote caching so unchanged targets reuse earlier results.
- Still run everything nightly to catch anything the graph missed.
Why → Affected-only builds make CI time grow with the size of the change, not the size of the repo.
Interview tip → Mention shared libraries: a change there must rebuild everything that depends on them, which is where naive path filters fail.
More on Pipelines at scale
The CI pipeline takes 45 minutes. Developers want it under 10. How do you approach it?IntermediateFlaky tests fail 1 in 5 runs and developers just click "re-run". How do you fix this culture and the tests?BeginnerYour self-hosted GitHub runners can't keep up at peak and sit idle at night. How do you run them at scale?AdvancedDocker builds in CI take 12 minutes because every runner starts with an empty cache. How do you speed them up?IntermediateHow do you secure the software supply chain from commit to production?AdvancedFifty teams have copy-pasted pipelines that have drifted apart. How do you standardise them?Intermediate