-
Notifications
You must be signed in to change notification settings - Fork 5
/
cloudbuild.yaml
93 lines (85 loc) · 3.14 KB
/
cloudbuild.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#################################################################################
# Deployment.
#
# Overview:
# 1. Test in sandbox during development.
# 2. Deploy to staging on commit to main branch.
# 3. Deploy to prod when a branch is tagged with vX.Y.Z
#
# Test individual components in sandbox before code review. Create your own
# sandbox branch for your changes, and coordinate with others to avoid
# conflicting deployments. Each person should use a branch name to trigger the
# single deployment that they are working on.
#
# Deploy reviewed code to staging before deploying to prod. To avoid
# incompatible components, we deploy ALL elements to staging when we merge
# changes.
#
# Deployments to production are done by manually tagging a specific commit,
# typically in the main branch, with a tag matching the pattern vX.Y.Z. DO NOT
# just tag the latest version, as someone may have pushed new code that hasn't
# had a chance to be qualified in staging.
#
# Deploy steps should trigger on specific branch name patterns or on an
# explicit tags.
# ################################################################################
timeout: 1800s
options:
machineType: 'N1_HIGHCPU_8'
env:
- PROJECT_ID=$PROJECT_ID
- GIT_COMMIT=$COMMIT_SHA
steps:
# Make all git tags available.
- name: gcr.io/cloud-builders/git
id: "Unshallow git clone"
args: ["fetch", "--unshallow"]
# Fetch travis submodule.
- name: gcr.io/cloud-builders/git
id: "Update travis submodule"
args: ["submodule", "update", "--init", "--recursive"]
# TODO: while local docker builds cache intermediate layers, CB does not.
# Combine the Dockerfile.testing with the Dockerfile using --target and
# --from-cache to speed up builds: See also:
# https://andrewlock.net/caching-docker-layers-on-serverless-build-hosts-with-multi-stage-builds---target,-and---cache-from/
- name: gcr.io/cloud-builders/docker
id: "Build the testing docker container"
args: [
"build", "-t", "gardener-testing", "-f", "Dockerfile.testing", "."
]
- name: gardener-testing
id: "Run all gardener unit tests"
args:
- go version
- go get -v -t ./...
- go get -v -tags=integration -t ./...
- go test -v -coverprofile=_unit.cov ./...
- go test -v ./tracker/... ./ops/... -race
# Integration testing requires additional SA credentials.
- ./integration-testing.sh
env:
- SERVICE_ACCOUNT_mlab_testing=$_SERVICE_ACCOUNT_MLAB_TESTING
- WORKSPACE_LINK=/go/src/github.com/m-lab/etl-gardener
- name: gcr.io/cloud-builders/docker
id: "Build the etl-gardener docker container"
args: [
"build",
"--build-arg", "VERSION=${TAG_NAME}${BRANCH_NAME}",
"-t", "gcr.io/$PROJECT_ID/etl-gardener:${COMMIT_SHA}", "."
]
waitFor: ['-']
- name: gcr.io/cloud-builders/docker
id: "Push the docker container to gcr.io"
args: [
"push", "gcr.io/$PROJECT_ID/etl-gardener:${COMMIT_SHA}"
]
# UNIVERSAL CLUSTER: Run apply-cluster.sh
- name: gcr.io/cloud-builders/kubectl
id: "Deploy universal gardener configuration"
entrypoint: /bin/bash
args: [
'-c', '/builder/kubectl.bash version && ./apply-cluster.sh'
]
env:
- CLOUDSDK_COMPUTE_REGION=$_CLUSTER_REGION
- CLOUDSDK_CONTAINER_CLUSTER=$_CLUSTER_NAME