Continuous Integration on Travis CI
Continuous integration is the most technically involved software engineering feature that I have added to my open source pi-qmc code. In software development, “integration” refers to the process of bringing together all the pieces into a usable application. Continuous integration is the practice of always keeping the software in a usable state. In particular, continuous integration implies an automated process to build and test the software at regular intervals, preferably each time someone checks in new source code.
The problems that continuous integration addresses are very clear. There have been many times that I have given another scientist a tarball with our current code, only to find out it was broken. A common situation is that a collaborator asks for source code, then emails back a few days later asking if there is a problem. Usually scientists think they can solve problems themselves, and they will hesitate to ask a simple question that I could have easily helped out with. A second problem is when source code compiles fine, but an old feature has been broken by new development, but no one knew that because the student who used the feature has moved on to new things.
Continuous integration has many benefits: (1) we always know that the current source code will compile without manual intervention, (2) unit tests can be automatically run at each commit, in case some of our developers aren’t checking them carefully, (3) important but often unused features can be added to automated test suites so we know right away if they are broken, and (4) the configuration files for building and testing the code serve as concise documentation for how to build and install the software.
I found Travis CI to be a great resource for continuous integration of open-source software. I configured the site to be automatically triggered whenever anyone commits new source code to pi-qmc on GitHub. At that point, Travis CI creates a clean virtual linux machine, installs the required software dependencies, grabs the latest pi-qmc source code from GitHub, compiles and links the software, runs unit tests, and runs some system integration tests. If any stage in that process has an error, I am emailed immediately so that I can fix the problem.
The configuration for Travis CI is stored in a YAML document in the root directory of the source code, .travis.yml. This file contains all the information to download and test the pi-qmc code! Having an automated process ensures that anyone can download and install our software; there are no unintended in-house hacks or other special rules to build the pi-qmc code.