-
Notifications
You must be signed in to change notification settings - Fork 22
/
.gitlab-ci.yml
472 lines (448 loc) · 14.3 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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
image: $DOCKER_URL/node:20
stages:
- update
- atg-shared-checks
- lint
- test
- apidocs
- build
- docs
- deploy
- integration-test
- teardown
variables:
TEST_HARNESS_FILE: ${CI_PROJECT_DIR}/harness_facts.json
ESR_PRODUCT: DO
ESR_TEST_RUN_ID: ${CI_JOB_ID}
ESR_TEST_RUN_WEB_URL: ${CI_JOB_URL}
TEST_REPORTER_OPTIONS: "--reporter mocha-multi-reporters --reporter-options configFile=test/mochaReporterConfig.json"
TF_DIRECTORY: test/env/terraform
TF_HTTP_LOCK_METHOD: POST
TF_HTTP_UNLOCK_METHOD: DELETE
TF_HTTP_USERNAME: ${CI_REGISTRY_USER}
TF_HTTP_PASSWORD: ${CI_JOB_TOKEN}
TF_CLI_ARGS_apply: "-auto-approve"
TF_CLI_ARGS_destroy: "-auto-approve"
TF_STATE_URL: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/terraform/state"
# terraform will try to update state 5(4+1) times every 3 minutes.
TF_HTTP_RETRY_MAX: 4
TF_HTTP_RETRY_WAIT_MIN: 3
DOCS_BUILD_DIR: "docs/_build/html"
# This inherits all the jobs defined in the parent template
# Override variables in this project as needed
include:
# adds atg-shared-checks stage and jobs
# adds atg_shared_checks_result job to test stage
- project: automation-toolchain/atg-shared-templates
file:
- compliance/base.gitlab-ci.yml
- security/base.gitlab-ci.yml
# Override compliance template job
check_copyrights:
allow_failure: false
# Override compliance template job
lint:
allow_failure: false
update_autotool_deps:
stage: update
rules:
- if: '$UPDATE_DEPS =~ /true/i'
needs: []
variables:
UPDATE_BRANCH_NAME: update_autotool_deps
script:
- . ./scripts/dev/update-do-deps.sh
- >
if [ "$AUTOTOOL_DIFF" = "true" ]; then
git push -f origin ${UPDATE_BRANCH_NAME}
node ./scripts/dev/createMR.js
fi
tags: [cm-official-docker-executor]
test_node:4:
stage: test
needs: []
tags:
- cm-official-docker-executor
script:
# npm install fails for some packages on older versions of node, so use a newer
# version just for the install
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
- export NVM_DIR="$HOME/.nvm"
- source "$NVM_DIR/nvm.sh"
- n=0
- until [ "$n" -ge 3 ]; do
- nvm install 4 && nvm install --latest-npm 12 && break
- n=$((n+1))
- sleep 15
- done
- nvm use 12
- npm install --no-optional
- npm install [email protected]
- nvm use 4
- npm test
test_node:6:
stage: test
needs: []
tags:
- cm-official-docker-executor
script:
# npm install fails for some packages on older versions of node, so use a newer
# version just for the install
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
- export NVM_DIR="$HOME/.nvm"
- source "$NVM_DIR/nvm.sh"
- n=0
- until [ "$n" -ge 3 ]; do
- nvm install 6 && nvm install --latest-npm 12 && break
- n=$((n+1))
- sleep 15
- done
- nvm use 12
- npm ci --no-optional
- npm install [email protected]
- nvm use 6
- npm test -- $TEST_REPORTER_OPTIONS
artifacts:
when: always
reports:
junit: test_report.xml
test_node:8:
image: $DOCKER_URL/node:8
stage: test
needs: []
tags:
- cm-official-docker-executor
script:
- npm ci
- npm install mocha@7
- npm test -- $TEST_REPORTER_OPTIONS
artifacts:
when: always
reports:
junit: test_report.xml
test_node:latest:
image: $DOCKER_URL/node:16
stage: test
needs: []
tags:
- cm-official-docker-executor
script:
- npm ci
- npm test -- $TEST_REPORTER_OPTIONS
artifacts:
when: always
reports:
junit: test_report.xml
coverage:
image: $DOCKER_URL/node:16
stage: test
needs: []
tags:
- cm-official-docker-executor
script:
- PUBLIC_DIR='./public'
- mkdir -p ${PUBLIC_DIR}
- COVERAGE_DOCS=${PUBLIC_DIR}/coverage-docs
- mkdir -p ${COVERAGE_DOCS}
## place code coverage docs under: /coverage-docs ##
- npm ci
- npm run coverage
- cp -R coverage/* ${COVERAGE_DOCS}
except:
# For develop, coverage is run in the pages job
- develop
- pipelines
artifacts:
paths:
- public
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
build_rpm:
image: $DOCKER_URL/node:14
stage: build
needs: []
tags:
- cm-official-docker-executor
except:
- pipelines
script:
# setup node environment
- apt-get update && apt-get install -y rpm --no-install-recommends
- scripts/build/buildRpm.sh
artifacts:
name: ${CI_PROJECT_NAME}-${CI_JOB_NAME}-${CI_PIPELINE_IID}
paths:
- dist/
expire_in: 1 week
reactivate_big_iq_license:
stage: build
needs: []
rules:
- if: '$REACTIVATE_BIG_IQ_LICENSE =~ /true/i'
script:
- npm ci
- node scripts/dev/reactivateBigIq.js
build_api_docs:
image: $DOCKER_URL/node:16
stage: apidocs
needs: []
script:
# install packages
# package-lock ends up with OS specific info during npm install, so
# make sure it is right for the platform we're on
- rm package-lock.json
- npm install
# generate docs
- npm run make-api-docs
- mkdir apidocs && mv redoc-static.html apidocs/index.html
tags:
- cm-official-docker-executor
artifacts:
name: docs
paths:
- apidocs
create_docs:
image: ${CONTAINTHEDOCS_IMAGE}
stage: build
allow_failure: true
needs:
- build_api_docs
script:
- if [ "$CI_COMMIT_REF_NAME" = "docs-staging" ] || [ "$CI_COMMIT_REF_NAME" = "docs-latest" ]; then
- rm -rf docs/_templates
- fi
- make html
- API_DOCS_INDEX=${DOCS_BUILD_DIR}/apidocs.html
- cp apidocs/index.html ${API_DOCS_INDEX}
- echo "Checking grammar and style"
# Runs the grammar check on everything except the /docs/drafts directory
- vale --glob='*.rst' .
- echo "Checking links"
- make linkcheck
tags:
- cm-official-docker-executor
artifacts:
expire_in: 1 week
name: sphinx-docs_$CI_COMMIT_SHA
paths:
- docs/_build/html
.deploy_common: &deploy_common
image: $INTEGRATION_DEPLOY_IMAGE
tags:
- do-test-docker-executor
stage: deploy
timeout: 2 hours
script:
- apk update
# Need to add bash, because included sh doen't support arrays
# used in build_harness_file.sh script to get IP addresses.
- apk add bash npm build-base python3 cmake
- if [[ $PROPERTY_TEST == true ]]; then
- export TF_VAR_bigip_count=1
- else
- export TF_VAR_bigip_count=3
- unset BIGIP_LICENSE # Licensing will be handled by integration testing
- fi
- cd "$TF_ROOT"
- terraform init
# In case of testing failure, BIGIP will not be destroyed,
# so before run we need to clean leftovers from last night.
- terraform destroy
- terraform apply
- export BIGIPS_ADDRESSES=$(terraform output --json admin_ip | jq -rc .[])
- export ADMIN_USERNAME=$(terraform output --json admin_username | jq -rc .)
- export ADMIN_PASSWORD=$(terraform output --json admin_password | jq -rc .)
- cd -
- scripts/dev/build_harness_file.sh > $TEST_HARNESS_FILE
- npm ci
- node test/integration/setup.js
artifacts:
when: always
paths:
- ${TEST_HARNESS_FILE}
expire_in: 1 day
retry:
max: 2
when: script_failure
deploy_for_this_project:
rules:
- if: '$RUN_INTEGRATION_TEST =~ /true/i'
variables:
TF_ROOT: '$TF_DIRECTORY/plans/openstack'
TF_VAR_bigip_image: "$BIGIP_IMAGE"
TF_VAR_nic_count: "$NIC_COUNT"
before_script:
- export TRIM_VERSION="$(echo $BIGIP_IMAGE | cut -d '-' -f 2 | tr '.' -)"
- if [[ $PROPERTY_TEST == true ]]; then
- export TF_HTTP_ADDRESS="$TF_STATE_URL/openstack-$TRIM_VERSION-property"
- else
- export TF_HTTP_ADDRESS="$TF_STATE_URL/openstack-$TRIM_VERSION"
- fi
- export TF_HTTP_LOCK_ADDRESS="$TF_HTTP_ADDRESS/lock"
- export TF_HTTP_UNLOCK_ADDRESS=$TF_HTTP_LOCK_ADDRESS
- echo using RPM from our pipeline
- export RPM_PACKAGE=$(ls ${CI_PROJECT_DIR}/dist/*.rpm)
<<: *deploy_common
needs:
- job: build_rpm
artifacts: true
deploy_for_other_project:
rules:
- if: '$TRIGGER_INTEGRATION_TEST =~ /true/i'
variables:
TF_ROOT: "$TF_DIRECTORY/plans/openstack"
TF_VAR_bigip_image: "$BIGIP_IMAGE"
TF_VAR_nic_count: "$NIC_COUNT"
before_script:
- export TRIM_VERSION="$(echo $BIGIP_IMAGE | cut -d '-' -f 2 | tr '.' -)"
- if [[ $PROPERTY_TEST == true ]]; then
- export TF_HTTP_ADDRESS="$TF_STATE_URL/openstack-$TRIM_VERSION-property"
- else
- export TF_HTTP_ADDRESS="$TF_STATE_URL/openstack-$TRIM_VERSION"
- fi
- export TF_HTTP_LOCK_ADDRESS="$TF_HTTP_ADDRESS/lock"
- export TF_HTTP_UNLOCK_ADDRESS=$TF_HTTP_LOCK_ADDRESS
- echo using RPM from cross-project pipeline
- export RPM_PACKAGE=$(ls ${UPSTREAM_RPM_PATH}/*.rpm)
<<: *deploy_common
needs:
- project: "$UPSTREAM_PROJECT_PATH"
job: "$UPSTREAM_JOB"
ref: "$UPSTREAM_REF"
artifacts: true
integration-test:
image: $DOCKER_URL/node:16
tags:
- do-test-docker-executor
rules:
- if: '$RUN_INTEGRATION_TEST =~ /true/i'
- if: '$TRIGGER_INTEGRATION_TEST =~ /true/i'
stage: integration-test
timeout: 3 hours
before_script:
- apt-get update
- apt-get install -y jq
- export ESR_TEST_TYPE=integration
- export ESR_PRODUCT_VERSION=$(node -e "console.log(require('./package.json').version)" | cut -d '-' -f1)
- export ESR_BIG_IP_VERSION=$(echo $BIGIP_IMAGE | cut -d '-' -f 2)
- export GIT_SSL_NO_VERIFY=1
- echo BIGIP_VERSION $ESR_BIG_IP_VERSION
- npm install --no-optional
script:
- if [[ $PROPERTY_TEST == true ]]; then
- export DO_HOST=$(cat ${TEST_HARNESS_FILE} | jq -r '.[0].admin_ip')
- export DO_USERNAME=$(cat ${TEST_HARNESS_FILE} | jq -r '.[0].f5_rest_user.username')
- export DO_PASSWORD=$(cat ${TEST_HARNESS_FILE} | jq -r '.[0].f5_rest_user.password')
- npm run property -- $TEST_REPORTER_OPTIONS
- else
- npm run integration -- $TEST_REPORTER_OPTIONS
- fi
after_script:
- apt-get install -y expect
- scripts/dev/collectRemoteIntegrationTestLogs.sh ${TEST_HARNESS_FILE}
artifacts:
name: f5-declarative-onboarding-$CI_COMMIT_SHA
when: always
paths:
- test/logs
reports:
junit: test_report.xml
expire_in: 1 week
.teardown_common: &teardown_common
image: $INTEGRATION_DEPLOY_IMAGE
tags:
- do-test-docker-executor
stage: teardown
before_script:
# terraform doesn't support '.' in backend address.
- export TRIM_VERSION="$(echo $BIGIP_IMAGE | cut -d '-' -f 2 | tr '.' -)"
- if [[ $PROPERTY_TEST == true ]]; then
- export TF_HTTP_ADDRESS="$TF_STATE_URL/openstack-$TRIM_VERSION-property"
- else
- export TF_HTTP_ADDRESS="$TF_STATE_URL/openstack-$TRIM_VERSION"
- fi
script:
- cd $TF_DIRECTORY/plans/openstack
- terraform init
- terraform destroy
retry:
max: 1
when: script_failure
teardown_for_this_project:
rules:
- if: '$SKIP_TEARDOWN =~ /true/i'
when: never
- if: '$RUN_INTEGRATION_TEST =~ /true/i'
when: always
- when: never
needs:
- job: deploy_for_this_project
- job: integration-test
<<: *teardown_common
teardown_for_other_project:
rules:
- if: '$SKIP_TEARDOWN =~ /true/i'
when: never
- if: '$TRIGGER_INTEGRATION_TEST =~ /true/i'
when: always
- when: never
needs:
- job: deploy_for_other_project
- job: integration-test
<<: *teardown_common
# Deploy docs to Pages for review
# Docs are staged on this projects pages site
pages:
image: $DOCKER_URL/node:16
stage: docs
allow_failure: true
environment:
name: review
url: https://${CI_PROJECT_NAMESPACE}.${PAGES_DOMAIN}/${CI_PROJECT_NAME}/
tags:
- cm-official-docker-executor
needs:
- create_docs
script:
# create public directory
- PUBLIC_DIR='./public'
- mkdir -p ${PUBLIC_DIR}
# place index.html in public dir
- cp docs/index.html ${PUBLIC_DIR}/index.html
## place public facing docs under: /public-docs ##
- PUBLIC_DOCS=${PUBLIC_DIR}/public-docs
- mkdir -p ${PUBLIC_DOCS}
- cp -R docs/_build/html/* ${PUBLIC_DOCS}
## place code coverage docs under: /coverage-docs ##
- npm install
- npm run coverage
- COVERAGE_DOCS=${PUBLIC_DIR}/coverage-docs
- mkdir -p ${COVERAGE_DOCS}
- cp -R coverage/* ${COVERAGE_DOCS}
artifacts:
paths:
- public
only:
- develop
- doc-release-branch
- joes-do-wip
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
publish docs to production:
image: ${CONTAINTHEDOCS_IMAGE}
stage: docs
environment:
name: production
url: https://clouddocs.f5.com/products/extensions/f5-declarative-onboarding/latest
only:
# Currently will only deploy to clouddocs.f5.com on commits to doc-publish
# fill in desired release branch name and uncomment to add deployment from a branch
- docs-latest@automation-toolchain/f5-declarative-onboarding
tags:
- cm-official-docker-executor
needs:
- create_docs
script:
# Publish docs to clouddocs.f5.com (live site).
- publish-product-docs-to-prod extensions/f5-declarative-onboarding/latest
- aws s3 cp versions.json s3://clouddocs.f5.com/products/extensions/f5-declarative-onboarding/versions.json
# create invalidation to clear cloudfront cache
# - aws cloudfront create-invalidation --distribution-id $AWS_DIST --paths /products/extensions/f5-declarative-onboarding