The problem I was having when running SWTBot tests in Travis CI was that I could not use the new container-based infrastructure of Travis, which allows to cache things like the local maven repository. This was not possible since to run SWTBot tests you need a Window Manager (in Linux, you can use metacity), and so you had to install it during the Travis build; this requires sudo and using sudo prevents the use of the container-based infrastructure. Not using the cache means that each build would download all the maven artifacts from the start.
Now things have changed 🙂
When running in the container-based infrastructure, you’re still allowed to use Travis’ APT sources and packages extensions, as long as the package you need is in their whitelist. Metacity was not there, but I opened a request for that, and now metacity is available 🙂
Now you can use the container-based infrastructure and install metacity together (note that you won’t be able to cache installed apt packages, so each time the build runs, metacity will have to be reinstalled, but installing metacity is much faster than downloading all the Maven/Tycho artifacts).
The steps to run SWTBot tests in Travis can be summarized as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
sudo: false language: java jdk: oraclejdk7 cache: directories: - $HOME/.m2 env: DISPLAY=:99.0 install: true addons: apt: packages: - metacity #before_install: # - sudo apt-get update # - sudo apt-get install metacity before_script: - sh -e /etc/init.d/xvfb start - metacity --sm-disable --replace 2> metacity.err & |
I left the old steps “before_install” commented out, just as a comparison.
- “sudo: false” enables the container based infrastructure
- “cache:” ensures that the Maven repository is cached
- “env:” enables the use of graphical display
- “addons:apt:packages” uses the extensions that allow you to install whitelisted APT packages (metacity in our case).
- “before_script:” starts the virtual framebuffer and then metacity.
Then, you can specify the Maven command to run your build (here are some examples:
- https://github.com/LorenzoBettini/junit-swtbot-example/blob/master/.travis.yml
- https://github.com/LorenzoBettini/xsemantics/blob/master/.travis.yml
- https://github.com/LorenzoBettini/javamm/blob/master/.travis.yml
Happy SWTBot testing! 🙂