CONTINUOUS INTEGRATION Introduction Continuous Integration is the topic of quite a bit of buzz in Silicon Valley and beyond. And with good reason: continuous integration helps teams ship better software at lower cost. This book will show you how to get started with Continuous Integration on your projects with actionable recommendations and practical suggestions.
What is Continuous Integration? Continuous Integration (or "CI") is a development process where project contributors (developers, designers, documentation writers, etc.) frequently commit their code to a master repository, which in turn builds and tests the current code after each commit. CI thus can gives an ongoing up-to-date measure of the health of a project's codebase. Continuous Integration helps teams find bugs and other system problems sooner. This is proven to save money and reduce scheduling risk.
Benefits of Continuous Integration 1 2 3 4 Developers and project managers get an early warning on possible bugs, incompatibilities, or new performance problems. By identifying these issues soon after they are introduced, fixing them takes less time and costs less than doing so at the end of the project. Since the current version of the codebase is built on every commit, team members, QA, and sales staff always have a current build for testing, demo, or release purposes. Since problems are identified and fixed continuously, there's no need for a last-minute scramble to fix bugs. This means reduced schedule risk (and no all-nighters) Higher initial quality also means lower ongoing maintenance costs.. Integration to continuous deployment systems ensure rapid turnaround from code update to live in production. Customer issues get resolved faster, which means increased customer satisfaction.
Considerations Before you begin Prerequisites Infrastructure Platforms Tests
Prerequisites Adding continuous integration to your process involves getting a few prerequisites in place. It's likely that you already have some or most of these in place on your project. The good news is that all of the prerequisites provide other benefits to your project, so you can add each one without making a huge push to get CI in place or worrying that it's wasted effort. Here's what you'll want for your CI setup: Source code repository (like Subversion, Git, or TFS) Automated build (e.g. Ant, Maven, Visual Studio, make, etc.) Automated test suite One-touch deployment to staging server
Infrastructure Once you've got the perquisites in place, you can move forward with adding continuous integration to your process. While you'll get some benefits of continuous integration with only a dedicated build server, adding more realism to your automated testing environment will help you expose a larger percentage of latent bugs before your customers do. In particular, you'll want to run your tests with representative sample data to mimic what your customers will experience. In rough order of importance, here's what you'll need: Continuous Integration software -- SaaS or on-premises Build & test servers for each of your platforms Clone of the production environment to run tests Test databases, including test data Automated notifications of build & test results
Platforms If your team builds applications that will be used on multiple platforms, the benefits of continuous integration compound in your favor. That's because a robust CI process makes it easy to build & test each build, on every relevant platform. Once you've gone through the initial effort of setting up a CI process, adding a new server is comparatively easy. Then, building on testing on all of your platforms is transparent to your contributors. You can even provide a test matrix to automatically test combinations of platform components. Depending on your customers' use cases, you may want to consider the following for inclusion in your build/test matrix: Operating system & version Database & version Language runtime & version Browser type and version Mobile: Screen sizes & other device capabilities Internationalization settings
Tests The key benefits of continuous integration derive from its ability to automatically run your test suite every time someone makes a change to the codebase. Your team can write tests with the confidence to know that they will be used every day, to ensure that working code stays working. Over time, as your team identifies new bugs, the test suite will grow to check those conditions. Over time, you may even find that a successful run of the test suite means the code is ready to be released. The corollary is that if your test suite isn't thorough, continuous integration will give you less actionable information. However, even if your test suite is limited, a CI system will notify you of build breakages and possible system incompatibilities.
Will Continuous Integration work with XP/Agile/Scrum/my favorite methodology? Yes.
Tools & Resources The next few pages provide some resources and tools that will help you add continuous integration to your development process. While it's possible to build a continuous integration system from scratch, in practice this will involve writing and maintaining a fair bit of code. This is not likely to lead to efficiency gains, as the staff time involved in building & maintaining the CI system could outweigh the benefits to the team. Similarly, setting up and maintaining an in-house CI server takes staff time away from core development activities on an ongoing basis. If possible, you may want to use one of the available cloud-based CI systems that offer predictable pricing and require close to zero of your staff's time to setup and administer.
Continuous Integration Software Continuous integration software is the conductor that drives the logic involved in building & testing your code after every commit. Here are some popular tools, both cloud-based and on-premises. Suggested Continuous Integration Systems Apache Continuum Hudson Jenkins BuildLocker by ProjectLocker TeamCity Team Foundation Server
Source Code Repository Your continuous integration software will need to get your latest code from a source control system. If you're not using a source control system for your code now, you should start immediately, whether or not you plan to add continuous integration. The investment you make in a source control system will pay consistent dividends over the life of your project. Suggested source control systems Git Subversion Team Foundation Server
Automated Build Software Once your CI system retrieves the latest version of your project's code, it will attempt to build the code using your automated build application. Suggested automated build systems Ant Maven make Rake Visual Studio
Automated Test Software Once the build is complete, your automated test suite will be run, with the results collated for your perusal. Testing is a fairly specialized discipline, and there are automated testing tools for many niches. However, there are some good general-purpose open source tools that may be a fit for your projects. Suggested automated test systems Appium Capybara JUnit NUnit Selenium
Bonus: Virtualization Like all tests, automated tests provide the best quality of information when they are run in a pristine environment. That way, you know exactly what's being tested (and you know that nobody "fixed" the machine to make the tests work there. Standardizing the test environment helps prevent the "it works on my machine" syndrome by ensuring that tests are 100% reproducible. Virtualization is an excellent way to achieve a reproducible test environment. Suggested testing virtualization systems Amazon EC2 templates Docker Hyper-V Vagrant VirtualBox VMWare
Shameless Plug is the easiest way to get continuous integration for your projects. Source Control with Subversion or Git BuildLocker Continuous Integration Free migration & CI setup Saves staff time & expense vs. in-house solutions Reach out to us at sales@projectlocker.com for details.