-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
175 lines (152 loc) · 5.13 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
timeout: 900s
options:
env:
# Provide information for cbif to reconstruct .git config.
- COMMIT_SHA=$COMMIT_SHA
- GIT_ORIGIN_URL=https://github.com/m-lab/siteinfo.git
- PROJECT_ID=$PROJECT_ID
availableSecrets:
secretManager:
- versionName: projects/${PROJECT_NUMBER}/secrets/siteinfo-builds-github-token/versions/latest
env: GITHUB_TOKEN
steps:
############################################################################
# RUN UNIT TESTS
############################################################################
- name: gcr.io/cloud-builders/docker
args: [
'build', '-t', 'python-env', '-f', 'Dockerfile.python', '.'
]
- name: python-env
args: [
'python3', '-m', 'unittest', 'discover', '-s', 'cmd/', '-p', '*_test.py'
]
# Import submodules to run jsonnet unit tests.
- name: gcr.io/$PROJECT_ID/gcloud-jsonnet-cbif:1.0
args: [
'git submodule update --init --recursive'
]
# Run jsonnet unit tests.
- name: gcr.io/$PROJECT_ID/gcloud-jsonnet-cbif:1.0
args: [
'make test VERSION=v1',
'make test VERSION=v2'
]
############################################################################
# BUILD ARTIFACTS
############################################################################
# Generate v1 and v2 json files.
- name: gcr.io/$PROJECT_ID/gcloud-jsonnet-cbif:1.0
args: [
'make VERSION=v1',
'make VERSION=v2'
]
env:
- 'PROJECT=${PROJECT_ID}'
############################################################################
# DEPLOY ARTIFACTS
############################################################################
# Publish new v1 data.
- name: gcr.io/cloud-builders/gsutil
args: [
'-h', 'Cache-Control:private, max-age=0, no-transform', '-m',
'cp', '-r', '/workspace/output/v1/*', 'gs://siteinfo-$PROJECT_ID/v1/'
]
# Publish new v2 data.
- name: gcr.io/cloud-builders/gsutil
args: [
'-h', 'Cache-Control:private, max-age=0, no-transform', '-m',
'cp', '-r', '/workspace/output/v2/*', 'gs://siteinfo-$PROJECT_ID/v2/'
]
# Copy v1 configs to archive.
- name: gcr.io/cloud-builders/gsutil
args: [
'-h', 'Cache-Control:private, max-age=0, no-transform', '-m',
'cp', '-r', '/workspace/output/configs/v1/*', 'gs://siteinfo-$PROJECT_ID/configs/v1'
]
# Copy v2 configs to archive.
- name: gcr.io/cloud-builders/gsutil
args: [
'-h', 'Cache-Control:private, max-age=0, no-transform', '-m',
'cp', '-r', '/workspace/output/configs/v2/*', 'gs://siteinfo-$PROJECT_ID/configs/v2'
]
############################################################################
# POST BUILD STEPS
############################################################################
# NOTE: The following remote Cloud Build trigger steps will not block this
# build. The steps do not wait for the remote build to finish, but merely start
# it.
# Trigger an epoxy-images stage1 build, which will build stage1 boot images for
# any new sites.
- name: gcr.io/${PROJECT_ID}/siteinfo-cbif:1.0
env:
- PROJECT_IN=mlab-staging,mlab-oti
- SINGLE_COMMAND=true
args: [
'/go/bin/cbctl', '-project=$PROJECT_ID',
'-repo=epoxy-images',
'-trigger_name=epoxy-images-stage1',
'trigger'
]
# Trigger a prometheus-support build. prometheus-support builds build various
# static target files that Prometheus consumes. These static target files are
# gnerated based on sites present, or not, in siteinfo. When a site is retired,
# for example, we need the prometheus-support build to generate updated target
# files, else the old target files will stay in use and alerts may fire for
# retired sites.
- name: gcr.io/${PROJECT_ID}/siteinfo-cbif:1.0
env:
- PROJECT_IN=mlab-staging,mlab-oti
- SINGLE_COMMAND=true
args: [
'/go/bin/cbctl', '-project=$PROJECT_ID',
'-repo=prometheus-support',
'-trigger_name=push-m-lab-prometheus-support-trigger',
'trigger'
]
# Trigger a switch-config build, which will build switch configurations for any
# new sites, and deploy them to GCS.
- name: gcr.io/${PROJECT_ID}/siteinfo-cbif:1.0
entrypoint: /bin/bash
env:
- PROJECT_IN=mlab-staging,mlab-oti
- SINGLE_COMMAND=true
args:
- '-c'
- >
/go/bin/cbif
/go/bin/cbctl
-project=$PROJECT_ID
-repo=switch-config
-trigger_name=switch-config
trigger
secretEnv:
- GITHUB_TOKEN
# Deploy the primary measurement-lab.org zone to Cloud DNS.
- name: gcr.io/cloud-builders/gcloud
entrypoint: '/bin/bash'
args: [
'./deploy_dns.sh'
]
env:
- 'PROJECT=${PROJECT_ID}'
- 'DOMAIN=measurement-lab.org'
- 'ZONEFILE=measurement-lab.org.zone'
# Deploy the measurement-lab.org project subdomain zone to Cloud DNS
- name: gcr.io/cloud-builders/gcloud
entrypoint: '/bin/bash'
args: [
'./deploy_dns.sh'
]
env:
- 'PROJECT=${PROJECT_ID}'
- 'DOMAIN=${PROJECT_ID}.measurement-lab.org'
- 'ZONEFILE=${PROJECT_ID}.measurement-lab.org.zone'
# Sync ePoxy Datastore entities with this repository.
- name: gcr.io/${PROJECT_ID}/siteinfo-cbif:1.0
env:
- PROJECT_IN=mlab-sandbox,mlab-staging,mlab-oti
- SINGLE_COMMAND=true
args: [
'/go/bin/epoxy_admin', 'sync', '--project=$PROJECT_ID'
]