Today I discovered Travis CI. Something fun to do on a Saturday!
Their claim is:
Test and Deploy with Confidence
Easily sync your GitHub projects with Travis CI and you’ll be testing your code in minutes!
I found the idea of using a public CI for testing my github project to be really exciting. Even though I don’t work at ResMed anymore, I created test tools that relied on my github project. Because they use jruby, I wanted to make sure the library worked on multiple versions of ruby/jruby. This is a solution for that.
To begin with, I attached my github account to travis-ci and selected the project to test against. Their instructions were very easy so I won’t go into them.
The first task I had was cleaning up. I had allowed the project to get messy. I had temporarily taken out yard because jruby didn’t like installing the redcarpet gem (I couldn’t find an alternative for it). I had to clean up the checks that were using should instead of the more modern expect. And the gemspec was out of date.
group :development do gem 'bundler' gem 'rake' gem 'cucumber' gem 'fig_newton' gem 'rspec' gem 'webmock' gem 'rubocop' if ENV["JRUBY"] || RUBY_PLATFORM == "java" # Skip the yard gems for jruby else gem 'yard' gem 'yard-cucumber' gem 'redcarpet' end end
Second, I updated my rake file to be flexible enough to only create yardoc using ruby. I don’t need to create documentation in every version of ruby. It just needs to run.
if ENV["JRUBY"] || RUBY_PLATFORM == "java" # Skip the yard gems for jruby else require 'yard' # rake yard YARD::Rake::YardocTask.new do |t| t.files = ['lib/**/*.rb', 'features/**/*.feature', 'features/**/*.rb'] end end
Next, I created a .travis.yml file. I tried to keep it simple enough:
language: ruby rvm: - 2.0.0 - 2.1.0 - 2.2.0 - jruby-19mode # JRuby in 1.9 mode
Then I had to merge to trunk. That was tough but only because I let myself get messy.
The results were great. I knew that my cukes worked on four different versions of ruby/jruby, and even which was faster.
Conclusion
I would recommend to use this for small opensource projects like mine. The cool thing was to learn a little more about rake.
It could work for larger ones, but I didn’t qualify that.