Matrix of matrix

I have a build process that builds a bunch of interrelated gems… a piece of the build file looks like this:

    - <<: *_test_gem
      env: COMPONENT=hyper-i18n        RUBY_VERSION=2.5.1
    - <<: *_test_gem
      env: COMPONENT=hyper-trace       RUBY_VERSION=2.5.1
    - <<: *_test_gem
      env: COMPONENT=hyper-state       RUBY_VERSION=2.5.1
    - <<: *_test_gem
      env: COMPONENT=hyper-component   RUBY_VERSION=2.5.1
   plus many more lines like this...

Now we are trying to test all these components against three different configurations like this

  - OPAL_VERSION='~>0.11'
  - RAILS_VERSION='~>5.0'

In otherwords I want to do each of the test runs listed above 3 times using each of the different environment variables.

Of course I can just copy the first set of commands three times and and add the different environment vars, but that seems pretty aweful…

Thanks in advance.