Why am I getting extra jobs with my Travis matrix?

I don’t understand the behavior of my .yml file, my .travis.yml:

language: go
go:
  - "1.10.x"
  - "1.11.x"
env:
  matrix:
    - MONGO_SETTINGS=--auth
    - MONGO_SETTINGS=
matrix:
  include:
    - env: MONGO_SETTINGS=--auth
      before_script:
        - mongorestore -h 127.0.0.1 --port 27017 -d data integration
        - mongo data --eval 'db.createUser({user:"travis", pwd:"test", roles:["readWrite"]});'
        - mongod --dbpath=data/db --shutdown
        - sleep 10
        - mongod --dbpath=data/db $MONGO_SETTINGS  &
        - sleep 3
        - mongo data --username travis --password test --eval "db.getCollection('data').find({})"
      script:
        - go test ./... -tags=authentication
    - env: MONGO_SETTINGS=
      before_script:
        - mongorestore -h 127.0.0.1 --port 27017 -d data integration
        - mongo data --eval "db.getCollection('data').find({})"
      script:
        - go test ./...
install:
  - wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.18.tgz
  - tar xfz mongodb-linux-x86_64-3.4.18.tgz
  - export PATH=`pwd`/mongodb-linux-x86_64-3.4.18/bin:$PATH
  - mkdir -p data/db
  - mongod --dbpath=data/db &
  - sleep 3

The matrix returns 6 jobs

  • 1.1 Go: 1.10.x MONGO_SETTINGS=–auth
  • 1.2 Go: 1.10.x MONGO_SETTINGS=
  • 1.3 Go: 1.11.x MONGO_SETTINGS=–auth
  • 1.4 Go: 1.11.x MONGO_SETTINGS=
  • 1.5 Go: 1.10.x MONGO_SETTINGS=–auth
  • 1.6 Go: 1.10.x MONGO_SETTINGS=

Why there are 1.5 and 1.6 jobs ?

To my mind, 1.5 and 1.6 are equal to 1.1 and 1.2.

The expected matrix is :

  • 1.1 Go: 1.10.x MONGO_SETTINGS=–auth
  • 1.2 Go: 1.10.x MONGO_SETTINGS=
  • 1.3 Go: 1.11.x MONGO_SETTINGS=–auth
  • 1.4 Go: 1.11.x MONGO_SETTINGS=
language: go
go:
  - "1.10.x"
  - "1.11.x"
env:
  matrix:
    - MONGO_SETTINGS=--auth
    - MONGO_SETTINGS=
install:
  - wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.18.tgz
  - tar xfz mongodb-linux-x86_64-3.4.18.tgz
  - export PATH=`pwd`/mongodb-linux-x86_64-3.4.18/bin:$PATH
  - mkdir -p data/db
  - mongod --dbpath=data/db &
  - sleep 3
before_script:
  - if [[ ${MONGO_SETTINGS} = "--auth" ]]; then
        mongorestore -h 127.0.0.1 --port 27017 -d data integration;
        mongo data --eval 'db.createUser({user:"travis", pwd:"test", roles:["readWrite"]})';
        mongod --dbpath=data/db --shutdown;
        sleep 10;
        mongod --dbpath=data/db --fork --logpath mongodb.log "$MONGO_SETTINGS";
        sleep 3;
        mongo data --username travis --password test --eval "db.getCollection('data').find({})";
    else
        mongorestore -h 127.0.0.1 --port 27017 -d data integration;
        mongo data --eval "db.getCollection('data').find({})";
    fi
script:
  - if [[ ${MONGO_SETTINGS} = "--auth" ]]; then
    go test ./... -tags=authentication;
else
    go test ./...;
fi

this makes no sense and is causing problems getting our new release out…

This is simple, you have a 2x2 build matrix with:

go:
  - "1.10.x"
  - "1.11.x"
env:
  matrix:
    - MONGO_SETTINGS=--auth
    - MONGO_SETTINGS=`

To top that you have another additional 2 jobs in matrix.include, for a grand total of 6 jobs.

Notice that your jobs 1.5 and 1.6 behave differently from jobs 1.1 and 1.2 with respect to before_script. I

I can’t tell from your description which jobs you don’t want, so I can’t really advise you on how to modify this. If you do give me more information, I can tell you how to modify this, so it works the way you’re intending.

Cheers,
Montana Mendy

2 Likes
Imprint