Releasing and running it · lesson 2 of 10
Ideas in this lesson
AContinuous integration (CI)merge often; build and test every change
BPipelinethe steps a server runs on every push
CGreen and red buildsall steps passed, or one failed

Continuous integration

Last updated

Four people change Pila every day. If each works alone for weeks and then merges, the merges are painful and the bugs pile up where nobody can see them. Continuous integration is the habit, and the machinery, that stops that: merge small changes often, and let a server build and test every one. In this lesson you'll watch Pila's pipeline run on four pushes, read a red build's log to find what broke, and learn the team rules that make CI work.

By the end of this lesson you can

  • Explain continuous integration: merging often, with every change built and tested
  • Read a pipeline’s result and its log to find why a build failed
  • Follow the team rules that keep the main branch green

Integration hell

Picture Pila's four developers each working on a separate branch for a month, then merging on the same day. Each branch worked alone. Together, they conflict in a hundred places, and the tests fail for reasons nobody can trace, because a month of four people's changes arrived at once. Teams in the 1990s called this integration hell, and some spent longer integrating than building.

The fix sounds backwards: if merging hurts, do it more often, so each merge is small.

Merge often, check every change

Continuous integration (CI) is two habits together:

  1. Merge small changes into the main branch often, at least daily. Branches live hours or a day or two, not weeks. Paul Hammant's name for this is trunk-based development.
  2. Every change is built and tested automatically by a server, on a clean computer, before and after it's merged. The steps it runs are called the pipeline.

If every step passes, the build is green; if any fails, it's red. Martin Fowler adds the rule that makes it work: a red main branch is everyone's first job. Nobody piles more changes on top of a broken build; the person whose change broke it fixes it, or reverts it, within minutes.

DORA's research finds CI among the practices that go with teams delivering faster and more reliably. Their caution: running a CI tool isn't the same as doing CI. Long-lived branches with a build server attached are still integration hell, just with a dashboard.

Pila’s pipeline on four pushes

Pila's pipeline has three steps, cheapest first. Play it, push by push:

  1. Lint (ruff) passed
  2. Test (pytest)
  3. Build image
  • ▶ running Add tests for the priority lane Marco
1 of 9 Marco pushes “Add tests for the priority lane”. The pipeline starts: Lint (ruff).

The order is deliberate: linting takes seconds, tests take a minute, building the image takes several. Failing fast saves everyone's time.

Read the red build

Jun’s build is red. According to its log, what went wrong?
What should Jun do about it?
Bea’s push failed at lint. Why didn’t the tests run?

Pipelines as code

The pipeline isn't set up by clicking in a settings page. It's a file in the repository, so it's versioned, reviewed and changed like any code. With GitHub Actions, Pila's is .github/workflows/ci.yml:

name: CI
on: [push, pull_request]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.14"
      - run: python -m pip install -r requirements.lock
      - run: ruff check .
      - run: python -m pytest -q

Read it top to bottom: on every push and pull request, take a fresh Linux computer, check out the code, install Python and the locked dependencies, lint, and test. You'll write this file yourself in capstone lesson C.7. Simple Git's Hooks and checks shows how the hosting site uses the result to block merging a red pull request.

Spot the trap: switch off the failing test

Spot the trapJun

It’s 4:50 p.m. A test on main has been red since lunch. Jun can’t see why, and wants to go home. “I’ll mark it skip for now,” he says, “so the build goes green.”

What happens if…

Check what you learned

What two habits make up continuous integration?
Main is red. What is the team rule?
Why is the pipeline kept as a file in the repository?

Sources

Every claim on this page comes from these sources: the standard, the founding text of a method, a study, or the official record of a project, from the body that publishes it. Industry reports are labelled as such.

All sources for Simple Software Development