Code, test, merge, repeat
11 October 2016
The Research Software Development Group (RSDG) have found another way to help researchers follow best practice when developing code: the Travis-CI continuous integration service.
What is continuous integration?
Software developers can tread a tortuous path as they go through successive versions of their code. As new functionality gets added, bugs are fixed, or the code gets entirely refactored, the aim is to make sure that despite these continual changes, consistent and correct results are produced. To do this requires regular testing: from small scale testing of individual functions, through to testing the integration of components at the whole program level.
It is best practice to start writing these tests from the outset, and to keep improving and expanding upon the suite of tests as the code evolves. To do this properly can take a lot of effort, but it has been proven time and time again that this effort pays off in saved time later on. It’s never too late to start adding tests to an existing codebase though. This can help to clarify how the code is intended to work before embarking on further development work, or when writing documentation.
Since the tests are themselves written as executable code, the task of running the whole suite of tests after each revision can be automated using a continuous integration (CI) server. A CI server is configured to routinely compile the code, run through the test suite, and report any failures back to the developers without the need for any human intervention. When integrated with a version control platform such as GitHub, this service can help developers to quickly judge whether new code can be safely added, or if more work is needed. And, by identifying which specific tests have failed, it makes the task of finding and fixing bugs much quicker (providing the test cases cover the bugs of course).
RSDG recommends Travis-CI
The Research Software Development Group recommends the use of Travis-CI, a cloud-based service that runs tests on Linux and OSX. A free version of Travis-CI can be used on public GitHub repositories by anyone, and there’s a paid for version for use with private repositories. RSDG are covering the cost of Travis-CI for all private repositories hosted within the UCL GitHub organisation so that UCL researchers can use the service even if they need to keep their code confidential. Researchers who wish to test private code stored with other organisations should get in touch via the email below to see if RSDG can help.
An alternative CI solution based on Jenkins and running on a part of Legion is also available for cases where a cloud-based solution may not be suitable (such as for highly parallel code-bases or those requiring paid-for dependencies). More information about automated testing for research and other tools supporting software development can be found on the research software development support website or RSDG can be contacted via firstname.lastname@example.org