You know, testing is important for software development. With good continuous integration and testing there, you have confidence that your software has a certain quality. It doesn’t mean your software is prefect then, however, when things broken, you can catch them and fix it. Jenkins is a pretty awesome and easy-to-use open source continuous integration tool, but for developing my own hobby open source projects, I just don’t want to rent a server and run Jenkins. So, I am always wondering, wouldn’t it be nice to have something like CI as service? I can just put my code there, and it could do the rest for me.
Meet the Travis-CI
Recently, I meet an awesome service which really fits what I want - Travis-CI. It has GitHub integration, so all you have to do is to grant some GitHub permissions to Travis-CI and write a configuration .travis.yml file like this:
python:
- "2.7"
env:
- PYRAMID_VERSION="pyramid>=1.2,<1.3"
- PYRAMID_VERSION="pyramid>=1.3,<1.4"
- PYRAMID_VERSION="pyramid>=1.4,<1.5"
# command to install dependencies
install:
- "pip install flake8 --use-mirrors"
- "pip install $PYRAMID_VERSION"
- "pip install -r requirements.txt --use-mirrors"
- "pip install -r test_requirements.txt --use-mirrors"
- "python setup.py develop"
before_script: "flake8 pyramid_genshi --ignore=E501,W291,W293"
# command to run tests
script: "python setup.py nosetests"
From https://github.com/fangpenlin/pyramid_genshi/blob/master/.travis.yml
Then it works like a charm, you can see the building results here https://travis-ci.org/fangpenlin/pyramid_genshi
The best part of it is, if you are testing open source project, it is totally free. I really love it!
Test Chef code on it, a dream in the dream
Currently, I am working on an open source Chef project for deployment. I think it would be neat to setup Travis-CI for testing my Chef code, so I tried to run Vagrant with VirtualBox on it. However, it turns out that Travis-CI testing environment is already running under a virtual machine, and it is based on OpenVZ, which is actually a container rather than hardware simulation. I cannot find a way to install VirtualBox with Travis-CI. Saddly, this is not Inception, I cannot have a dream in the dream.
Fine, I changed my mind then, it is already a virtual environment, why don’t I just run my Chef code against the Travis-CI environment?
The missing feature - interactive debugging
Okay, it appears that it is a better idea to run Chef code against Travis-CI instance instead of to have a dream in the dream. Nevertheless, it is still a pain in ass to make my Chef code works on Travis CI. You can’t never get the thing done at the very first time. And you always have to push a commit to kick it starting to build, so it results in a painful trial and error loop looks like this
In the process, you will see error output like this
- The PostgreSQL server failed to start. Please check the log output. …fail!
Okay… check the log out? but how? I can add a “cat /path/to/log_file” to the .travis.yml and push the commit to make it run again, but it would only be another painful waiting. I tried to reproduce the testing environment with Vagrant on my machine, but I can only find some outdated information there and some important Vagrant boxes are missing.
Like what Niko said in GTA IV
This no touching rule is killing me!
This no touching rule to Travis CI is also killing me. I think it would be nice to have a chance to interact with the CI environment after something went wrong. Fortunately, I contacted the support, they said they are working on it.
Green dots make you happy
Once I setup Travis-CI for one project, after I realize how easy it is, I just can’t wait to setup for most of my open source projects. When there are red dots, you really want to erase them all. However, when it is all in green, like this
That’s really pleasant to see a all green list in Travis-CI. If you are also an open source lover, just try it now, you will love it :)