Testing and Code Review

Continuous Integration Basics

What continuous integration means, how a simple pipeline builds and tests each change automatically, and what to watch for when setting one up for a team.

On this page
  1. The idea in one paragraph
  2. What a simple pipeline does
  3. Why it helps
  4. What to put in the pipeline
  5. Habits that make it work
  6. Related terms
  7. Common mistakes
  8. Getting started

The idea in one paragraph

Continuous integration, usually shortened to CI, is the practice of merging work into a shared branch often and having a machine build and test every change automatically. The word “integration” refers to combining the work of several people. The word “continuous” means this happens many times a day, in small steps, instead of once in a painful event near a deadline.

The problem it addresses is old. When two people work separately for weeks, their changes drift apart, and combining them later produces conflicts and surprises that nobody can easily trace to a cause. Merging small changes frequently keeps the differences small and the surprises cheap.

What a simple pipeline does

A pipeline is the sequence of automatic steps that runs when someone pushes a change. A minimal one looks like this:

  1. Trigger. A push to the shared repository, or a request to merge, starts the run.
  2. Checkout. The CI system gets a clean copy of the code at that exact commit.
  3. Set up. It installs dependencies and prepares the environment.
  4. Build. It compiles or packages the software, if that applies.
  5. Test. It runs the automated tests, normally starting with the fastest.
  6. Report. It marks the change as passing or failing and shows where it failed.

The key property is that this happens on a clean machine rather than on one person’s laptop. A surprising number of “it works for me” problems come from files, settings or installed tools that exist on one computer and nowhere else. A clean build makes those hidden dependencies visible.

Why it helps

  • Fast feedback. A failure found minutes after a change is made is much easier to fix than one found weeks later, because the author still remembers the change and the list of suspects is short.
  • A shared definition of working. The pipeline gives the team an agreed, written-down answer to “does this change break anything we check for?”
  • Safer changes. With version control holding the history and CI checking each step, reverting a bad change is straightforward.
  • Less manual repetition. Checks nobody has to remember to run are checks that actually get run.

None of this guarantees correct software. CI runs the checks you have written; if the tests are thin, a green result means little. It is a way of applying your tests consistently, not a substitute for having good ones. Test coverage numbers and the level of integration testing in the suite determine how much a pass is worth.

What to put in the pipeline

Begin with what already exists: the build and the unit tests. Add other checks when they earn their place:

  • Style and formatting checks, so reviewers do not spend time on spacing.
  • Static analysis tools that look for common mistakes without running the code.
  • Integration tests, which are slower and may need a database or other services started for the run.
  • Packaging steps that confirm the software can actually be assembled into something deliverable.

A good ordering puts quick checks first. If formatting fails in ten seconds, there is no reason to wait twenty minutes for the full test run before telling the author.

Habits that make it work

CI is as much a team habit as a tool. A few practices decide whether it helps or becomes noise.

Keep changes small. Small changes build quickly, fail for understandable reasons and are easier to review. Pull requests that stay focused also make code review faster for the person reading them.

Fix a broken main branch first. If the shared branch is failing, the team is working on an unreliable base. Most teams agree that restoring it takes priority over new work, and reverting the offending change is often the quickest way to do so.

Treat flaky tests as bugs. A test that fails at random teaches people to rerun and ignore. Once that habit forms, genuine failures are dismissed too. Quarantine or repair unreliable tests rather than living with them.

Keep the pipeline fast. Long runs lead people to batch up changes, which defeats the purpose. If the suite grows slow, split it, run the heaviest tests less often, or speed up the slowest ones.

Make failures readable. A red mark with a clear log pointing to the failing step saves everyone time. Someone should be able to see what failed without being an expert in the CI system.

You will often see “continuous delivery” and “continuous deployment” used alongside CI. They extend the same idea further down the line: delivery means every passing change is kept in a state where it could be released, and deployment means passing changes are released automatically. Teams differ in how far they go, and many reasonably stop at CI. Whether automatic release is suitable depends on the product; software involved in safety or regulated work usually needs approval steps that rules in that industry require.

Common mistakes

  • Treating a green pipeline as proof the software is correct.
  • Letting the pipeline depend on secrets or settings that only one person knows.
  • Allowing slow, unreliable checks to build up until nobody trusts the result.
  • Skipping the pipeline “just this once” under deadline pressure, which is exactly when mistakes are most likely.

Getting started

For a small project, a workable first version is modest: on every push, check out the code, install dependencies, run the tests and report the result. Once the team is used to seeing that signal, add checks one at a time. The tool you choose matters less than keeping the feedback fast, honest and visible to everyone.

The complete guide to testing and code review

Software Testing Concepts Every Engineer Should Know
Read the guide

Keep exploring

Guides from other topics

All topics →