🤖🚫 AI-free content. This post is 100% written by a human, as is everything on my blog. Enjoy!

How to test your gem against multiple Ruby versions on CircleCI

August 15, 2016 in Ruby on Rails

So I’ve recently released a new gem for MessagePack-RPC, and I had to test it against all kinds of Ruby versions of course. On Travis CI it’s trivial, and kudos to Travis for that.

But our client is using Circle CI, and it makes no sense to involve Travis just to test one single gem. Unfortunately, Circle CI doesn’t support a build matrix.

After trying out a couple third-party scripts for build matrices, I recalled that RVM can run commands against multiple rubies out of the box, with the rvm do command. You’ll have to override most of the build steps, but still it works really well.

Here’s the entire circle.yml file I use:

machine:
  environment:
    RUBY_VERSIONS: 1.9.3,2.0.0,2.1.10,2.2.5,2.3.1,jruby-1.7.25,jruby-9.1.2.0

dependencies:
  override:
    - rvm get head
    - rvm install $RUBY_VERSIONS
    - rvm $RUBY_VERSIONS --verbose do gem install bundler
    - rvm $RUBY_VERSIONS --verbose do bundle install

test:
  override:
    - rvm $RUBY_VERSIONS --verbose do bundle exec rspec spec

(Best thing about Circle CI though? Effortless parallel testing. And Clojure.)

Buy me a coffee Liked the post? Treat me to a coffee