Things to consider when using Travis CI

Posted . Visible to the public.

Travis CI is a free continuous integration testing service. However, it is really fragile and will break more than it will work.

If you choose to use it anyway, learn the lessons we already learnt:

Use a compatible Rubygems for Rails 2.3 on Ruby 1.8.7

Ruby 1.8.7 is not compatible with current Rubygems versions (> 2.0). Runnig rvm rubygems latest-1.8 --force will fix this and install Rubygems version 1.8.29.

To make Travis CI do this, add before_script: rvm rubygems latest-1.8 --force to .travis.yml. However, if you run tests for multiple Ruby versions, you need to add before_script: travis:prepare to .travis.yml. In Rakefile add this block:

namespace :travis do

  desc 'Things to do before Travis CI begins'
  task :prepare => [:compatible_rubygems]

  desc 'Ensure compatible Rubygems version for Ruby 1.8'
  task :compatible_rubygems do
    if RUBY_VERSION == '1.8.7'
      system "rvm rubygems latest-1.8 --force"
    end
  end
  
end

Don't let Travis CI install a debugger

… cause it will fail. To have Travis CI skip installing a debugger gem but still have it in development, add this line to .travis.yml:

bundler_args: --without development

Then move any debugger gem (debugger, ruby-debug) into the :development group. Example:

gem 'debugger', :platform => :ruby_19, :group => :development

Add a travis-testing branch

To keep your master branch clean of "Trying to fix Travis CI (again)" commits, have a branch travis-testing that you can sqash and rebase once Travis CI is happy. To make Travis CI run tests on that branch, add these lines to .travis.yml:

branches:
  only:
    - master
    - travis-testing
Dominik Schöler
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2014-06-10 12:14)