Read more

Things to consider when using Travis CI

Dominik Schöler
June 10, 2014Software engineer at makandra GmbH

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

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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
Posted by Dominik Schöler to makandra dev (2014-06-10 14:14)