LII:Medical Device Software Development with Continuous Integration/Continuous Integration: Part 2
Note: The following content originates from a separate source. However, it elaborates further on the original author's ideas in the previous section and adds additional information regarding benefits, drawbacks, and tools other than Jenkins, Trac, and Redmine. It has been added and slightly modified under the same license as the rest of the content.
Theory
When embarking on a change, a developer takes a copy of the current code base on which to work. As other developers submit changed code to the code repository, this copy gradually ceases to reflect the repository code. 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 called "integration hell",[1] where the time it takes to integrate exceeds the time it took to make their original changes. In a worst-case scenario, developers may have to discard their changes and completely redo the work.
Continuous integration involves integrating early and often, so as to avoid the pitfalls of "integration hell." The practice aims to reduce rework and thus reduce cost and time, particularly when automated as a best practice.[2][3]
Recommended practices
Continuous integration should occur 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.[4] 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's usual to trigger a short timer after each commit, then to start a build when either this timer expires, or after a rather longer interval since the last build. Automated tools such as CruiseControl or Jenkins offer this scheduling automatically.
Another factor is the need for a version control system that supports atomic commits, 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.
Maintain a code repository
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 in 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 also mentions that where branching is supported by tools, its use should be minimized.[4] Instead, integrating changes is preferred rather than creating multiple versions of the software that are maintained simultaneously. The mainline (or trunk) should be the place for the working version of the software.
Automate the build
A single command should have the capability of building the system. Many build-tools, such as make, have existed for years. Other more recent tools like Ant, Maven, MSBuild or IBM Rational Build Forge are frequently used in continuous integration environments. Automation of the build should include 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 Windows MSI files, RPM or DEB files).
Make the build self-testing
Once the code is built, all tests should run to confirm that it behaves as the developers expect it to behave.
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.
Many programmers recommend committing all changes at least once a day (once per feature built), and in addition performing a nightly build.
Every commit (to baseline) should be built
The system should build commits to the current working version in order to verify that they integrate correctly. A common practice is to use automated continuous integration, although this may be done manually. For many, continuous integration is synonymous with using automated continuous integration where a continuous integration server or daemon monitors the version control system for changes, then automatically runs the build process.
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 pre-production environment should be built to be a scalable version of the actual production environment to both alleviate costs while maintaining technology stack composition and nuances.
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 also, in some cases, reduces the amount of work necessary to resolve them.
Everyone can see the results of the latest build
It should be easy to find out where/whether the build breaks and who made the relevant change.
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 the concept of "continuous deployment," which calls for the software to be deployed directly into production, often with additional automation to prevent defects or regressions.[5][6]
Advantages and disadvantages
Advantages
Continuous integration has many advantages[4]:
- ability to revert the codebase back to a bug-free state, without wasting time debugging, when unit tests fail or a bug emerges;
- ability to detect and fix integration problems continuously, avoiding last-minute chaos at release dates (when everyone tries to check in their slightly incompatible versions);
- early warning of broken/incompatible code;
- early warning of conflicting changes;
- immediate unit testing of all changes;
- constant availability of a "current" build for testing, demo, or release purposes;
- immediate feedback to developers on the quality, functionality, or system-wide impact of code they are writing;
- modular, less complex code often a result of frequent code check-in by developers; and
- metrics generated from automated testing and CI (such as metrics for code coverage, code complexity, and features complete) focus developers on developing functional, quality code, and help develop momentum in a team.
Disadvantages
- initial setup time required;
- well-developed test-suite required to achieve automated testing advantages;
- large-scale refactoring can be troublesome due to continuously changing code base; and
- hardware costs for build machines can be significant.
Many teams using CI report that the advantages of CI well outweigh the disadvantages.[7] The effect of finding and fixing integration bugs early in the development process saves both time and money over the lifespan of a project.
Software
To support continuous integration, software tools such as automated build software can be employed.
Software tools for continuous integration include:
- AnthillPro — continuous integration server by Urbancode
- Apache Continuum — continuous integration server supporting Apache Maven and Apache Ant. Supports CVS, Subversion, Ant, Maven, and shell scripts
- Apache Gump — continuous integration tool by Apache
- Automated Build Studio — proprietary automated build, continuous integration and release management system by AutomatedQA
- Bamboo — proprietary continuous integration server by Atlassian Software Systems
- BuildBot — Python/Twisted-based continuous build system
- BuildForge - proprietary automated build engine by IBM / Rational
- BuildMaster — proprietary application lifecycle management and continuous integration tool by Inedo
- CABIE - Continuous Automated Build and Integration Environment — open source, written in Perl; works with CVS, Subversion, AccuRev, Bazaar and Perforce
- Cascade — proprietary continuous integration tool; provides a checkpointing facility to build and test changes before they are committed
- codeBeamer — proprietary collaboration software with built-in continuous integration features
- CruiseControl — Java-based framework for a continuous build process
- CruiseControl.NET — .NET-based automated continuous integration server
- CruiseControl.rb - Lightweight, Ruby-based continuous integration server that can build any codebase, not only Ruby, released under Apache Licence 2.0
- ElectricCommander — proprietary continuous integration and release management solution from Electric Cloud
- FinalBuilder Server — proprietary automated build and continuous integration server by VSoft Technologies
- Go — proprietary agile build and release management software by Thoughtworks
- Jenkins (formerly known as Hudson) — MIT-licensed, written in Java, runs in servlet container, supports CVS, Subversion, Mercurial, Git, StarTeam, Clearcase, Ant, NAnt, Maven, and shell scripts
- Software Configuration and Library Manager — software configuration management system for z/OS by IBM Rational Software
- QuickBuild - proprietary continuous integration server with free community edition featuring build life cycle management and pre-commit verification.
- TeamCity — proprietary continuous-integration server by JetBrains with free professional edition
- Team Foundation Server — proprietary continuous integration server and source code repository by Microsoft
- Tinderbox — Mozilla-based product written in Perl
- Rational Team Concert — proprietary software development collaboration platform with built-in build engine by IBM including Rational Build Forge
See comparison of continuous integration software for a more in depth feature matrix.
Further reading
- Duvall, P.M. (2007). Continuous Integration. Improving Software Quality and Reducing Risk. Addison-Wesley. ISBN 0321336380.
</ref>
References
- ↑ Cunningham, W. (20 December 2012). "Integration Hell". WikiWikiWeb. http://c2.com/cgi/wiki?IntegrationHell. Retrieved 27 April 2016.
- ↑ Brauneis, D.; Hüttermann, M. (16 January 2010). "[OSLC Possible new Working Group - Automation"]. open-services.net. http://open-services.net/pipermail/community_open-services.net/2010-January/000214.html. Retrieved 27 April 2016.
- ↑ Taylor, B. (10 February 2009). "Rails Deployment and Automation with ShadowPuppet and Capistrano". Rails Machine. Archived from the original on 03 March 2011. https://web.archive.org/web/20110303225845/http://blog.railsmachine.com/articles/2009/02/10/rails-deployment-and-automation-with-shadowpuppet-and-capistrano. Retrieved 27 April 2016.
- ↑ 4.0 4.1 4.2 Fowler, M. (1 May 2006). "Continuous Integration". MartinFowler.com. http://www.martinfowler.com/articles/continuousIntegration.html. Retrieved 27 April 2016.
- ↑ Ries, E. (30 March 2009). "Continuous deployment in 5 easy steps". O'Reilly Radar. O'Reilly Media, Inc. http://radar.oreilly.com/2009/03/continuous-deployment-5-eas.html. Retrieved 27 April 2016.
- ↑ Fitz, T. (10 February 2009). "Continuous Deployment at IMVU: Doing the impossible fifty times a day". timothyfitz.com. http://timothyfitz.com/2009/02/10/continuous-deployment-at-imvu-doing-the-impossible-fifty-times-a-day/. Retrieved 27 April 2016.
- ↑ Richardson, J. (14 September 2008). "Agile Software Testing Strategies at No Fluff Just Stuff Conference". Boston, Massachusetts. https://nofluffjuststuff.com/conference/boston/2008/09/session?id=11645. Retrieved 27 April 2016.
External links
- Comparison of continuous integration software
- Continuous integration by Martin Fowler (an introduction)
- Continuous Integration at the Portland Pattern Repository (a collegial discussion)
- Cross platform testing at the Portland Pattern Repository
- Continuous Integration Server Feature Matrix (archived version of guide to tools)
- Continuous Integration: The Cornerstone of a Great Shop by Jared Richardson (an introduction)
- A Recipe for Build Maintainability and Reusability by Jay Flowers
- Continuous Integration anti-patterns by Paul Duvall
- Extreme programming