为什么我的 Travis-CI 矩阵会得到额外的工作?

Why am I getting extra jobs with my Travis-CI matrix?

我不明白 Travis-CI 对矩阵的行为。

我的.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

矩阵returns 6个职位

为什么有 1.5 和 1.6 个职位?

在我看来,1.5 和 1.6 等于 1.1 和 1.2。

预期的矩阵是:

编辑:感谢@banzaiman。我的错误是使用 matrix.include 添加了两个新工作。

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

你有一个 2x2 构建矩阵:

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

matrix.include 中的另外 2 个职位,总共有 6 个职位。

请注意,关于 before_script,您的作业 1.5 和 1.6 的行为与作业 1.1 和 1.2 不同。我无法从你的描述中看出你想要哪些工作,所以我无法就如何修改它提供建议。