Continuous Integration
Monday, December 14, 2009 7:491. Summary
An important part of any software development process is getting reliable builds of the software. Despite its importance, we are often surprised when this isn’t done. (Fowler, 2006)
Continuous Integration (CI) is the strategy and practice of making sure that changes to a software project’s code base are successfully built, tested, reported on, and rapidly made available to all parties after they are introduced.
2. Business Challenge
The current build process is immature. It is limited to only the code base; requires many manual steps; lacks structured testing; lacks status broadcasting; and introduces more complexities for projects with more than one developer. Ideally, the build process would include not only the code base but anything necessary to deploy to a clean machine; include both unit testing and integration testing; provide status updates to members of the project team; be the same process for all developers regardless of team size; and perform the majority of operations automatically.
3. Solution Description
Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily – leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly. (Fowler, 2006)
The key practices that make up an effective Continuous Integration (CI) are the following:
- Source Repository (SVN): There should be a mainline, a single branch of the project as it is being developed; alternate branches should be kept to a minimum (production bug fixes or temporary experimentation); Everything needed to build the project on a clean machine should be included (i.e. test scripts, install scripts, third party libraries, etc.) and any other useful files (i.e. IDE configurations) can optionally be included.
- Build Automation (NAnt): Everything necessary to bring in a clean machine, check the source out of the repository, issue a single command, and have a running system on the machine.
- Test Automation (NUnit / VS2008 Test Projects): Run all unit tests; Run all functional / integration tests. The tests should be automated so that a single command executes them, and each must report the results of the test.
- Mainline Committal: CI is primarily about communication, allowing developers to tell other developers about the changes they have made. Frequent communication allows people to know quickly as changes develop. So, at a minimum, developers should commit to the mainline once every day. The more frequent the integration the sooner a conflict can be detected. The key to fixing problems quickly is finding them quickly and at a point that not much has happened, therefore they are easy to resolve.
- Continuous Integration Server (CruiseControl.Net): A CI server monitors the repository. Each committal initiates the CI server to automatically check out the source, build, test, and notify the committer of the results. The committer isn’t done until notification is received.
- Build Time: The whole point of CI is to provide rapid feedback. A ten minute build is perfectly within reason. For builds that take more than 10 minutes investigate implementing a staged build (a.k.a. a build pipeline).
- Production Environment: The point of testing is to flush out, under controlled conditions, any problem that the system will have in production. A significant part of this is the environment within which the production system will run. If you test in a different environment, every difference results in a risk that what happens under test won’t happen in production. As a result, you want to set up your test environment to be as exact a mimic of your production environment as possible.
- The Latest and Greatest: The resulting code should be available for anyone involved for demonstrations, exploratory testing, or just to see what changed. It’s very hard to specify what you want in advance and be correct; it’s much easier to see something that’s not quite right and say how it needs to be changed.
- Information Dissemination: CI is all about communication, so you want to ensure that everyone can easily see the state of the system, how long it’s been in that state and the changes that have been made to it.
- Deployment Automation: Although this is merely just the aforementioned steps executing on the desired application server, this is a crucial process, as it eliminates potential human error and, almost as important, provides the ability to perform automated rollbacks.
4. Benefits
- Reduced Risk: By integrating many times a day, you can reduce risks on your project. Doing so facilitates the detection of defects, the measurement of software health, and a reduction of assumptions.
- Increased Productivity: Often, it takes more time to locate a bug then it does to correct it and the more bugs there are, the more difficult it is to remove each one, due to bug interactions. With CI, the vast majority of integration bugs are known as the build is created; more importantly, the offending code (at least ½ of it) is identified. This dramatically reduces the scope of the search for the bug. Furthermore, as bugs are identified and corrected on a continuous basis, there are fewer bugs in the development process which may impede developers working on other sections of code.
- Increased Portability: CI can enable you to release deployable software at any point in time.
- Improved Product Timeline: With developers spending more time on coding and less time on investigation, manual testing and building releases combined with the knowledge of which sections of code contain bugs and how many bugs in each, adhering to the project timeline is more easily attainable. Additionally, if adjustments are necessary to the timeline, more information is available to assist with the forecasting.
- Increase in Customer Confidence / IT Reputation: With most integration bugs identified, it becomes a decision rather than a mistake to release code with known bugs, resulting in fewer bugs being deployed to production and a more stable product.
5. Technical Specifications
A server environment separate from that of the one housing the application is necessary for the various automation tasks.
6. Target Market
Anyone involved with any application implementing CI, including, but not limited to, developers, business analysts, project managers and customers.
7. Case Studies
8. Additional Resources
- (Fowler, 2006): Fowler, M. (2006, 05 01). Continuous Integration. Retrieved 12 14, 2009, from http://martinfowler.com/articles/continuousIntegration.html
- SVN: http://subversion.tigris.org/
- NAnt: http://nant.sourceforge.net/
- NUnit: http://www.nunit.org/index.php
- VS2008 Test Projects: http://msdn.microsoft.com/en-us/library/bb385902.aspx
- CruiseControl.Net: http://confluence.public.thoughtworks.org/display/CCNET