Liam Middlebrook - Game Developer

site-home

Setting up TravisCI | FIRST Robotics C++

09 Mar 2015

This is a step by step guide on how to setup TravisCI for FIRST Robotics C++ repositories. It will cover getting build status from TravisCI, but it will not go into unit testing. If you want to explore setting up Unit Tests for your repository I would recommend looking into CUnit.

Since TravisCI uses Ubuntu as an OS we'll need to create a Makefile for actually building the robot code. I based my Makefile off of the file that is generated by brpylko/FRCMakeProject

Here's the example of the Makefile that you could use.

#Copyright (c) 2015 Benjamin Pylko

#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

AT = @
INCDIR = -I$(HOME)/wpilib/cpp/current/include -Isrc/
CPPFLAGS += -g -Wall -W $(INCDIR) -std=c++14 -fPIC
LFLAGS = -L$(HOME)/wpilib/cpp/current/lib -lwpi
CXX = arm-frc-linux-gnueabi-g++
TEAM = 3181
RMCOMMAND = rm -f
DEPLOYTARGET = roboRIO-$(TEAM).local

SOURCES = $(wildcard src/*.cpp)
HEADERS = $(wildcard src/*.h)
OBJECTS = $(patsubst src/%.cpp,src/%.o,$(wildcard src/*.cpp))

all: $(OBJECTS)
    test -d bin/ || mkdir -p bin/
    $(CXX) $(CPPFLAGS) $(OBJECTS) $(LFLAGS) -o bin/FRCUserProgram

This file will tell TravisCI what it needs to do in order to properly test and build your code. We're going to set the language to be CPP and tell TravisCI to get the following dependencies.

Then all you need to do is tell TravisCI to run the Makefile to build the code! I've attached a sample .travis.yml below!

language: cpp
before_install:
    - git clone git://github.com/brpylko/wpilib.git ~/wpilib
    - sudo add-apt-repository -y ppa:byteit101/frc-toolchain
    - sudo apt-get update
install:
    - sudo apt-get install frc-toolchain
script:
    - make

Sign into TravisCI and you'll see a list of all the repositories that you have administrator access to. All you need to do is flip the switch and next time you push or receive a pull request you'll have TravisCI checking your build status.