BOOK DEEP READ · CONTINUOUS DELIVERY · CH 7

The Commit Stage

Continuous Delivery · Ch 7 · Jez Humble & David Farley · 2010

中文 →

What is this chapter about?

The app on your phone is built by programmers who hand in their "homework" to a shared codebase several times a day. Chapter 7 of Continuous Delivery is about what kind of check should run in the first few minutes after that homework arrives. That check is called the commit stage. It is the first gate of the pipeline from the previous chapter, and the only gate every developer faces personally, every single day.

An analogy

Think of hospital triage. When you walk into the emergency room, a nurse spends five minutes on your temperature, blood pressure and pulse — no scans, no surgery. One job only: use the fastest, cheapest instruments available to spot who is obviously in trouble. The expensive examinations come later, and only for the people triage lets through.

Here is the counterintuitive part: the value of triage is not in how thorough it is, but in being fast enough that you are willing to stand there and wait for the result. A very thorough triage desk that takes two hours is no triage desk at all.

Why the old world was hard

This check can fail in three ways, all fatal. Too slow: pile every check together and it takes two hours, so nobody waits — you hand in your work and move on, and when the report comes back red you have long forgotten what you changed. Useless: the report says only "failed", not what broke or how to reproduce it, so people quietly learn to ignore it. Dishonest: some checks pass and fail at random on identical code; after a few rounds, the team's first reaction to a red light stops being "go fix it" and becomes "just run it again" — and from that moment the gate is dead.

Three rules that fix it

One: give it a time budget of ten minutes. That number is not arbitrary — it is roughly the limit of how long a person will stand there and wait. Past it, behaviour changes: people stop waiting, keep working, and several people's changes pile up so nobody can tell whose change turned the light red. Ten minutes is a design constraint, not a performance target.

Two: only run checks that are both fast and trustworthy. What is slow? Touching a database, clicking through a user interface, waiting a while before looking. Most of this chapter teaches you how to keep those three out: give the little piece of code under test a stand-in — a fake database, a clock that stops on command — so it finishes in a thousandth of a second, and thousands of them together still take seconds.

Three: once it passes, seal the box and label it. That exact box travels down the rest of the line; nobody is allowed to build a new one. The reports get filed alongside it, where the whole team can read them.

The genuinely hard part

The difficulty is not in the checking — it is in the code being checked. For a small piece of code to be tested on its own with stand-ins, it has to be separable from everything around it. With tangled legacy code you will find you simply cannot write fast tests. Which is this chapter's hidden lesson: when tests are hard to write, that is usually not a testing problem — it is the design raising an alarm.

It does have a cost: this gate is fast precisely because it never touches a real database or a real network, so "green" only means nothing obviously broke — it does not mean the change is fit to ship. That verdict belongs to the slower, more expensive gates further down.

One line to remember

The commit stage is the pipeline's first gate: a trustworthy red or green within ten minutes. It does not aim to be thorough — it aims to be fast enough that you wait, and reliable enough that you believe it. Thoroughness is somebody else's job, further down the line.

Want the actual contents, where the ten minutes goes, and how to pick test doubles? → Switch to the deep read