ArticleslgStudy

computer science

Continuous integration

Continuous integration is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Continuous integration rather than just read about it. In short: Continuous integration (CI) is the practice of integrating source code changes frequently and ensuring that the integrated codebase is in a workable state. Typically, developers merge changes to an integration branch, and an automated system builds and tests the software system.

Continuous integration — main illustration
Continuous integration — illustration

Key takeaways

  • Continuous integration belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Continuous integration to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Continuous integration from memory before moving on to harder problems.

Reference excerpt

Continuous integration (CI) is the practice of integrating source code changes frequently and ensuring that the integrated codebase is in a workable state. Typically, developers merge changes to an integration branch, and an automated system builds and tests the software system. Often, the automated process runs on each commit or runs on a schedule such as once a day. Grady Booch first proposed the term CI in 1991, although he did not advocate integrating multiple times a day, but later, CI came to include that aspect.

History

The earliest known work (1989) on continuous integration was the Infuse environment developed by G. E. Kaiser, D. E. Perry, and W. M. Schell. In 1994, Grady Booch used the phrase continuous integration in Object-Oriented Analysis and Design with Applications (2nd edition) to explain how, when developing using micro processes, "internal releases represent a sort of continuous integration of the system, and exist to force closure of the micro process". In 1997, Kent Beck and Ron Jeffries invented extreme programming (XP) while on the Chrysler Comprehensive Compensation System project, including continuous integration. Beck published about continuous integration in 1998, emphasising the importance of face-to-face communication over technological support. In 1999, Beck elaborated more in his first full book on Extreme Programming. CruiseControl, one of the first open-source CI tools, was released in 2001. In 2010, Timothy Fitz published an article detailing how IMVU's engineering team had built and been using the first practical CD system. While his post was originally met with skepticism, it quickly caught on and found widespread adoption as part of the lean software development methodology, also based on IMVU.

Practices The core activities of CI are that developers co-locate code changes in a shared, integration area frequently and that the resulting integrated codebase is verified for correctness. The first part generally involves merging changes to a common version control branch. The second part generally involves automated processes including: building, testing and many other processes. Typically, a server builds from the integration area frequently, i.e. after each commit or periodically, like once a day. The server may perform quality control checks such as running unit tests and collect software quality metrics via processes such as static analysis and performance testing.

Build automation

Build automation is considered a best practice in software development. Build automation tools are used to automate building. Proponents of CI recommend that a single command should have the capability of building the system. Automation often includes automating the integration, which often includes deployment into a production-like environment. In many cases, the build script not only compiles binaries but also generates documentation, website pages, statistics and distribution media (such as Debian DEB, Red Hat RPM or Windows MSI files).

Atomic commits CI requires the version control system to support atomic commits; in other words, all of a developer's changes are handled as a single commit.

Committing changes When making a code change, a developer creates a branch that is a copy of the current codebase. As other changes are committed to the repository, this copy diverges from the latest version. The longer development continues on a branch without merging to the integration branch, the greater the risk of multiple integration conflicts and failures when the developer branch is eventually merged back. When developers submit code to the repository they must first update their code to reflect the changes in the repository since they took their copy. The more changes the repository contains, the more work developers must do before submitting their own changes. Eventually, the repository may become so different from the developers' baselines that they enter what is sometimes referred to as "merge hell", or "integration hell", where the time it takes to integrate exceeds the time it took to make their original changes.

Testing locally Proponents of CI suggest that developers should use test-driven development and ensure that all unit tests pass locally before committing to the integration branch so that one developer's work does not break another developer's copy. Incomplete features can be disabled before committing, using feature toggles.

Continuous delivery and continuous deployment

Continuous delivery ensures the software checked in on an integration branch is always in a state that can be deployed to users, and continuous deployment automates the deployment process. Continuous delivery and continuous deployment are often performed in conjunction with CI and together form a CI/CD pipeline.

Version control

Proponents of CI recommend storing all files and information needed for building in version control (for git a repository), and that the system should be buildable from a fresh checkout and not require additional dependencies. Martin Fowler recommends that all developers commit to the same integration branch.

Commit frequently Developers can reduce the effort of resolving conflicting changes by synchronizing changes with each other frequently, at least daily. Checking in a week's worth of work risks conflict both in likelihood of occurrence and complexity to resolve. Relatively small conflicts are significantly easier to resolve than larger ones. Integrating (committing) changes at least once a day is considered good practice, and more often better.

Daily build Building daily, if not more often, is generally recommended.

Every commit should be built The system should build commits to the current working version to verify that they integrate correctly. A common practice is to use Automated Continuous Integration, although this may be done manually. Automated continuous integration employs a continuous integration server or daemon to monitor the revision control system for changes, then automatically run the build process.

Every bug-fix commit should come with a test case When fixing a bug, it is a good practice to push a test case that reproduces the bug. This prevents the fix from being reverted and the bug from reappearing, which is known as a regression.

Keep the build fast The build needs to complete rapidly so that if there is a problem with integration, it is quickly identified.

Test in a clone of the production environment

… excerpt ends here. Continue reading the full article.

Illustrations

Continuous integration: Sketch of flow diagram for continuous integration
Sketch of flow diagram for continuous integration

Worked examples

Example 1 — a first encounter with Continuous integration

Start with the simplest possible case. Write down what Continuous integration claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Continuous integration before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Continuous integration ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Continuous integration

In research
Continuous integration appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Continuous integration in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Continuous integration is common in secondary-school and first-year university syllabi. It links to neighbouring topics Agile software development, Continuous integration, Extreme programming, so understanding it makes those chapters shorter.
In everyday life
Look for Continuous integration outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Continuous integration” →

How to study Continuous integration in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Continuous integration means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Continuous integration out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Continuous integration in simple terms?

Continuous integration (CI) is the practice of integrating source code changes frequently and ensuring that the integrated codebase is in a workable state. Typically, developers merge changes to an integration branch, and an automated system builds and tests the software system.

Why does Continuous integration matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Continuous integration?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Continuous integration.

Tags

  • Agile software development
  • Continuous integration
  • Extreme programming
  • Software development process

Keep exploring