travis-ci/worker:.travis.yml@0864d6c
language: go
go: 1.17.x
dist: xenial
cache:
directories:
- vendor
- $HOME/.cache/go-build
- $HOME/gopath/bin
- $HOME/gopath/pkg/mod
services:
- rabbitmq
- docker
- redis
env:
global:
- AMQP_URI="amqp://"
- GOPATH="$HOME/gopath"
- PATH="bin:$HOME/gopath/bin:$HOME/bin:$PATH"
- CHECKOUT_ROOT="$HOME/gopath/src/github.com/travis-ci/worker"
- GO15VENDOREXPERIMENT='1'
- REDIS_URL="redis://"
stages:
- test
before_cache:
- make clean
jobs:
include:
- stage: test
name: linux
go: 1.17.x
script:
- make deps
- make lintall
- GO111MODULE=on make build
- mkdir -p build/linux/amd64
- cp ${GOPATH%%:*}/bin/travis-worker build/linux/amd64
- make test-no-cover
- make test-cover
- make smoke
addons:
apt:
packages:
- rabbitmq-server
artifacts:
paths:
- ./build/linux/amd64/travis-worker
target_paths:
- travis-ci/worker/$TRAVIS_BUILD_NUMBER/$TRAVIS_JOB_NUMBER
- travis-ci/worker/$(git describe --always --dirty --tags)
- travis-ci/worker/$TRAVIS_BRANCH
- stage: test
name: crossbuild
go: 1.17.x
script:
- GO111MODULE=on make build/darwin/amd64/travis-worker
addons:
artifacts:
paths:
- ./build/darwin/amd64/travis-worker
target_paths:
- travis-ci/worker/$TRAVIS_BUILD_NUMBER/$TRAVIS_JOB_NUMBER
- travis-ci/worker/$(git describe --always --dirty --tags)
- travis-ci/worker/$TRAVIS_BRANCH
- stage: test
name: docker
if: type != 'pull_request' && env(VAULT_PASS) is present && env(VAULT_USERNAME) is present
script:
- vault login -method=userpass username=$VAULT_USERNAME password=$VAULT_PASS
- vault kv get -field=secret gcp/gcr-sa-key > /tmp/gcr_key.json;
- gcloud -q auth activate-service-account --key-file /tmp/gcr_key.json;
- gcloud -q config set project ${GCE_PROJECT}
- gcloud auth configure-docker
- make docker-build
- make docker-push
addons:
snaps:
- name: google-cloud-sdk
confinement: classic
- name: vault
apt:
update: true
packages:
- docker-ce
- stage: test
name: http-job-test
script:
- GO111MODULE=on make build
- mkdir -p build/linux/amd64
- cp ${GOPATH%%:*}/bin/travis-worker build/linux/amd64
- make http-job-test
Build Config
{
"language": "go",
"os": [
"linux"
],
"dist": "xenial",
"go": [
"1.17.x"
],
"cache": {
"directories": [
"vendor",
"$HOME/.cache/go-build",
"$HOME/gopath/bin",
"$HOME/gopath/pkg/mod"
]
},
"services": [
"rabbitmq",
"docker",
"redis"
],
"env": {
"global": [
{
"AMQP_URI": "\"amqp://\""
},
{
"GOPATH": "\"$HOME/gopath\""
},
{
"PATH": "\"bin:$HOME/gopath/bin:$HOME/bin:$PATH\""
},
{
"CHECKOUT_ROOT": "\"$HOME/gopath/src/github.com/travis-ci/worker\""
},
{
"GO15VENDOREXPERIMENT": "'1'"
},
{
"REDIS_URL": "\"redis://\""
}
]
},
"stages": [
{
"name": "test"
}
],
"before_cache": [
"make clean"
],
"jobs": {
"include": [
{
"stage": "test",
"name": "linux",
"go": "1.17.x",
"script": [
"make deps",
"make lintall",
"GO111MODULE=on make build",
"mkdir -p build/linux/amd64",
"cp ${GOPATH%%:*}/bin/travis-worker build/linux/amd64",
"make test-no-cover",
"make test-cover",
"make smoke"
],
"addons": {
"apt": {
"packages": [
"rabbitmq-server"
]
},
"artifacts": {
"paths": [
"./build/linux/amd64/travis-worker"
],
"target_paths": [
"travis-ci/worker/$TRAVIS_BUILD_NUMBER/$TRAVIS_JOB_NUMBER",
"travis-ci/worker/$(git describe --always --dirty --tags)",
"travis-ci/worker/$TRAVIS_BRANCH"
]
}
}
},
{
"stage": "test",
"name": "crossbuild",
"go": "1.17.x",
"script": [
"GO111MODULE=on make build/darwin/amd64/travis-worker"
],
"addons": {
"artifacts": {
"paths": [
"./build/darwin/amd64/travis-worker"
],
"target_paths": [
"travis-ci/worker/$TRAVIS_BUILD_NUMBER/$TRAVIS_JOB_NUMBER",
"travis-ci/worker/$(git describe --always --dirty --tags)",
"travis-ci/worker/$TRAVIS_BRANCH"
]
}
}
},
{
"stage": "test",
"name": "docker",
"if": "type != 'pull_request' && env(VAULT_PASS) is present && env(VAULT_USERNAME) is present",
"script": [
"vault login -method=userpass username=$VAULT_USERNAME password=$VAULT_PASS",
"vault kv get -field=secret gcp/gcr-sa-key > /tmp/gcr_key.json;",
"gcloud -q auth activate-service-account --key-file /tmp/gcr_key.json;",
"gcloud -q config set project ${GCE_PROJECT}",
"gcloud auth configure-docker",
"make docker-build",
"make docker-push"
],
"addons": {
"snaps": [
{
"confinement": "classic",
"name": "google-cloud-sdk"
},
{
"name": "vault"
}
],
"apt": {
"update": true,
"packages": [
"docker-ce"
]
}
}
},
{
"stage": "test",
"name": "http-job-test",
"script": [
"GO111MODULE=on make build",
"mkdir -p build/linux/amd64",
"cp ${GOPATH%%:*}/bin/travis-worker build/linux/amd64",
"make http-job-test"
]
}
]
}
}