Two (or more) values for a matrix entry

I’d like to create a matrix but using two paired values along one axis.

That is, something like so:

strategy:
      matrix:
        os: [ubuntu-16.04, ubuntu-latest]
        c_and_cpp_compiler: [gcc/g++, gcc-8/g++-8, clang/clang++]

Note that c_and_cpp_compiler has three entries, but each entry is logically two variables: the c and cpp compilers. In my tasks I’d like to refer to c_compiler and cpp_compiler and get gcc and g++ (in the first matrix entry).

Any clean way to do this?

For a 2x3 matrix, you can add dummy entries for the number of compilers and use include to add additional values:

    strategy:
      matrix:
        os: [ubuntu-16.04, ubuntu-latest]
        compiler: [1, 2, 3]
        include:
          - os: ubuntu-16.04
            compiler: 1
            cc: gcc
            cxx: g++
          - os: ubuntu-latest
            compiler: 1
            cc: gcc
            cxx: g++
          - os: ubuntu-16.04
            compiler: 2
            cc: gcc-8
            cxx: g++-8
          - os: ubuntu-latest
            compiler: 2
            cc: gcc-8
            cxx: g++-8
          - os: ubuntu-16.04
            compiler: 3
            cc: clang
            cxx: clang++
          - os: ubuntu-latest
            compiler: 3
            cc: clang
            cxx: clang++

You can also explicitly list all matrix combinations by using include, which it actually a bit
less cumbersome, and you get full control over the combinations and don’t need to do any hacky things like splitting strings at /:

    strategy:
      matrix:
        include:
          - os: ubuntu-16.04
            cc: gcc
            cxx: g++
          - os: ubuntu-latest
            cc: gcc
            cxx: g++
          - os: ubuntu-16.04
            cc: gcc-8
            cxx: g++-8
          - os: ubuntu-latest
            cc: gcc-8
            cxx: g++-8
          - os: ubuntu-16.04
            cc: clang
            cxx: clang++
          - os: ubuntu-latest
            cc: clang
            cxx: clang++