Simyl
simylflow
Course Home
Module 2: Technical Practices
Lesson 4 of 5
12 min

Continuous Integration

Integrate early, integrate often. Build a shared codebase with confidence.

1What CI Really Means

Continuous Integration is widely misunderstood. It's not just a build server. It's not just running tests on every commit. Those are tools that support CI—but CI itself is a practice.

Real CI means:

  • Everyone commits to the main branch (or trunk) at least daily
  • Every commit triggers a build and test run
  • If the build breaks, fixing it is the top priority
  • The main branch is always in a deployable state

The "continuous" part is key. If you're integrating weekly, that's not continuous. If you have long-lived feature branches, that's not continuous. CI means integrating your work with everyone else's work every day, usually multiple times a day.

CI Is a Social Practice

CI is about how the team works together, not just about tooling. A Jenkins server that runs tests on month-old branches isn't CI.

2Trunk-Based Development

True CI requires trunk-based development: everyone commits to the main branch (often called "trunk" or "main").

This sounds scary. Won't people break things? That's where the discipline comes in:

  • Run tests before committing (don't break the build)
  • Commit small changes (easier to integrate, easier to fix)
  • Fix broken builds immediately (everyone stops until it's green)
  • Use feature flags for incomplete features (so they can be merged but not activated)

Long-lived branches are the enemy of CI. When you develop on a branch for weeks, you're not integrating. You're just postponing integration—and the longer you wait, the harder it gets.

Branch for hours, not days. Integrate daily, not weekly.

Good CI Practice

A developer creates a branch, works for 2-3 hours, runs all tests locally, then merges to main. This happens 3-4 times per day per developer. Integration is boring because conflicts are rare and small.

Fake CI

Developers create feature branches that live for 2-3 weeks. They merge to main when the feature is 'done.' Merge conflicts are painful. Integration bugs are common. The 'CI server' just tests the stale main branch.

3The 10-Minute Build

For CI to work, the build and test cycle must be fast. Martin Fowler suggests the 10-minute rule: the entire build, including all tests, should complete in under 10 minutes.

Why 10 minutes? Because:

  • Developers need fast feedback on their changes
  • Waiting an hour to know if you broke something is too slow
  • Long builds encourage developers to skip running tests locally

If your build takes too long:

  • Parallelize tests
  • Use faster hardware
  • Optimize the slowest tests
  • Consider test categorization (fast unit tests vs slow integration tests)
  • Revisit test design (too much database? too much network?)

Some teams run a fast subset locally (unit tests) and the full suite on the CI server. That's fine as long as the full suite runs quickly enough to provide timely feedback.

4When the Build Breaks

The build will break. What matters is what happens next.

The rule: When the build breaks, fixing it becomes the top priority. Everything else stops.

This might seem extreme, but consider: a broken build means the team can't trust the main branch. Everyone's work is blocked because they can't integrate safely. Every minute the build is broken is a minute of accumulated risk.

Who fixes it? Usually the person who broke it. But if they're stuck, others help. A broken build is a team problem, not an individual problem.

How to prevent breaks:

  • Run tests locally before committing
  • Keep changes small (smaller changes = smaller risk)
  • Pay attention to CI notifications (fix fast)
  • Don't commit and leave for the day

Some teams use a "CI sheriff" rotation—someone responsible for watching the build and coordinating fixes. This prevents the bystander effect where everyone assumes someone else will fix it.

Broken Builds Are Emergencies

A broken build that stays broken for hours is a team failure. Treat it with the same urgency as a production incident.

5Beyond the Build

CI is the foundation for more advanced practices:

Continuous Delivery (CD): Every commit can be deployed to production. Deployment is a business decision, not a technical one.

Continuous Deployment: Every commit that passes tests is automatically deployed to production. No human approval required.

Not every team needs continuous deployment. But every team benefits from CI. Start there.

CI metrics to watch:

  • Build time (should be under 10 minutes)
  • Build frequency (should be multiple times per day per developer)
  • Mean time to fix broken builds (should be minutes, not hours)
  • Test coverage (not a perfect metric, but a signal)

CI isn't just about catching bugs. It's about creating a rhythm where integration is boring, routine, and safe. When integration is safe, everything else gets easier.

Key Takeaways
  • CI is a social practice, not just a tool—everyone integrates daily to the main branch
  • Trunk-based development is essential: branch for hours, not weeks
  • The build should complete in under 10 minutes
  • Broken builds are emergencies—fixing them is top priority
  • CI creates a rhythm where integration is boring and safe
Common Pitfalls to Avoid
  • Equating 'having a CI server' with 'doing CI' (the practice matters)
  • Long-lived feature branches that undermine continuous integration
  • Slow builds that discourage frequent integration
  • Ignoring broken builds or letting them stay broken

Practice Exercises