Continuos Integration on Linux and Windows: Travis and AppVeyor

Continous Integration on Linux and Windows: Travis and AppVeyor

Recently I worked on improving the testing and the Continuos Integration (CI) configuration for a few open-source projects. In particular, I have spent some time on WorldEngine, a world generator written in Python, which uses a C++ extension named plate-tectonics.

There have been several issues, the main two are:

  • the deployment of the application on Windows is problematic
  • the application does not behave in the exact some way on Linux and Mac OS-X

To mitigate these issues I invested some time in writing better tests and improve my usage of Travis (CI for Linux) and start using AppVeyor (CI for Windows). While my solution is still not perfect I feel I am far better covered from regressions on the different platforms and I have a more reliable development process.

Travis

Travis is well-known in the open-source community because of three nice qualities:

  1. It is free for open-source projects
  2. It integrates seamlessly with GitHub
  3. It is very easy to use

Getting started with Travis is very easy: you simply register and connect your GitHub profile, You then select on which projects you want to activate Travis.

At this point you will see a list of your projects. The green or red color used for the project names make immediately evident which projects need to be fixed. You can also take a look at a specific build and see what caused it to fail.

Screen Shot 2015-03-02 at 11.09.46

Every time you push to Github, whether the master or in another branch, a build is started. If the branch you are building is used in a pull request, a badge indicating if the build failed or succeeded will appear in the GitHub interface.

Screen Shot 2015-03-03 at 10.17.11

Setting up Different C++ Compilers for Travis

While having your tests all passing on one platform is good, having them passing on different platforms is great. For example, it is a very good thing to verify if you C++ code compiles correctly both with gcc and clang. This is particularly important if support for C++’11 is needed and it can be affected by using the wrong version of the compiler. You can do that by creating a .travis.yml file containing these lines:

Now, what you want to do typically is to install specific versions of the compilers, to have a completely controlled environment, and not just using whatever happens to be installed on the machine Travis is offering you. Doing that is pretty simple, you just use apt-get to install whatever you need to install.

Given you are a smart guy, I am sure you can adapt this example to your specific case.

Setting Up Different Python Versions for Travis

Let’s build our application with a few different versions of Python:

In this case we do not manually install Python, but we rely on Travis having the correct versions already installed. To find out more about Python on travis read the Travis documentation about Python support.

A useful trick is to use a different requirements file depending on the python version (damn you Python 2!):

My Travis Files

These are a couple of complete Travis files I am using.

 plate-tectonics (C++)

WorldEngine (Python, using C++ extensions)

Civs (Clojure)

Javaparser (Java)

Ok, you got the picture. Travis is awesome and you can use it with a lot of different languages. This is easy to get started with (see the Civs script) but it is also flexible and powerful, if you need it to be.

AppVeyor

Recently I was very bugged by problems about building plate-tectonics and WorldEngine on Windows. Luckily Bret (who is maintaining WorldEngine with me) pointed me to AppVeyor which is basically Travis for Windows.

This is out we configured it for our project, so that it can build our library on 6 different versions of Python:

  • Python 2.7, 32 bit
  • Python 2.7, 64 bit
  • Python 3.3, 32 bit
  • Python 3.3, 64 bit
  • Python 3.4, 32 bit
  • Python 3.4, 64 bit

One feature of AppVeyor is really great: it store artifacts generating during the build.

Screen Shot 2015-03-03 at 10.07.42

We use AppVeyor to generate the Windows binary wheels for our library and then we upload them on Pypi. The project of uploading the files on Pypi is manual at the moment because we want to have some control on it (we do not want just to upload a new version everytime we do a push).

Badges

Badges are nice, and permit to check the status of your project.

It could sound childish but those small virtual stickers can motivate you to fix problems as they arise, because you want to be proud of your green status, on both Travis and AppVeyor.

Screen Shot 2015-03-03 at 10.28.23

Conclusions and Thoughts for Improvements

I think that CI integrations is fundamental to give solid basis to your projects. I sleep better since I have start using it.

However there is still a lot of room for improvements and a few ideas:

  • I am still missing a CI solution for Mac OS-X
  • I could use docker under Travis to verify the building process under different distros
  • I sometimes use Travis in a trial and error fashion: if I do not have access to a Windows machine I just cut a separate branch and push furiously to it, to trigger builds on AppVeyor and collecting feedback on the building process under Windows. This seems silly… but it works for me 🙂

Bonus

If you want to use Travis with Perl you can read Try Travis CI with your CPAN distributions.

Building Binary Wheels for Windows using Appveyor is an interesting reading for Python developers targeting Windows users.

Download the guide with 68 resources on Creating Programming Languages

68resources

Receive the guide to your inbox to read it on all your devices when you have time

Powered by ConvertKit
3 replies
  1. Ayoub
    Ayoub says:

    Thank you Federico,
    This blog allowed me to know about Appveyor, I was looking for a SaaS-based continuous integration system for windows and i fall on your blog.

    The problem i found within Appveyor is when trying to choose VS version. Appveyor use Visual Studio 2015 by default and i want to use 2013 version which doesn’t seem to work seamlessly or simply not working.

    Also, i had meet issue with Travis-CI when launching test for X11 based library.

    Finally, I think you for sharing your experience with CI systems.
    -Ayb

Trackbacks & Pingbacks

  1. […] for open-source, but it costs for businesses. This is a successful model that is also followed by Travis and AppVeyor, which have become synonymous with CI on Linux and Windows, and, among other things, Walkmod, […]

  2. […] part of this process I focused more on Continuos Integration and on techniques for testing. I think a big part of having a good process is to have an […]

Comments are closed.