Я не понимаю, как работает Travis-CI с матрицей.
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
Матрица возвращает 6 заданий
- 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 =
Почему существует 1,5 и 1,6 рабочих мест?
На мой взгляд, 1,5и 1.6 равны 1.1 и 1.2.
Ожидаемая матрица:
- 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 =
Редактировать : Спасибо @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