Continuous Integration with Travis CI

Travis CI is a cloud-based continuous integration service that supports many different programming languages and environments. If you have projects at GitHub, Travis CI might be interesting for you. I currently use it for a few of my open source projects at GitHub. Setup is quite easy, you can log in with your GitHub credentials and then you get a lit of all repos you have administration rights. Then you can configure, when Travis should run a build, e.g. on every push or pull request. The only thing you have to do is to provide a .travis.yml file at the root of your GitHub project that contains configuration info.

A few examples: my current pet project chatty has a Java back-end and a HTML/JavaScript based front-end (actually mostly written in TypeScript). For the JavaScript/TypeScript part I need node.js installed, as well as grunt, bower and tsd (TypeScript Definition Manager). The yml file looks like:

language: java
jdk:
  - oraclejdk8

before_script:
  - npm install -g grunt-cli
  - npm install -g bower
  - npm install -g tsd

script: ./gradlew test

This makes sure that the node modules grunt-cli, bower and tsd is installed before the build is run. Gradle is supported out of the box but the default is the check task. In my chatty project I have integration tests that I don’t want to run on Travis CI, that’s why I explicitly use ‘gradlew test’ as script. Make sure that the build scripts are executable. While this is a no-brainer on most operating systems, on Windows it is not so easy. But even on Windows you could use git to do the job, e.g.:

git update-index --chmod=+x gradlew

When the Travis CI build is set up, you can include a build indicator icon directory in the readme of your GitHub project. If you use markdown, the code snipped (for chatty) looks like

[![Build Status](https://travis-ci.org/toedter/chatty.svg?branch=master)](https://travis-ci.org/toedter/chatty)

Then a nice icon build status is displayed in your project description.

Eclipse based Builds
When you want to run Tycho based builds for Eclipse based projects, you only have to make sure to change to the directory of the parent pom. The yml file for my Eclipse 4 Application Platform Tutorial looks like:

language: java
jdk:
  - oraclejdk8

before_script:
  - cd org.eclipse.e4.tutorial.contacts.build.tycho

script: mvn clean install -DskipTests

I had some trouble running tests on Travis CI that involve SWT, that’s why I skip the tests.

Grails based Builds
Travis CI does not support Grails out of the box (like Gradle) but this is no problem at all since Grails provides its own Wrapper. So make sure that the wrapper is part of your project. One of our Siemens OSS projects, the REST API doc for Grails has the following yml file:

language: groovy
script: ./grailsw refresh-dependencies
     && ./grailsw test-app --echoOut

I am a big fan of Travis CI and recommend to give it a try!

This Post Has 2 Comments

  1. Aurélien Pupier

    Hi,

    thanks for your feedback.

    If I can suggest you to write a new article to explain your specific issues with SWT and Tycho builds, I’m interested on this topic 🙂

    Is it the same issue than the one described on this forum post http://www.eclipse.org/forums/index.php/t/633869/ ?

    regards,

    1. Kai Tödter

      Hi Aurélien,

      I guess it was a different issue, see https://travis-ci.org/toedter/e4-tutorial/builds/25725525 line 1202:
      shouldSetContactSelection(org.eclipse.e4.tutorial.contacts.views.details.DetailsViewTest): No more handles [gtk_init_check() failed]

      Unfortunately I currently have no time to investigate further…

Leave a Reply to Kai Tödter Cancel reply

I accept the Privacy Policy