This repository has been archived by the owner on Jan 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
executable file
·424 lines (389 loc) · 10.1 KB
/
.gitlab-ci.yml
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
image: registry.gitlab.com/cloudigrade/images/test-container
stages:
- Deploy Images
- Test Integrade
- Deploy Master
- Test Cloudigrade API
- Test Cloudigrade Inspection
- Test Cloudigrade UI
- Teardown Cloudigrade
- Cleanup
#####################################################################
# Shared definitions.
.archive_results: &archive_results
artifacts:
when: always
reports:
junit: "${REPORT_NAME}.xml"
name: "${REPORT_NAME}"
paths:
- "${REPORT_NAME}.xml"
- "${REPORT_NAME}-api.log"
- "${REPORT_NAME}-celery-worker.log"
- "${REPORT_NAME}-celery-beat.log"
.before_script: &before_script
before_script:
- python --version
- oc version
- make install-dev
- oc login ${OPENSHIFT_URL} --token ${GITLAB_CI_SA_TOKEN}
- oc project ${OPENSHIFT_PROJECT}
- export USE_HTTPS=true
- cp aws_image_config_template.yaml integrade/aws_image_config.yaml
.api_all: &api_all
script:
- py.test -s --junitxml="${REPORT_NAME}.xml" -vvv --force-flaky -m 'not inspection' integrade/tests/api
.inspect: &inspect
script:
- cp aws_image_config_template.yaml integrade/aws_image_config.yaml
- py.test --junitxml="${REPORT_NAME}.xml" -vvv -m 'inspection' integrade/tests/api
after_script:
- python scripts/aws_reaper.py --env-cloudtrail-only
.master_variables: &master_variables
CLOUDTRAIL_PREFIX: review-master-integrade-
AWS_S3_BUCKET_NAME: review-master-integrade-cloudigrade-s3
AWS_QUEUE_PREFIX: review-master-integrade-
CLOUDIGRADE_BASE_URL: review-master-integrade.5a9f.insights-dev.openshiftapps.com
OPENSHIFT_PREFIX: c-review-master-integrade-
BRANCH_NAME: master
.branch_variables: &branch_variables
CLOUDTRAIL_PREFIX: review-${CI_COMMIT_REF_SLUG}-
AWS_S3_BUCKET_NAME: ${CI_COMMIT_REF_SLUG}-cloudigrade-s3
AWS_QUEUE_PREFIX: review-${CI_COMMIT_REF_SLUG}-
BRANCH_NAME: ${CI_COMMIT_REF_SLUG}
.ui_scripts: &ui_scripts
script:
- py.test --junitxml="${REPORT_NAME}.xml" -vvv integrade/tests/ui ${EXTRA_PYTEST_ARGS}
#####################################################################
# Deploy images every morning so we have some inspections to look at
# Commented out until later date at which point this may become relavent again.
# CloudMeter development is going into deep freeze.
# Deploy Images:
# stage: Deploy Images
# tags:
# - shared
# only:
# refs:
# - schedules
# variables:
# - $ONLY_DEPLOY_IMAGES == "true"
# before_script:
# - python --version
# - make install-dev
# - pip install codecov
# - cp aws_image_config_template.yaml integrade/aws_image_config.yaml
# script:
# - python scripts/aws_instigator.py
# coverage: '/\d+\%\s*$/'
#####################################################################
# Test integrade's own code.
Test Integrade:
stage: Test Integrade
tags:
- shared
except:
refs:
- schedules
before_script:
- python --version
- make install-dev
- pip install codecov
script:
- cp aws_image_config_template.yaml integrade/aws_image_config.yaml
- make lint
- make test-coverage
- codecov
coverage: '/\d+\%\s*$/'
#####################################################################
# Jobs that run ONLY on branches.
# These should do the same thing as the jobs for master, but these
# have different environment variables and some are manual because
# they may be slow. These also require someone else to set up branch
# review environments for cloudigrade and frontigrade BEFORE these
# jobs run.
API (automatic):
stage: Test Cloudigrade API
tags:
- shared
variables:
<<: *branch_variables
except:
refs:
- master
- schedules
allow_failure: true # allow inspection or UI tests to run if API fails
<<: *before_script
<<: *api_all
<<: *archive_results
after_script:
- python scripts/aws_reaper.py --env-cloudtrail-only
Inspection (manual):
stage: Test Cloudigrade Inspection
tags:
- shared
variables:
<<: *branch_variables
except:
refs:
- schedules
- master
when: manual
allow_failure: true # allows UI tests to run if inspection fails
<<: *before_script
<<: *archive_results
<<: *inspect
UI Chrome (manual):
stage: Test Cloudigrade UI
tags:
- shared
except:
- master
- schedules
when: manual
<<: *before_script
<<: *archive_results
<<: *ui_scripts
variables:
<<: *branch_variables
REPORT_NAME: ui_chrome
UI_BROWSER: Chrome
UI_USE_REMOTE: "true"
services:
- name: selenium/standalone-chrome
alias: selenium
UI Firefox (manual):
stage: Test Cloudigrade UI
tags:
- shared
except:
- master
- schedules
when: manual
<<: *before_script
<<: *archive_results
<<: *ui_scripts
variables:
<<: *branch_variables
REPORT_NAME: ui_firefox
UI_BROWSER: Firefox
UI_USE_REMOTE: "true"
services:
- name: selenium/standalone-firefox
alias: selenium
UI Microsoft Edge (manual):
stage: Test Cloudigrade UI
tags:
- shared
except:
- master
- schedules
when: manual
<<: *before_script
<<: *archive_results
<<: *ui_scripts
variables:
<<: *branch_variables
REPORT_NAME: ui_edge
UI_BROWSER: MicrosoftEdge
#####################################################################
# Deploy review environments for master jobs only.
# These tests require a custom "master" review environment because
# they cannot run against our test and stage environments.
Deploy Master Cloudigrade:
stage: Deploy Master
tags:
- shared
image: registry.gitlab.com/finestructure/pipeline-trigger
only:
refs:
- master
- schedules
except:
variables:
- $ONLY_DEPLOY_IMAGES == "true"
variables:
PROJECT_ID: 7449616
TARGET_BRANCH: master
DEPLOYMENT_NAME: integrade
script:
- >
trigger -a ${API_TOKEN} -p ${CLOUDIGRADE_PIPELINE_TOKEN}
-t ${TARGET_BRANCH} -e CHAT_INPUT=${DEPLOYMENT_NAME} ${PROJECT_ID}
# Deploy Master Frontigrade:
# stage: Deploy Master
# tags:
# - shared
# image: registry.gitlab.com/finestructure/pipeline-trigger
# only:
# - master
# - schedules
# variables:
# PROJECT_ID: 7449617
# TARGET_BRANCH: master
# DEPLOYMENT_NAME: integrade
# script:
# - >
# trigger -a ${API_TOKEN} -p ${FRONTIGRADE_PIPELINE_TOKEN}
# -t ${TARGET_BRANCH} -e CHAT_INPUT=${DEPLOYMENT_NAME} ${PROJECT_ID}
#####################################################################
# Jobs that run on master upon commits and on schedule.
# These should run ALL tests automatically. The content of the tests
# is the same as when run in a branch, but all "manual" branch jobs
# are now automatic.
API:
stage: Test Cloudigrade API
tags:
- shared
only:
refs:
- master
- schedules
except:
variables:
- $ONLY_DEPLOY_IMAGES == "true"
when: always
<<: *before_script
<<: *api_all
<<: *archive_results
variables:
<<: *master_variables
REPORT_NAME: api_all
after_script:
- python scripts/aws_reaper.py --env-cloudtrail-only
# Inspection:
# stage: Test Cloudigrade Inspection
# tags:
# - shared
# only:
# - master
# - schedules
# <<: *before_script
# <<: *archive_results
# <<: *inspect
# variables:
# <<: *master_variables
# UI Chrome:
# stage: Test Cloudigrade UI
# tags:
# - shared
# only:
# - master
# - schedules
# when: always
# <<: *before_script
# <<: *archive_results
# <<: *ui_scripts
# variables:
# <<: *master_variables
# REPORT_NAME: ui_chrome
# UI_BROWSER: Chrome
# UI_USE_REMOTE: "true"
# services:
# - name: selenium/standalone-chrome
# alias: selenium
# UI Firefox:
# stage: Test Cloudigrade UI
# tags:
# - shared
# only:
# - master
# - schedules
# when: always
# <<: *before_script
# <<: *archive_results
# <<: *ui_scripts
# variables:
# <<: *master_variables
# REPORT_NAME: ui_firefox
# UI_BROWSER: Firefox
# UI_USE_REMOTE: "true"
# services:
# - name: selenium/standalone-firefox
# alias: selenium
# UI Microsoft Edge:
# stage: Test Cloudigrade UI
# tags:
# - shared
# only:
# - master
# - schedules
# when: always
# <<: *before_script
# <<: *archive_results
# <<: *ui_scripts
# variables:
# <<: *master_variables
# REPORT_NAME: ui_edge
# UI_BROWSER: MicrosoftEdge
# EXTRA_PYTEST_ARGS: "-x --ff"
#####################################################################
# Clean up master review environments.
.stop_master_review: &stop_master_review
stage: Teardown Cloudigrade
tags:
- shared
only:
refs:
- master
- schedules
when: always
except:
variables:
- $ONLY_DEPLOY_IMAGES == "true"
script: >
curl --request POST --header "${AUTH}"
https://gitlab.com/api/v4/projects/${PROJECT_ID}/environments/$(
curl --header "${AUTH}" https://gitlab.com/api/v4/projects/${PROJECT_ID}/environments |
jq '.[] | (.name=="review/master-integrade") | .id'
)/stop
Teardown Cloudigrade (Master):
<<: *stop_master_review
variables:
GIT_STRATEGY: none
PROJECT_ID: 7449616
AUTH: "PRIVATE-TOKEN: ${API_TOKEN}"
tags:
- shared
Teardown Frontigrade (Master):
<<: *stop_master_review
variables:
GIT_STRATEGY: none
PROJECT_ID: 7449617
AUTH: "PRIVATE-TOKEN: ${API_TOKEN}"
tags:
- shared
#####################################################################
# Clean up customer accounts at the end of each pipeline run.
Test Cleanup:
stage: Cleanup
tags:
- shared
<<: *before_script
variables:
<<: *master_variables
except:
variables:
- $ONLY_DEPLOY_IMAGES == "true"
script:
- python scripts/aws_reaper.py --env-cloudtrail-only
when: always
Nightly Cleanup:on-schedule:
stage: Cleanup
tags:
- shared
only:
refs:
- schedules
except:
variables:
- $ONLY_DEPLOY_IMAGES == "true"
# will only run on the scheduled pipeline,
# 'always' in this context means it will run
# even if prior stages fail
when: always
before_script:
- python --version
- oc version
- make install-dev
script:
- python scripts/aws_reaper.py --all-integrade-cloudtrails