Free Travis CI for your Open Source project
So as I was poking around and looking at Travis CI and I noticed they give their service for free to open source projects. This is cool! Give your project more credibility by using it.
So what is Travis CI? Well it’s basically a tool to run your software tests within several environments and give you the status of if your code passes the tests. So when you write and changes to code that has tests for it you will know immediately if it breaks compatibility with any environment versions you test it with.
Well I went ahead and tried it out with my Youtube Toolbox project. I found a few different howtos for Ruby and began sticking in the configuration code. It didn’t work at first. Not all the instructions on various sites are detailed enough. Luckily Travis CI gives you messages as to what went wrong.
Here’s how to setup your own ruby project. I will use RSpec as the test framework.
In your projects root directory create a .travis.yml file
script: "bundle exec rake spec"
You can specify many different Ruby versions here. See the DOC for more details. For me the important line which I had to redo several times before I got it right was the script line. A rake command by itself won’t work here. You need the full bundle exec command with it. The script is referring to your Rakefile configuration which will need to have this in it.
task :default => [:spec]
desc 'run Rspec specs'
task :spec do
sh 'rspec spec'
You will also need to make sure every gem is specified in your Gemfile for Travis. Make sure you include rspec, rake, and bundler. BEFORE YOU GIT PUSH run your bundle command. If the Gemfile.lock is out of sync the Travis build will fail. I ran into this 3 times before I learned my lesson.
Then goto the Travis website, link your github account, and enable the project you want tested. And that’s it! You should have a working test suite for your open source project! Just keep an eye on the status of the test in Travis to see if any errors occur, then fix it. They’re pretty straight forward as long as your RSpec tests are understandable.
God Bless! – Daniel P. Clark