Continuous Integration
Scope of this domain
Continuous Integration tests whether you can design a pipeline that integrates every change into trunk quickly and reliably: trunk-based development, build-once artefact flow, fail-fast staging, test-pyramid economics, artefact repositories and pipeline health as a first-class concern.
Core rules and concepts
- CI means every developer integrates with trunk at least daily; long-lived feature branches are the opposite of CI.
- Every push triggers an automated build and unit tests; the commit stage should return feedback in roughly ten minutes.
- Build once and promote the same immutable artefact through environments. Never rebuild per environment, or you test a different binary.
- Test pyramid: many fast unit tests, fewer service and contract tests, a thin layer of end-to-end UI tests.
- Fail fast: order stages by speed and failure likelihood, parallelise independent jobs, cache dependencies keyed on lockfile hash.
- Flaky tests are defects: quarantine, fix or delete them. A red pipeline everyone ignores is worse than none.
- Branch protection, required status checks and a merge queue keep trunk green under concurrent merges.
- Artefacts live in a versioned repository (Nexus, Artifactory) with retention policy and provenance metadata.
Worked example
A pipeline takes 45 minutes and developers merge without waiting. Profiling shows 30 minutes is a serial end-to-end UI suite. Reasoning: move the full UI suite to post-merge or nightly, keep a small smoke subset pre-merge, shard unit tests across parallel runners, and cache package downloads. Add required status checks so bypassing is impossible. Track p95 pipeline duration and merge-to-green time as pipeline SLOs rather than asking people to be patient.
Traps that cost marks
- Calling a nightly job 'CI'; integration must happen on every change.
- Producing a different artefact per environment.
- Running the entire test suite serially on every push with no tiers.
- Muting flaky tests indefinitely instead of owning them.
- Treating CI as a product you buy rather than a practice you enforce.