forked from openconfig/public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
295 lines (283 loc) · 7.95 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
substitutions:
_OC_PYANG_VERSION: master
steps:
############### GET CI REPO ###############
# Decrypt the file containing the key
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- kms
- decrypt
- --ciphertext-file=id_rsa.enc
- --plaintext-file=/root/.ssh/id_rsa
- --location=global
- --keyring=keyring0
- --key=key0
volumes:
- name: 'ssh'
path: /root/.ssh
# Set up git with key and domain
# See https://cloud.google.com/build/docs/access-github-from-build#add_the_public_ssh_key_to_known_hosts
- name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
args:
- '-c'
- |
chmod 600 /root/.ssh/id_rsa
cat <<EOF >/root/.ssh/config
Hostname github.com
IdentityFile /root/.ssh/id_rsa
EOF
mv known_hosts /root/.ssh/known_hosts
volumes:
- name: 'ssh'
path: /root/.ssh
############### COMMON PREP ###############
# Create GOPATH
- name: 'golang'
entrypoint: 'bash'
args: ['-c', 'mkdir -p /go/src/github.com/openconfig']
volumes:
- name: 'gopath'
path: /go
id: 'go path creation'
# Clone CI repository
- name: 'golang'
entrypoint: 'bash'
args:
- '-c'
- |
git clone [email protected]:openconfig/models-ci.git /go/src/github.com/openconfig/models-ci
cd /go/src/github.com/openconfig/models-ci
# Modify the major version to update models-ci version.
branch=$(git tag -l 'v11.*' | sort -V | tail -1)
git checkout $branch
volumes:
- name: 'ssh'
path: /root/.ssh
- name: 'gopath'
path: /go
id: 'models-ci clone'
# Get CI script dependencies
- name: 'golang'
entrypoint: 'go'
args:
- 'install'
- './...'
volumes:
- name: 'ssh'
path: /root/.ssh
- name: 'gopath'
path: /go
env:
- 'GOPATH=/go'
dir: '/go/src/github.com/openconfig/models-ci'
id: 'models-ci dep'
# Generate validator scripts
- name: 'golang'
entrypoint: 'bash'
args:
- -c
- >- # CI Configuration
/go/bin/cmd_gen
-modelRoot=$_MODEL_ROOT
-repo-slug=$_REPO_SLUG
-pr-head-repo-url=$_HEAD_REPO_URL
-commit-sha=$COMMIT_SHA
-pr-number=$_PR_NUMBER
-skipped-validators=confd,yanglint
-extra-pyang-versions=2.2.1
-branch=$BRANCH_NAME
-compat-report=pyangbind
secretEnv: ['GITHUB_ACCESS_TOKEN']
env:
- 'GOPATH=/go'
volumes:
- name: 'gopath'
path: /go
id: 'validator prep'
############### REGEXP TESTS ###############
# Clone CI repository
- name: 'golang'
entrypoint: 'bash'
args:
- '-c'
- |
git clone [email protected]:openconfig/pattern-regex-tests.git /go/src/github.com/openconfig/pattern-regex-tests
cd /go/src/github.com/openconfig/pattern-regex-tests
# Modify the major version to update regexp version.
branch=$(git tag -l 'v2.0*' | sort -V | tail -1)
git checkout $branch
volumes:
- name: 'ssh'
path: /root/.ssh
- name: 'gopath'
path: /go
waitFor: ['validator prep']
id: 'regexp clone'
# Get regexp dependencies
- name: 'golang'
entrypoint: 'go'
args: ['install', './...']
volumes:
- name: 'gopath'
path: /go
env:
- 'GOPATH=/go'
dir: '/go/src/github.com/openconfig/pattern-regex-tests'
waitFor: ['regexp clone']
id: 'regexp dep'
- name: 'us-west1-docker.pkg.dev/$PROJECT_ID/models-ci/models-ci-image'
entrypoint: 'bash'
args: ['-c', "/go/src/github.com/openconfig/models-ci/validators/regexp/test.sh"]
secretEnv: ['GITHUB_ACCESS_TOKEN']
env:
- 'GOPATH=/go'
- '_PR_NUMBER=$_PR_NUMBER'
- 'COMMIT_SHA=$COMMIT_SHA'
- '_MODEL_ROOT=$_MODEL_ROOT'
- '_REPO_SLUG=$_REPO_SLUG'
- 'BRANCH_NAME=$BRANCH_NAME'
volumes:
- name: 'gopath'
path: /go
waitFor: ['regexp dep']
id: 'regexp'
############### YANGLINT ##############
- name: gcr.io/cloud-builders/gsutil
args: ['cp', 'gs://openconfig/libyang.deb', '/workspace/libyang.deb']
waitFor: ['validator prep']
id: 'yanglint prep1'
- name: gcr.io/cloud-builders/gsutil
args: ['cp', 'gs://openconfig/yanglint.deb', '/workspace/yanglint.deb']
waitFor: ['validator prep']
id: 'yanglint prep2'
- name: 'us-west1-docker.pkg.dev/$PROJECT_ID/models-ci/models-ci-image'
entrypoint: 'bash'
args: ['-c', "/go/src/github.com/openconfig/models-ci/validators/yanglint/test.sh"]
secretEnv: ['GITHUB_ACCESS_TOKEN']
volumes:
- name: 'gopath'
path: /go
env:
- 'GOPATH=/go'
- '_PR_NUMBER=$_PR_NUMBER'
- '_MODEL_ROOT=$_MODEL_ROOT'
- 'COMMIT_SHA=$COMMIT_SHA'
- '_REPO_SLUG=$_REPO_SLUG'
- 'BRANCH_NAME=$BRANCH_NAME'
waitFor: ['yanglint prep1', 'yanglint prep2']
id: 'yanglint'
############### MISC-CHECKS ###############
- name: 'golang'
entrypoint: 'bash'
args: ['-c', "/go/src/github.com/openconfig/models-ci/validators/misc-checks/test.sh"]
secretEnv: ['GITHUB_ACCESS_TOKEN']
volumes:
- name: 'ssh'
path: /root/.ssh
- name: 'gopath'
path: /go
env:
- 'GOPATH=/go'
- '_PR_NUMBER=$_PR_NUMBER'
- '_MODEL_ROOT=$_MODEL_ROOT'
- 'COMMIT_SHA=$COMMIT_SHA'
- '_REPO_SLUG=$_REPO_SLUG'
- 'BRANCH_NAME=$BRANCH_NAME'
waitFor: ['validator prep']
id: 'misc-checks'
############### OC-PYANG ###############
- name: 'us-west1-docker.pkg.dev/$PROJECT_ID/models-ci/models-ci-image'
entrypoint: 'bash'
args: ['-c', '/go/src/github.com/openconfig/models-ci/validators/oc-pyang/test.sh']
secretEnv: ['GITHUB_ACCESS_TOKEN']
env:
- 'GOPATH=/go'
- '_PR_NUMBER=$_PR_NUMBER'
- '_MODEL_ROOT=$_MODEL_ROOT'
- 'COMMIT_SHA=$COMMIT_SHA'
- '_REPO_SLUG=$_REPO_SLUG'
- 'BRANCH_NAME=$BRANCH_NAME'
- '_OC_PYANG_VERSION=$_OC_PYANG_VERSION'
volumes:
- name: 'gopath'
path: /go
waitFor: ['validator prep']
id: 'oc-pyang'
############### GOYANG/YGOT ###############
- name: 'us-west1-docker.pkg.dev/$PROJECT_ID/models-ci/models-ci-image'
entrypoint: 'bash'
args: ['-c', "/go/src/github.com/openconfig/models-ci/validators/goyang-ygot/test.sh"]
secretEnv: ['GITHUB_ACCESS_TOKEN']
volumes:
- name: 'gopath'
path: /go
env:
- 'GOPATH=/go'
- '_PR_NUMBER=$_PR_NUMBER'
- '_MODEL_ROOT=$_MODEL_ROOT'
- 'COMMIT_SHA=$COMMIT_SHA'
- '_REPO_SLUG=$_REPO_SLUG'
- 'BRANCH_NAME=$BRANCH_NAME'
waitFor: ['validator prep', 'go path creation', 'oc-pyang']
id: 'goyang-ygot'
############### PYANG ###############
- name: 'us-west1-docker.pkg.dev/$PROJECT_ID/models-ci/models-ci-image'
entrypoint: 'bash'
args: ['-c', '/go/src/github.com/openconfig/models-ci/validators/pyang/test.sh']
secretEnv: ['GITHUB_ACCESS_TOKEN']
env:
- 'GOPATH=/go'
- '_PR_NUMBER=$_PR_NUMBER'
- '_MODEL_ROOT=$_MODEL_ROOT'
- 'COMMIT_SHA=$COMMIT_SHA'
- '_REPO_SLUG=$_REPO_SLUG'
- 'BRANCH_NAME=$BRANCH_NAME'
volumes:
- name: 'gopath'
path: /go
waitFor: ['validator prep', 'oc-pyang']
id: 'pyang'
############### PYANGBIND ###############
- name: 'us-west1-docker.pkg.dev/$PROJECT_ID/models-ci/models-ci-image'
entrypoint: 'bash'
args: ['-c', '/go/src/github.com/openconfig/models-ci/validators/pyangbind/test.sh']
secretEnv: ['GITHUB_ACCESS_TOKEN']
env:
- 'GOPATH=/go'
- '_PR_NUMBER=$_PR_NUMBER'
- '_MODEL_ROOT=$_MODEL_ROOT'
- 'COMMIT_SHA=$COMMIT_SHA'
- '_REPO_SLUG=$_REPO_SLUG'
- 'BRANCH_NAME=$BRANCH_NAME'
volumes:
- name: 'gopath'
path: /go
waitFor: ['validator prep', 'oc-pyang']
id: 'pyangbind'
############### COMPATIBILITY REPORT ###############
- name: 'us-west1-docker.pkg.dev/$PROJECT_ID/models-ci/models-ci-image'
entrypoint: 'bash'
args: ['-c', '/go/src/github.com/openconfig/models-ci/validators/compat_report.sh']
secretEnv: ['GITHUB_ACCESS_TOKEN']
env:
- 'GOPATH=/go'
- '_PR_NUMBER=$_PR_NUMBER'
- '_MODEL_ROOT=$_MODEL_ROOT'
- 'COMMIT_SHA=$COMMIT_SHA'
- '_REPO_SLUG=$_REPO_SLUG'
- 'BRANCH_NAME=$BRANCH_NAME'
volumes:
- name: 'gopath'
path: /go
id: 'compat-report'
timeout: 600s
options:
machineType: 'E2_HIGHCPU_32'
availableSecrets:
inline:
- kmsKeyName: 'projects/$PROJECT_ID/locations/global/keyRings/keyring0/cryptoKeys/key0'
envMap:
# This is the encrypted version of the token.
GITHUB_ACCESS_TOKEN: 'CiQAvY6emxdh1dn1h9yW/IXSsGQE8l2L39zL8zT8lugxP4zsxBcSUQACTwBYgV0FHz18eP4bqQP6v9Co5ScbuOY24VgquPjtjGumwmdo68/Mn6P6uNn2DOUULvnHfOdpSG865RPGlVSM7kCo5n5tR2e9oskvYfMFWA=='