Using Build Matrix for multiple Ubuntu distributions

I’m trying to test some scripts on multiple Ubuntu distributions such as Xenial, Bionic, Focal, etc. There are 5 tests to be run on each distribution, and currently using Xenial & Bionic, so 5*2=10 jobs. After adding another distribution, it would increase to 15 jobs.

Currently, each of the 10 jobs is being specified separately, so 10 entries, and I would need to add 5. That didn’t look very clean to me (even though would need to do that once) and making any change would require changing it in multiple jobs. Therefore I’m trying to use a Build Matrix to reduce all this. This is my current travis.yml

language: python
python: 3.7
os: linux

# Build Matrix for Travis
  - xenial
  - bionic
  - focal

# Scripts to be tested
  - CIINSTALL=yes SCRIPT=12   # BasicSetup + GenSoftware
  - CIINSTALL=yes SCRIPT=3    # ML-Basic
  - CIINSTALL=yes SCRIPT=4    # Build-OpenCV
  - CIINSTALL=yes SCRIPT=14   # BasicSetup + OpenCV (Conda OpenCV)
  - CIINSTALL=yes SCRIPT=5    # BuildML

  # BasicSetup + GenSoftware
  - if [[ $SCRIPT -eq 12 ]]; then
      export PATH=/opt/anaconda3/bin:$PATH;
      hash -r;

  # ML-Basic
  - if [[ $SCRIPT -eq 3 ]]; then

  # Build-OpenCV
  - if [[ $SCRIPT -eq 4 ]]; then
      ffmpeg -version;
      gdb --ex='set confirm on' -ex=run -ex=bt -ex=quit --args python3 extras/;

  # BasicSetup + OpenCV (Conda OpenCV)
  - if [[ $SCRIPT -eq 14 ]]; then
      export PATH=/opt/anaconda3/bin:$PATH;
      hash -r;
      ffmpeg -version;
      gdb --ex='set confirm on' -ex=run -ex=bt -ex=quit --args python extras/;

  # BuildML
  - if [[ $SCRIPT -eq 5 ]]; then

    - sudo add-apt-repository "deb $(lsb_release -sc) main universe restricted multiverse"
    - sudo apt-get update -qq
    - sudo apt-get install -y software-properties-common
    - sudo apt-get install -qq build-essential curl g++ python3-dev python3-setuptools gdb
    - echo 'America/Los_Angeles' | sudo tee /etc/timezone
    - sudo dpkg-reconfigure --frontend noninteractive tzdata

What I was hoping for - 3 dist * 5 env = 15 jobs
However, I’m getting only 5 jobs - For the xenial distribution only (
My commit - (Earlier use of 10 jobs an be seen in this)

Is there any way to use multiple distributions in a build matrix? I searched but didn’t find any such example.

I’m not very experienced in using Travis, and this is my first time posting here, so please let me know if any more details are required, etc.


I am also experiencing the same difficulty when trying to build with multiple distributions. If anyone has an answer to this question, it would be much appreciated. I posted the same question on SO before seeing this. One piece of insight that I can provide is that it doesn’t seem possible to specify dist as a list. See the reference for dist, here, and compare it to, say, the reference for os, here.

If any Travis CI staff happen to read this comment, may I ask why this is the case? And would it be possible to update Travis to use the build matrix for multiple distributions?

dist: is not an axis. So you need to create jobs with different dist: manually:

   - dist: xenial
   - dist: bionic
   - dist: focal

See for an example.

@native-api Thanks for the info! I tried it out, however it’s creating 7 jobs, 5 for xenial (which is not present in config right now) and 1 each for bionic & focal. The matrix is being expanded on xenial only.
Travis build -
Am I doing something wrong here?


Since it’s not an axis, matrix expansion only uses the value specified at global level (you have nothing specified and xenial is currently the default). You’ll need to specify all jobs for bionic and focal by hand under jobs: include:.

You can create a feature request to change that, or perhaps create a pull request against (I believe they use it for matrix expansion logic now, at least with build config validation enabled).

@native-api Yup, currently doing that only -
I’ve opened an issue -
Haven’t contributed to Travis before, or actually even coded in Ruby, so let’s see. But would love to contribute, should be fun!

1 Like

2 posts were split to a new topic: Specify multiple compilers