Design a CI/CD Pipeline System - System Design
Everyone thinks CI/CD is simple. “A webhook fires on push, you spin up a box, run the tests, and if they pass you ship it - it is a glorified make test && deploy wrapped in a cron.” That mental model survives exactly until you ask the two questions that actually define the system. First: a monorepo push touches three files, but the repo has 40,000 build targets wired into a dependency graph where test E cannot run until library C is built which needs A and B - how do you figure out the minimal set of jobs that this change could possibly have broken, order them so no job runs before its inputs exist, and pack that onto a finite pool of workers so the critical path finishes fast and no small team’s tiny job waits forty minutes behind a mega-build? That is a dependency-aware scheduling problem over a DAG, and it is where every naive CI system falls over. Second: you are not running one team’s builds, you are running thousands of concurrent pipelines from hundreds of teams on a shared, elastic fleet of ephemeral workers that must be created clean, used once, and destroyed - because a build that leaks a secret or a cached artifact into the next tenant’s build is a security incident and a correctness bug at the same time. How do you provision those workers in seconds, schedule across them fairly, and guarantee a poisoned job never contaminates another? ...