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 →

  1. 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
  1. Without a tool: compute changed paths from git diff --name-only origin/main...HEAD and map them to services, including shared libraries that trigger all their dependants.
  2. Generate a dynamic matrix in CI from that list.
  3. Use remote caching so unchanged targets reuse earlier results.
  4. 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.

All Real-World Interview questions Roadmap: Interview readiness

More on Pipelines at scale