Langbahn Team – Weltmeisterschaft

Continuous integration: Difference between revisions

Content deleted Content added
Altered pages. Add: date, s2cid, authors 1-1. Removed parameters. Formatted dashes. Some additions/deletions were parameter name changes. | Use this bot. | #UCB_Other
CI is not about committing often; it's about building and testing often; the rationale section was not a rationale; workflows were more practices; debounce?
Line 1: Line 1:
{{short description|Software development practice based on frequent submission of granular changes}}
{{short description|Software development practice of building and testing frequenting}}
{{more footnotes|date=July 2016}}
{{more footnotes|date=July 2016}}
{{Use dmy dates|date=April 2022}}
{{Use dmy dates|date=April 2022}}
Line 6: Line 6:
[[File:Continuous Integration.jpg|thumb|right|Sketch of [[flow diagram]] for continuous integration]]
[[File:Continuous Integration.jpg|thumb|right|Sketch of [[flow diagram]] for continuous integration]]


'''Continuous integration''' ('''CI''') is the practice of frequently building and testing a [[software system]] during its development. It is intended to ensure that [[source code|code]] written by [[programmers]] is always buildable, runnable and passes [[automated testing]]. Developers [[Merge (version control)|merge]] to an [[Branching (revision control)|integration branch]] and an automated system [[Software build|builds]] and [[software testing|tests]].<ref name="martinfowler" />
In [[software engineering]], '''continuous integration''' ('''CI''') is the practice of merging all developers' working copies to a shared [[Trunk (software)|mainline]] several times a day.<ref name="martinfowler" /> Nowadays it is typically implemented in such a way that it triggers an automated build with testing. [[Grady Booch]] first proposed the term CI in [[Booch method|his 1991 method]],<ref>{{Cite book |last=Booch |first=Grady |url=https://books.google.com/books?id=w5VQAAAAMAAJ&q=continuous+integration+inauthor:grady+inauthor:booch |title=Object Oriented Design: With Applications |publisher=[[Benjamin Cummings]] |year=1991 |isbn=9780805300918 |page=209 |author-link=Grady Booch |access-date=18 August 2014}}</ref> although he did not advocate integrating several times a day. [[Extreme programming]] (XP) adopted the concept of CI and did advocate integrating more than once per day – perhaps as many as tens of times per day.<ref>{{Cite journal |last=Beck |first=K. |date=1999 |title=Embracing change with extreme programming |journal=Computer |volume=32 |issue=10 |pages=70–77 |doi=10.1109/2.796139 |issn=0018-9162}}</ref>
Often, the automated process runs on each [[Commit (version control)|commit]] or runs on a schedule such as once a day.


[[Grady Booch]] first proposed the term CI in [[Booch method|1991]],<ref>{{Cite book |last=Booch |first=Grady |url=https://books.google.com/books?id=w5VQAAAAMAAJ&q=continuous+integration+inauthor:grady+inauthor:booch |title=Object Oriented Design: With Applications |publisher=[[Benjamin Cummings]] |year=1991 |isbn=9780805300918 |page=209 |author-link=Grady Booch |access-date=18 August 2014}}</ref> although he did not advocate integrating multiple times a day, but later, CI came to include that aspect.<ref>{{Cite journal |last=Beck |first=K. |date=1999 |title=Embracing change with extreme programming |journal=Computer |volume=32 |issue=10 |pages=70–77 |doi=10.1109/2.796139 |issn=0018-9162}}</ref>
== Rationale ==


== History ==
When embarking on a change, a [[software developer|developer]] takes a copy of the current [[code base]] on which to work. As other developers submit changed code to the [[source code repository]], this copy gradually ceases to reflect the repository code. Not only can the existing code base change, but new code can be added as well as new libraries, and other resources that create dependencies, and potential conflicts.
{{expand section|date=August 2014}}


The earliest known work on continuous integration was the Infuse environment developed by G. E. Kaiser, D. E. Perry, and W. M. Schell.<ref>{{Cite conference |last1=Kaiser |first1=G. E. |last2=Perry |first2=D. E. |last3=Schell |first3=W. M. |year=1989 |title=Infuse: fusing integration test management with change management |conference=Proceedings of the Thirteenth Annual International Computer Software & Applications Conference |location=Orlando, Florida |pages=552–558 |doi=10.1109/CMPSAC.1989.65147|citeseerx=10.1.1.101.3770 }}</ref>
The longer development continues on a branch without merging back to the mainline, the greater the risk of multiple integration conflicts<ref>{{Cite book |last=Duvall |first=Paul M. |title=Continuous Integration. Improving Software Quality and Reducing Risk |publisher=Addison-Wesley |year=2007 |isbn=978-0-321-33638-5}}</ref> 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.


In 1994, Grady Booch used the phrase continuous integration in ''Object-Oriented Analysis and Design with Applications'' (2nd edition)<ref>{{Cite book |last=Booch |first=Grady |url=http://www.cvauni.edu.vn/imgupload_dinhkem/file/pttkht/object-oriented-analysis-and-design-with-applications-2nd-edition.pdf |title=Object-Oriented Analysis and Design with applications |date=December 1998 |edition=2nd |access-date=2 December 2014 |archive-date=19 August 2019 |archive-url=https://web.archive.org/web/20190819035559/http://www.cvauni.edu.vn/imgupload_dinhkem/file/pttkht/object-oriented-analysis-and-design-with-applications-2nd-edition.pdf |url-status=dead }}</ref> 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".
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",<ref name="Cunningham, Integration Hell">{{Cite web |title=Integration Hell |url=http://c2.com/cgi/wiki?IntegrationHell |last=Cunningham |first=Ward |author-link=Ward Cunningham |date=5 August 2009 |website=WikiWikiWeb |access-date=19 September 2009}}</ref> where the time it takes to integrate exceeds the time it took to make their original changes.<ref>{{Cite web |title=What is Continuous Integration? |url=https://aws.amazon.com/devops/continuous-integration/ |website=Amazon Web Services}}</ref>


In 1997, [[Kent Beck]] and [[Ron Jeffries]] invented [[extreme programming]] (XP) while on the [[Chrysler Comprehensive Compensation System]] project, including continuous integration.<ref name="martinfowler">{{Cite web |title=Continuous Integration |url=http://martinfowler.com/articles/continuousIntegration.html |last=Fowler |first=Martin |date=1 May 2006 |access-date=9 January 2014}}</ref>{{self-published source|date=May 2020}} Beck published about continuous integration in 1998, emphasising the importance of face-to-face communication over technological support.<ref>{{Cite conference |last=Beck |first=Kent |date=28 March 1998 |title=Extreme Programming: A Humanistic Discipline of Software Development |url=https://books.google.com/books?id=YBC5xD08NREC&q=%22Extreme+Programming%3A+A+Humanistic+Discipline+of+Software+Development%22&pg=PA4 |location=Lisbon, Portugal |publisher=[[Springer Science+Business Media|Springer]] |volume=1 |pages=4 |isbn=9783540643036 |book-title=Fundamental Approaches to Software Engineering: First International Conference}}</ref> In 1999, Beck elaborated more in his first full book on Extreme Programming.<ref name="Beck, Extreme Programming Explained">{{Cite book |last=Beck |first=Kent |url=https://archive.org/details/extremeprogrammi00beck |title=Extreme Programming Explained |publisher=Addison-Wesley Professional |year=1999 |isbn=978-0-201-61641-5 |page=[https://archive.org/details/extremeprogrammi00beck/page/97 97] |ref=Beck, Extreme Programming Explained |author-link=Kent Beck |url-access=registration}}</ref> [[CruiseControl]], one of the first open-source CI tools,<ref>{{Cite news |date=1 February 2018 |title=A Brief History of DevOps, Part III: Automated Testing and Continuous Integration |work=CircleCI |url=https://circleci.com/blog/a-brief-history-of-devops-part-iii-automated-testing-and-continuous-integration/ |access-date=19 May 2018}}</ref>{{self-published source|date=May 2020}} was released in 2001.
== Workflows ==


In 2010, [[Timothy Fitz]] published an article detailing how [[IMVU]]'s engineering team had built and been using the first practical CI system. While his post was originally met with scepticism, it quickly caught on and found widespread adoption<ref>{{Citation | chapter=A Brief Survey of Current Software Engineering Practices in Continuous Integration and Automated Accessibility Testing | doi=10.1109/WiSPNET51692.2021.9419464| arxiv=2103.00097| s2cid=232076320| chapter-url=https://ieeexplore.ieee.org/document/9419464| title=2021 Sixth International Conference on Wireless Communications, Signal Processing and Networking (WiSPNET)| year=2021| last1=Sane| first1=Parth| pages=130–134| isbn=978-1-6654-4086-8}}</ref> as part of the [[Lean software development]] methodology, also based on IMVU.
=== Run tests locally ===


== Goal ==
CI should be used in combination with automated unit tests such as those written through the practices of [[test-driven development]]. All unit tests in the developer's local [[Deployment environment|environment]] should be run and passed before committing to the mainline. This helps prevent one developer's work-in-progress from breaking another developer's copy. Where necessary, incomplete features can be disabled before committing, using [[feature toggle]]s, for instance.


A stated goal of CI is to run the automated process frequently enough that no intervening window remains between [[Commit (version control)|commit]] and [[Software build|build]], and such that no errors can arise without developers noticing them and correcting them immediately.<ref name="martinfowler" /> Generally, this means triggering builds on each commit to a repository. Due to processing limitations, sometimes multiple changes are committed between automation runs.
=== Compile the mainline periodically; run tests of the mainline and/or use continuous quality control ===


== Practices ==
A build server compiles the code periodically. The build server may automatically run tests and/or implement other ''continuous'' [[quality control]] processes. Such processes aim to improve [[software quality]] and delivery time by periodically running additional static analyses, measuring performance, extracting documentation from the source code, and facilitating manual [[Quality assurance|QA]] processes.


A [[Server (computing)|server]] builds the integration branch frequently.
=== Use CI as part of continuous delivery or continuous deployment ===


Once built, all tests should run.<ref>{{Cite web |title=Continuous integration |url=https://www.atlassian.com/agile/continuous-integration |last=Radigan |first=Dan |website=Atlassian Agile Coach}}</ref>
CI is often intertwined with [[continuous delivery]] or [[continuous deployment]] in what is called a CI/CD pipeline. "Continuous delivery" ensures the software checked in on the mainline is always in a state that can be deployed to users, while "continuous deployment" fully automates the deployment process.


The server may also run other [[quality control]] and [[software quality]] processes such as static analysis, measuring performance, extracting documentation from the source code, and facilitating manual [[Quality assurance|QA]] processes.
== History ==
{{expand section|date=August 2014}}


== Related practices ==
The earliest known work on continuous integration was the Infuse environment developed by G. E. Kaiser, D. E. Perry, and W. M. Schell.<ref>{{Cite conference |last1=Kaiser |first1=G. E. |last2=Perry |first2=D. E. |last3=Schell |first3=W. M. |year=1989 |title=Infuse: fusing integration test management with change management |conference=Proceedings of the Thirteenth Annual International Computer Software & Applications Conference |location=Orlando, Florida |pages=552–558 |doi=10.1109/CMPSAC.1989.65147|citeseerx=10.1.1.101.3770 }}</ref>
{{howto|section|date=May 2015}}


This section lists [[best practice]]s from practitioners for other practices that enhance CI.
In 1994, Grady Booch used the phrase continuous integration in ''Object-Oriented Analysis and Design with Applications'' (2nd edition)<ref>{{Cite book |last=Booch |first=Grady |url=http://www.cvauni.edu.vn/imgupload_dinhkem/file/pttkht/object-oriented-analysis-and-design-with-applications-2nd-edition.pdf |title=Object-Oriented Analysis and Design with applications |date=December 1998 |edition=2nd |access-date=2 December 2014 |archive-date=19 August 2019 |archive-url=https://web.archive.org/web/20190819035559/http://www.cvauni.edu.vn/imgupload_dinhkem/file/pttkht/object-oriented-analysis-and-design-with-applications-2nd-edition.pdf |url-status=dead }}</ref> 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".


=== Build automation ===
In 1997, [[Kent Beck]] and [[Ron Jeffries]] invented [[extreme programming]] (XP) while on the [[Chrysler Comprehensive Compensation System]] project, including continuous integration.<ref name="martinfowler">{{Cite web |title=Continuous Integration |url=http://martinfowler.com/articles/continuousIntegration.html |last=Fowler |first=Martin |date=1 May 2006 |access-date=9 January 2014}}</ref>{{self-published source|date=May 2020}} Beck published about continuous integration in 1998, emphasising the importance of face-to-face communication over technological support.<ref>{{Cite conference |last=Beck |first=Kent |date=28 March 1998 |title=Extreme Programming: A Humanistic Discipline of Software Development |url=https://books.google.com/books?id=YBC5xD08NREC&q=%22Extreme+Programming%3A+A+Humanistic+Discipline+of+Software+Development%22&pg=PA4 |location=Lisbon, Portugal |publisher=[[Springer Science+Business Media|Springer]] |volume=1 |pages=4 |isbn=9783540643036 |book-title=Fundamental Approaches to Software Engineering: First International Conference}}</ref> In 1999, Beck elaborated more in his first full book on Extreme Programming.<ref name="Beck, Extreme Programming Explained">{{Cite book |last=Beck |first=Kent |url=https://archive.org/details/extremeprogrammi00beck |title=Extreme Programming Explained |publisher=Addison-Wesley Professional |year=1999 |isbn=978-0-201-61641-5 |page=[https://archive.org/details/extremeprogrammi00beck/page/97 97] |ref=Beck, Extreme Programming Explained |author-link=Kent Beck |url-access=registration}}</ref> [[CruiseControl]], one of the first open-source CI tools,<ref>{{Cite news |date=1 February 2018 |title=A Brief History of DevOps, Part III: Automated Testing and Continuous Integration |work=CircleCI |url=https://circleci.com/blog/a-brief-history-of-devops-part-iii-automated-testing-and-continuous-integration/ |access-date=19 May 2018}}</ref>{{self-published source|date=May 2020}} was released in 2001.


[[Build automation]] is a best practice.<ref name="Brauneis, [OSLC] Possible new Working Group - Automation">{{Cite mailing list |url=http://open-services.net/pipermail/community_open-services.net/2010-January/000214.html |title=[OSLC] Possible new Working Group – Automation |date=1 January 2010 |last=Brauneis |first=David |mailing-list=open-services.net Community |access-date=16 February 2010 |archive-url=https://web.archive.org/web/20180901173720/http://open-services.net/pipermail/community_open-services.net/2010-January/000214.html |archive-date=1 September 2018 |url-status=dead }}</ref><ref name="Taylor, Rails Deployment and Automation with ShadowPuppet and Capistrano">{{Cite web |title=Rails Deployment and Automation with ShadowPuppet and Capistrano |url=http://blog.railsmachine.com/articles/2009/02/10/rails-deployment-and-automation-with-shadowpuppet-and-capistrano/ |last=Taylor |first=Bradley |website=Rails machine |type=[[World Wide Web|blog]] |url-status=dead |archive-url=https://archive.today/20121202054105/http://blog.railsmachine.com/articles/2009/02/10/rails-deployment-and-automation-with-shadowpuppet-and-capistrano/ |archive-date=2 December 2012 |access-date=16 February 2010 |ref=Taylor, Rails Deployment and Automation with ShadowPuppet and Capistrano}}</ref>
In 2010, [[Timothy Fitz]] published an article detailing how [[IMVU]]'s engineering team had built and been using the first practical CI system. While his post was originally met with scepticism, it quickly caught on and found widespread adoption<ref>{{Citation | chapter=A Brief Survey of Current Software Engineering Practices in Continuous Integration and Automated Accessibility Testing | doi=10.1109/WiSPNET51692.2021.9419464| arxiv=2103.00097| s2cid=232076320| chapter-url=https://ieeexplore.ieee.org/document/9419464| title=2021 Sixth International Conference on Wireless Communications, Signal Processing and Networking (WiSPNET)| year=2021| last1=Sane| first1=Parth| pages=130–134| isbn=978-1-6654-4086-8}}</ref> as part of the [[Lean software development]] methodology, also based on IMVU.


== Common practices ==
=== Atomic commits ===
{{howto|section|date=May 2015}}
This section lists [[best practice]]s suggested by various authors on how to achieve continuous integration, and how to automate this practice. [[Build automation]] is a best practice itself.<ref name="Brauneis, [OSLC] Possible new Working Group - Automation">{{Cite mailing list |url=http://open-services.net/pipermail/community_open-services.net/2010-January/000214.html |title=[OSLC] Possible new Working Group – Automation |date=1 January 2010 |last=Brauneis |first=David |mailing-list=open-services.net Community |access-date=16 February 2010 |archive-url=https://web.archive.org/web/20180901173720/http://open-services.net/pipermail/community_open-services.net/2010-January/000214.html |archive-date=1 September 2018 |url-status=dead }}</ref><ref name="Taylor, Rails Deployment and Automation with ShadowPuppet and Capistrano">{{Cite web |title=Rails Deployment and Automation with ShadowPuppet and Capistrano |url=http://blog.railsmachine.com/articles/2009/02/10/rails-deployment-and-automation-with-shadowpuppet-and-capistrano/ |last=Taylor |first=Bradley |website=Rails machine |type=[[World Wide Web|blog]] |url-status=dead |archive-url=https://archive.today/20121202054105/http://blog.railsmachine.com/articles/2009/02/10/rails-deployment-and-automation-with-shadowpuppet-and-capistrano/ |archive-date=2 December 2012 |access-date=16 February 2010 |ref=Taylor, Rails Deployment and Automation with ShadowPuppet and Capistrano}}</ref>


CI requires the version control system to support [[atomic commit]]s; i.e., all of a developer's changes are handled as a single commit.
Continuous integration—the practice of frequently integrating one's new or changed code with the existing code repository —should occur frequently enough that no intervening window remains between [[Commit (version control)|commit]] and [[Software build|build]], and such that no errors can arise without developers noticing them and correcting them immediately.<ref name="martinfowler" /> Normal practice is to trigger these builds by every commit to a repository, rather than a periodically scheduled build. The practicalities of doing this in a multi-developer environment of rapid commits are such that it is usual to trigger a short time after each commit, then to start a build when either this timer expires or after a rather longer interval since the last build. Note that since each new commit resets the timer used for the short time trigger, this is the same technique used in many button debouncing algorithms.<ref>See for example {{Cite web |title=Debounce |url=https://www.arduino.cc/en/Tutorial/Debounce |date=29 July 2015 |website=Arduino}}</ref> In this way, the commit events are "debounced" to prevent unnecessary builds between a series of rapid-fire commits. Many automated tools offer this scheduling automatically.


=== Committing changes ===
Another factor is the need for a version control system that supports [[atomic commit]]s; i.e., all of a developer's changes may be seen as a single commit operation. There is no point in trying to build from only half of the changed files.


When making a code change, a [[software developer|developer]] creates a branch that is a copy of the current [[codebase]]. As other changes are committed to the [[source code repository|repository]], this copy diverges from the latest version.
To achieve these objectives, continuous integration relies on the following principles.


The longer development continues on a branch without merging to the integration branch, the greater the risk of multiple integration conflicts<ref>{{Cite book |last=Duvall |first=Paul M. |title=Continuous Integration. Improving Software Quality and Reducing Risk |publisher=Addison-Wesley |year=2007 |isbn=978-0-321-33638-5}}</ref> 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.
=== Maintain a code repository ===

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",<ref name="Cunningham, Integration Hell">{{Cite web |title=Integration Hell |url=http://c2.com/cgi/wiki?IntegrationHell |last=Cunningham |first=Ward |author-link=Ward Cunningham |date=5 August 2009 |website=WikiWikiWeb |access-date=19 September 2009}}</ref> where the time it takes to integrate exceeds the time it took to make their original changes.<ref>{{Cite web |title=What is Continuous Integration? |url=https://aws.amazon.com/devops/continuous-integration/ |website=Amazon Web Services}}</ref>

=== Testing locally ===

Proponents of CI suggest that developers should
use [[test-driven development]] and to
ensure that all [[unit testing|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 toggle]]s.

=== 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 ===
{{Main|Version control}}
{{Main|Version control}}


Proponents of CI recommend storing all files and information needed for building in [[version control]], (for [[git]] a ''repository''); that the system should be buildable from a fresh checkout and not require additional dependencies.
This practice advocates the use of a revision control system for the project's source code. All artifacts required to build the project should be placed in the repository. In this practice and the revision control community, the convention is that the system should be buildable from a fresh checkout and not require additional dependencies. [[Extreme Programming]] advocate [[Martin Fowler (software engineer)|Martin Fowler]] also mentions that where [[branching (software)|branching]] is supported by tools, its use should be minimised.<ref name="Fowler, Continuous Integration practices">{{Cite web |title=Practices |url=http://martinfowler.com/articles/continuousIntegration.html#PracticesOfContinuousIntegration |last=Fowler |first=Martin |author-link=Martin Fowler (software engineer) |website=Continuous Integration |type=article |access-date=29 November 2015}}</ref> Instead, it is preferred for changes to be integrated rather than for multiple versions of the software to be maintained simultaneously. The mainline (or [[trunk (software)|trunk]]) should be the place for the working version of the software.

[[Martin Fowler (software engineer)|Martin Fowler]] recommends that all developers commit to the same integration branch.<ref name="Fowler, Continuous Integration practices">{{Cite web |title=Practices |url=http://martinfowler.com/articles/continuousIntegration.html#PracticesOfContinuousIntegration |last=Fowler |first=Martin |author-link=Martin Fowler (software engineer) |website=Continuous Integration |type=article |access-date=29 November 2015}}</ref>


=== Automate the build ===
=== Automate the build ===
{{Main|Build automation}}
{{Main|Build automation}}


[[List of build automation software|Build automation tools]] automate building.
A single command should have the capability of building the system. Many build tools, which have existed for many years like [[make (software)|make]], and [[List of build automation software|other more recent tools]] are frequently used in continuous integration environments to automate building. (E.g. Makefile, which contains a set of rules for building software, can be used automate the [[make (software)|make]] build process.) Automation of the build should include automating the integration, which often includes [[software deployment|deployment]] into a production-like [[Deployment environment|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 (file format)|DEB]], Red Hat [[RPM Package Manager|RPM]] or Windows [[Microsoft Installer|MSI]] files).


Proponents of CI recommend that a single command should have the capability of building the system.
=== Make the build self-testing ===


Automation often includes automating the integration, which often includes [[software deployment|deployment]] into a production-like [[Deployment environment|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 (file format)|DEB]], Red Hat [[RPM Package Manager|RPM]] or Windows [[Microsoft Installer|MSI]] files).
Once the code is built, all tests should run to confirm that it behaves as the developers expect it to behave.<ref>{{Cite web |title=Continuous integration |url=https://www.atlassian.com/agile/continuous-integration |last=Radigan |first=Dan |website=Atlassian Agile Coach}}</ref>


=== Everyone commits to the baseline every day ===
=== Everyone commits to the baseline every day ===
Line 69: Line 89:
By committing regularly, every committer can reduce the number of conflicting changes. Checking in a week's worth of work runs the risk of conflicting with other features and can be very difficult to resolve. Early, small conflicts in an area of the system cause team members to communicate about the change they are making.<ref name=":0">{{Cite web |title=Continuous Integration |url=https://www.thoughtworks.com/continuous-integration |website=Thoughtworks}}</ref> Committing all changes at least once a day (once per feature built) is generally considered part of the definition of Continuous Integration. In addition, performing a [[nightly build]] is generally recommended.{{Citation needed|date =April 2012}} These are lower bounds; the typical frequency is expected to be much higher.
By committing regularly, every committer can reduce the number of conflicting changes. Checking in a week's worth of work runs the risk of conflicting with other features and can be very difficult to resolve. Early, small conflicts in an area of the system cause team members to communicate about the change they are making.<ref name=":0">{{Cite web |title=Continuous Integration |url=https://www.thoughtworks.com/continuous-integration |website=Thoughtworks}}</ref> Committing all changes at least once a day (once per feature built) is generally considered part of the definition of Continuous Integration. In addition, performing a [[nightly build]] is generally recommended.{{Citation needed|date =April 2012}} These are lower bounds; the typical frequency is expected to be much higher.


=== Every commit (to baseline) should be built ===
=== 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 (computer software)|daemon]] to monitor the [[revision control|revision control system]] for changes, then automatically run the build process.
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 (computer software)|daemon]] to monitor the [[revision control|revision control system]] for changes, then automatically run the build process.

Revision as of 23:02, 7 May 2024

Sketch of flow diagram for continuous integration

Continuous integration (CI) is the practice of frequently building and testing a software system during its development. It is intended to ensure that code written by programmers is always buildable, runnable and passes automated testing. Developers merge to an integration branch and an automated system builds and tests.[1] 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,[2] although he did not advocate integrating multiple times a day, but later, CI came to include that aspect.[3]

History

The earliest known work on continuous integration was the Infuse environment developed by G. E. Kaiser, D. E. Perry, and W. M. Schell.[4]

In 1994, Grady Booch used the phrase continuous integration in Object-Oriented Analysis and Design with Applications (2nd edition)[5] 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.[1][self-published source] Beck published about continuous integration in 1998, emphasising the importance of face-to-face communication over technological support.[6] In 1999, Beck elaborated more in his first full book on Extreme Programming.[7] CruiseControl, one of the first open-source CI tools,[8][self-published source] 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 CI system. While his post was originally met with scepticism, it quickly caught on and found widespread adoption[9] as part of the Lean software development methodology, also based on IMVU.

Goal

A stated goal of CI is to run the automated process frequently enough that no intervening window remains between commit and build, and such that no errors can arise without developers noticing them and correcting them immediately.[1] Generally, this means triggering builds on each commit to a repository. Due to processing limitations, sometimes multiple changes are committed between automation runs.

Practices

A server builds the integration branch frequently.

Once built, all tests should run.[10]

The server may also run other quality control and software quality processes such as static analysis, measuring performance, extracting documentation from the source code, and facilitating manual QA processes.

This section lists best practices from practitioners for other practices that enhance CI.

Build automation

Build automation is a best practice.[11][12]

Atomic commits

CI requires the version control system to support atomic commits; i.e., 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[13] 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",[14] where the time it takes to integrate exceeds the time it took to make their original changes.[15]

Testing locally

Proponents of CI suggest that developers should use test-driven development and to 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); 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.[16]

Automate the build

Build automation tools 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).

Everyone commits to the baseline every day

By committing regularly, every committer can reduce the number of conflicting changes. Checking in a week's worth of work runs the risk of conflicting with other features and can be very difficult to resolve. Early, small conflicts in an area of the system cause team members to communicate about the change they are making.[17] Committing all changes at least once a day (once per feature built) is generally considered part of the definition of Continuous Integration. In addition, performing a nightly build is generally recommended.[citation needed] These are lower bounds; the typical frequency is expected to be much higher.

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 avoids the fix to be reverted, and the bug to reappear, 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

Having a test environment can lead to failures in tested systems when they deploy in the production environment because the production environment may differ from the test environment in a significant way. However, building a replica of a production environment is cost-prohibitive. Instead, the test environment or a separate pre-production environment ("staging") should be built to be a scalable version of the production environment to alleviate costs while maintaining technology stack composition and nuances. Within these test environments, service virtualisation is commonly used to obtain on-demand access to dependencies (e.g., APIs, third-party applications, services, mainframes, etc.) that are beyond the team's control, still evolving, or too complex to configure in a virtual test lab.

Make it easy to get the latest deliverables

Making builds readily available to stakeholders and testers can reduce the amount of rework necessary when rebuilding a feature that doesn't meet requirements. Additionally, early testing reduces the chances that defects survive until deployment. Finding errors earlier can reduce the amount of work necessary to resolve them.

All programmers should start the day by updating the project from the repository. That way, they will all stay up to date.

Everyone can see the results of the latest build

It should be easy to find out whether the build breaks and, if so, who made the relevant change and what that change was.

Automate deployment

Most CI systems allow the running of scripts after a build finishes. In most situations, it is possible to write a script to deploy the application to a live test server that everyone can look at. A further advance in this way of thinking is continuous deployment, which calls for the software to be deployed directly into production, often with additional automation to prevent defects or regressions.[18][19]

Costs and benefits

Continuous integration is intended to produce benefits such as:

  • Integration bugs are detected early and are easy to track down due to small changesets. This saves both time and money over the lifespan of a project.
  • Avoids last-minute chaos at release dates, when everyone tries to check in their slightly incompatible versions
  • When unit tests fail or a bug emerges, if developers need to revert the codebase to a bug-free state without debugging, only a small number of changes are lost (because integration happens frequently)
  • Constant availability of a "current" build for testing, demo, or release purposes
  • Frequent code check-in pushes developers to create modular, less complex code[20]

With continuous automated testing, benefits can include:

Some downsides of continuous integration can include:

  • Constructing an automated test suite requires a considerable amount of work, including ongoing effort to cover new features and follow intentional code modifications.
  • There is some work involved to set up a build system, and it can become complex, making it difficult to modify flexibly.[21]
  • Continuous integration is not necessarily valuable if the scope of the project is small or contains untestable legacy code.
  • Value added depends on the quality of tests and how testable the code really is.[22]
  • Larger teams mean that new code is constantly added to the integration queue, so tracking deliveries (while preserving quality) is difficult and builds queueing up can slow down everyone.[22]
  • With multiple commits and merges a day, partial code for a feature could easily be pushed and therefore integration tests will fail until the feature is complete.[22]
  • Safety and mission-critical development assurance (e.g., DO-178C, ISO 26262) require rigorous documentation and in-process review that are difficult to achieve using continuous integration. This type of life cycle often requires additional steps to be completed prior to product release when regulatory approval of the product is required.

See also

References

  1. ^ a b c Fowler, Martin (1 May 2006). "Continuous Integration". Retrieved 9 January 2014.
  2. ^ Booch, Grady (1991). Object Oriented Design: With Applications. Benjamin Cummings. p. 209. ISBN 9780805300918. Retrieved 18 August 2014.
  3. ^ Beck, K. (1999). "Embracing change with extreme programming". Computer. 32 (10): 70–77. doi:10.1109/2.796139. ISSN 0018-9162.
  4. ^ Kaiser, G. E.; Perry, D. E.; Schell, W. M. (1989). Infuse: fusing integration test management with change management. Proceedings of the Thirteenth Annual International Computer Software & Applications Conference. Orlando, Florida. pp. 552–558. CiteSeerX 10.1.1.101.3770. doi:10.1109/CMPSAC.1989.65147.
  5. ^ Booch, Grady (December 1998). Object-Oriented Analysis and Design with applications (PDF) (2nd ed.). Archived from the original (PDF) on 19 August 2019. Retrieved 2 December 2014.
  6. ^ Beck, Kent (28 March 1998). "Extreme Programming: A Humanistic Discipline of Software Development". Fundamental Approaches to Software Engineering: First International Conference. Vol. 1. Lisbon, Portugal: Springer. p. 4. ISBN 9783540643036.
  7. ^ Beck, Kent (1999). Extreme Programming Explained. Addison-Wesley Professional. p. 97. ISBN 978-0-201-61641-5.
  8. ^ "A Brief History of DevOps, Part III: Automated Testing and Continuous Integration". CircleCI. 1 February 2018. Retrieved 19 May 2018.
  9. ^ Sane, Parth (2021), "A Brief Survey of Current Software Engineering Practices in Continuous Integration and Automated Accessibility Testing", 2021 Sixth International Conference on Wireless Communications, Signal Processing and Networking (WiSPNET), pp. 130–134, arXiv:2103.00097, doi:10.1109/WiSPNET51692.2021.9419464, ISBN 978-1-6654-4086-8, S2CID 232076320
  10. ^ Radigan, Dan. "Continuous integration". Atlassian Agile Coach.
  11. ^ Brauneis, David (1 January 2010). "[OSLC] Possible new Working Group – Automation". open-services.net Community (Mailing list). Archived from the original on 1 September 2018. Retrieved 16 February 2010.
  12. ^ Taylor, Bradley. "Rails Deployment and Automation with ShadowPuppet and Capistrano". Rails machine (blog). Archived from the original on 2 December 2012. Retrieved 16 February 2010.
  13. ^ Duvall, Paul M. (2007). Continuous Integration. Improving Software Quality and Reducing Risk. Addison-Wesley. ISBN 978-0-321-33638-5.
  14. ^ Cunningham, Ward (5 August 2009). "Integration Hell". WikiWikiWeb. Retrieved 19 September 2009.
  15. ^ "What is Continuous Integration?". Amazon Web Services.
  16. ^ Fowler, Martin. "Practices". Continuous Integration (article). Retrieved 29 November 2015.
  17. ^ "Continuous Integration". Thoughtworks.
  18. ^ Ries, Eric (30 March 2009). "Continuous deployment in 5 easy steps". Radar. O’Reilly. Retrieved 10 January 2013.
  19. ^ Fitz, Timothy (10 February 2009). "Continuous Deployment at IMVU: Doing the impossible fifty times a day". Wordpress. Retrieved 10 January 2013.
  20. ^ Junpeng, Jiang; Zhu, Can; Zhang, Xiaofang (July 2020). "An Empirical Study on the Impact of Code Contributor on Code Smell" (PDF). International Journal of Performability Engineering. 16 (7): 1067–1077. doi:10.23940/ijpe.20.07.p9.10671077. S2CID 222588815.
  21. ^ Laukkanen, Eero (2016). "Problems, causes and solutions when adopting continuous delivery—A systematic literature review". Information and Software Technology. 82: 55–79. doi:10.1016/j.infsof.2016.10.001.
  22. ^ a b c Debbiche, Adam. "Assessing challenges of continuous integration in the context of software requirements breakdown: a case study" (PDF).