Using Multiple Operating Systems with Ruby and Shell in a Matrix

I’m attempting to create a CI test that executes a test using multiple Ruby versions using rvm on Linux, but I want to execute another test on Windows using the bash shell.

I’ve tried a few configurations, but they do not allow me to create or use multiple ruby versions if I have an additional OS and language in the matrix.

As an example, if I use the following configuration, I’ll get 3 different line items for Linux with different Ruby versions:

os:
  - linux

dist: xenial
language: ruby
cache: bundler

rvm:
  - 2.4.5
  - 2.5.4
  - 2.6.2

script:
  - ruby -v

If I add a matrix and include different OS’s and languages, I just get 2 line items in the matrix – one for Linux (ruby) and one for Windows (shell). The Windows OS works fine, but Linux only executes the first ruby version in the rvm list.

matrix:
  include:
    - os: linux
      dist: xenial
      language: ruby
      cache: bundler
      rvm: 
        - 2.4.5
        - 2.5.4
        - 2.6.2
      script:
        - ruby -v
    - os: windows
      language: shell
      script:
        - powershell -Command Write-Host Test

Ruby/Windows Travis CI

I’d like to have 3 build jobs with different ruby versions listed for Linux, but just one shell build job on Windows. Is it possible to use rvm within a matrix with multiple OS’s and languages?

matrix.include will not expand the rvm key. The expansion happens only at the top level.

What you want to do is use the expansion at the top level, and add the Windows job with matrix.include.

Imprint