Travis-CI Build Scripts

Read time: 5 minutes (1260 words)

In order to get Travis-CI to run your tests for you, you need to add a control file to your repository. The structure for this file is fairly simple, but it is not obvious what is going on at times. This guide is my attempt to provide some guidance for you to use in setting up your file.

YAML

First, the control file is written in something called YAM (Yet Another Markup Language). This language is structured, and provides a way to identify simple values for variables. Those variables can be anything (text) and can include lists of values if needed. We will see examples of this markup as we create a control file.

Control File Structure

Travis-CI will test your code using a “matrix” of configurations. At present, you can test your code on these operating systems:

  • Linux (Ubuntu)

  • Mac OS-X

Furthermore, you can test your code using two major C/C++ compilers:

  • GCC - Gnu Compiler Collection

Clang - A popular compiler developed by CERN

Travis-CI uses this file to determine how many virtual machines to spinn up for your tests, and what major tools will be needed in each one. If needed, you can add additional tools to fully configure the VM for your build.

Programming Language

The control file begins by specifying the programming languauge you need to use:

.travis.yml
language:       cpp

Here is the structure of a build matrix specification:

matrix:
    compiler:
      - clang
          - gcc