Fork me on GitHub

Monday, February 13, 2012

Continuous integration with Travis

We recently started using Travis CI as continuous integration server for Cormoran. Travis is a distributed build system for the open source community used by projects like Ruby, Rails, Rubinius, Rubygems and a large number of open source projects.


Travis is integrated with GitHub and supports various programming languages like Ruby, Node.js or PHP. Although Travis doesn't support Python language it's possible to use it with Python projects. Here's how to do it ;)

First of all you need to sign in through GitHub and follow the getting started guide here. In the third step you need to create a .travis.yml configuration file to tell Travis how to build your project. This is an example of the structure that must have.

1
2
3
4
5
6
7
8
9
language: python
before_script:
    - virtualenv cormoran_env
    - source cormoran_env/bin/activate
    - pip install nose pyhamcrest pydoubles coverage

script:
    - python setup.py develop
    - nosetests tests/unit

There are only three sections: language, before_script and script. The first section tells Travis the programming language of the project. We use Python, although is not supported, to pass travis-lint check.

The next two sections are a set of shell commands to build the project. The before_script section is executed before main script and script is the main script to build your project. We basically create a virtual environment and install the dependencies and then build project and run tests. 

That's all! We already have our continuous integration system.

Travis CI Documentation

No comments:

Post a Comment