-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
913 lines (865 loc) · 28.5 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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/node:8
variables:
GIT_SECRETS_VERSION: "1.3.0"
GIT_SECRETS_PKG_URL: "https://github.com/awslabs/git-secrets/archive/${GIT_SECRETS_VERSION}.tar.gz"
ARTIFACTORY_SERVER: "$ARTIFACTORY_SERVER"
ATG_IMG_REGISTRY_URL: ${ARTIFACTORY_SERVER}/dockerhub-remote
DOCS_BUILD_DIR: "docs/_build/html"
POSTMAN_EXAMPLES: "postman-collection"
MONGO_INITDB_ROOT_PASSWORD: root
MONGO_INITDB_ROOT_USERNAME: root
DT_IMAGE_V3: ${ARTIFACTORY_SERVER}/ecosystems-cloudsolutions-docker-dev/deployment-tool-v3:latest
# azure vars - normalize env var options between ansible and terraform
AZURE_TENANT: "$AZURE_TENANT_ID"
AZURE_SECRET: "$AZURE_CLIENT_SECRET"
ARM_CLIENT_ID: "$AZURE_CLIENT_ID"
ARM_CLIENT_SECRET: "$AZURE_CLIENT_SECRET"
ARM_SUBSCRIPTION_ID: "$AZURE_SUBSCRIPTION_ID"
ARM_TENANT_ID: "$AZURE_TENANT_ID"
# aws vars
AWS_ACCESS_KEY_ID: "$AWS_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY: "$AWS_SECRET_ACCESS_KEY"
AWS_DEFAULT_REGION: "$AWS_DEFAULT_REGION"
# gcp vars
GOOGLE_CREDENTIALS: "$GOOGLE_CREDENTIALS"
GOOGLE_PROJECT_ID: "$GOOGLE_PROJECT_ID"
# debug vars
F5_SDK_LOG_LEVEL: "INFO"
F5_DISABLE_CERT_VERIFY: "true"
PYTHONWARNINGS: "ignore:Unverified HTTPS request"
SEC_TOML_BRANCH: main
stages:
- check_content
- atg-shared-checks
- test
- build_package
- test_functional_init
- test_functional_execute
- test_functional_cleanup
- build_api_docs_and_postman_collection
- build_docs
- publish
include:
- project: automation-toolchain/atg-shared-templates
file: security/base.gitlab-ci.yml
.helpers: &helpers |
function validate () {
"$@"
if [[ $? -ne 0 ]]; then exit 1; fi
}
before_script:
- *helpers
- mkdir ~/.docker
- echo "${DOCKER_AUTH_CONFIG}" > ~/.docker/config.json
# check for disallowed content within any file in source control, this
# supplements the native pre-receive push rules built into GitLab for secrets
# note: .gitallowed is used for exceptions
check_content:
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/node:11
stage: check_content
script:
# install git-secrets
- curl -q -L -o git_secrets.tar.gz ${GIT_SECRETS_PKG_URL}
- tar xzf git_secrets.tar.gz
- cd git-secrets-${GIT_SECRETS_VERSION} && make install && cd ..
# now, add any patterns to disallow
- git secrets --add '.*f5.*\.com'
# scan
- git secrets --scan
tags:
- cm-official-docker-executor
# test package
test_package:
stage: test
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/node:14
except:
variables:
- $CI_COMMIT_REF_NAME == "docs_production"
- $CI_COMMIT_REF_NAME == "docs_staging"
script:
- apt-get update && apt-get install -y jq && npm install
# linter
- npm run lint
# unit tests
- npm run test
tags:
- cm-official-docker-executor
# audit packages for vulnerabilities
test_audit:
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/node:14
stage: test
except:
variables:
- $CI_COMMIT_REF_NAME == "docs_production"
- $CI_COMMIT_REF_NAME == "docs_staging"
script:
# npm audit - uses custom audit processor wrapper
- npm install --unsafe-perm
- npm run audit
tags:
- cm-official-docker-executor
artifacts:
name: audit_report
paths:
- .auditReport.json
expire_in: 1 month
# job must be called coverage
coverage:
stage: test
script:
- apt-get update && apt-get install -y jq && npm install
# unit tests + coverage report
- npm run test && npm run check && npm run report
tags:
- cm-official-docker-executor
artifacts:
name: ${CI_COMMIT_REF_NAME}_unittests_coverage
paths:
- coverage
expire_in: 1 month
only:
- develop
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
- $PUBLISH_RPM_DEVELOP == "true"
when: manual
build_package:
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/node:14
stage: build_package
except:
variables:
- $CI_COMMIT_REF_NAME == "docs_production"
- $CI_COMMIT_REF_NAME == "docs_staging"
script:
- echo 'CI BUILD'
# install packages: jq
- apt-get update
- apt-get install -y jq
- apt-get install -y rpm
# build RPM, handles dependency installation, etc.
- bash ./scripts/build_rpm.sh
tags:
- cm-official-docker-executor
artifacts:
name: f5-cloud-failover-$CI_BUILD_REF
paths:
- dist
expire_in: 1 month
### Functional Tests Section
# Functional Tests - Initialization phase (with 1 retries in a case of any failures)
.test-install:
stage: test_functional_init
image: $DT_IMAGE_V3
services:
- alias: mongo
name: ${ARTIFACTORY_SERVER}/dockerhub-remote/mongo:4.0-xenial
tags:
- azure-autoscale-runner
script:
- deployment-tool create ci-$CI_JOB_ID --plan $PLAN $PARAMETERS
- deployment-tool database export --uri "mongodb://root:root@mongo:27017/porter?authSource=admin" --destination ./deployment/
- deployment-tool describe ci-$CI_JOB_ID
- deployment-tool get ci-$CI_JOB_ID --output-format json | jq > ./deployment/deployment_info.json
- cat ./deployment/deployment_info.json | jq
- echo "ci-$CI_JOB_ID" > ./deployment/name.txt
only:
variables:
- $CI_COMMIT_REF_NAME == "master"
- $CI_COMMIT_REF_NAME == "develop"
- $RUN_FUNCTIONAL_TESTS == "true"
# tier 1 tests 2 NIC AWS across-net and 3 NIC Azure, GCP
- $TESTS_TIER == "1"
# tier 2 tests 2 NIC AWS same-net and all 1 NIC tests for Azure, GCP, AWS
- $TESTS_TIER == "2"
# run all tests
- $TESTS_TIER == "all"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
artifacts:
paths:
- ./deployment
when: always
expire_in: 1 month
# init functional tests: azure
test_functional_init_azure:
extends: .test-install
variables:
PLAN: "azure_bigip_classic_ha"
PARAMETERS: "--param location=westus2 --param bigip_version=17.1.103000"
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "aws"
- $CF_ENV_CLOUD == "gcp"
- $RUN_FUNCTIONAL_TESTS == "false"
# init functional tests: azure - 1nic
test_functional_init_azure_1nic:
extends: .test-install
variables:
PLAN: "azure_bigip_classic_ha"
PARAMETERS: "--param nic_count=1 --param location=westus2 --param bigip_version=16.1.401053"
when: manual
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "aws"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
- $RUN_FUNCTIONAL_TESTS == "false"
# init functional tests: aws - across network topology
test_functional_init_aws_across_net:
extends: .test-install
variables:
PLAN: "aws_bigip_classic_ha"
PARAMETERS: "--param region=us-west-2"
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $RUN_FUNCTIONAL_TESTS == "false"
# init functional tests: aws - across network topology for 1nic
test_functional_init_aws_across_net_1nic:
extends: .test-install
variables:
PLAN: "aws_bigip_classic_ha"
PARAMETERS: "--param region=us-west-2 --param nic_count=1"
when: manual
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
- $RUN_FUNCTIONAL_TESTS == "false"
# init functional tests: aws - same network topology in us-west-2
test_functional_init_aws:
extends: .test-install
variables:
PLAN: "aws_bigip_classic_ha"
PARAMETERS: "--param region=us-west-2 --param use_availability_zones=false"
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
- $RUN_FUNCTIONAL_TESTS == "false"
# init functional tests: aws - same network topology for 1nic
test_functional_init_aws_1nic:
extends: .test-install
variables:
PLAN: "aws_bigip_classic_ha"
PARAMETERS: "--param region=us-west-2 --param use_availability_zones=false --param nic_count=1"
when: manual
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
- $RUN_FUNCTIONAL_TESTS == "false"
# init functional tests: gcp
test_functional_init_gcp:
extends: .test-install
variables:
PLAN: "gcp_bigip_classic_ha"
PARAMETERS: "--param region=us-west1 --param bigip_version=f5-bigip-17-1-1-0-2-6-payg-best-plus-25mbps-231101130547"
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "aws"
- $RUN_FUNCTIONAL_TESTS == "false"
# init functional tests: gcp no forwarding
test_functional_init_gcp_no_forwarding:
extends: .test-install
variables:
PLAN: "gcp_bigip_classic_ha"
PARAMETERS: "--param region=us-west1 --param use_forwarding_rule=false --param bigip_version=f5-bigip-17-1-1-0-2-6-payg-best-plus-25mbps-231101130547"
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "aws"
- $RUN_FUNCTIONAL_TESTS == "false"
# Functional Tests - Execute phase (with no retries)
.test_functional_execute_generic:
stage: test_functional_execute
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/python:3.7
retry: 1
script:
# install jq
- apt-get update
- apt-get install -y jq openssh-client sshpass
# create ssh key
- echo "*** Configuring SSH"
- eval $(ssh-agent -s)
- echo "$SSH_KEY" | sed 's/\\n/\n/g' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
# install node (and package dependencies)
- curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
- nvm install 14 && nvm use 14
- npm install --unsafe-perm
# copying artifacts inherited from functional_test_init target to root directory
- cp -a deployment/. .
- cat deployment_info.json | jq
# proactively restarting rest services
- export USERNAME=$(cat deployment_info.json | jq .instances[0].admin_username -r) && echo "USERNAME is ${USERNAME}"
- export PASSWORD=$(cat deployment_info.json | jq .instances[0].admin_password -r) && echo "PASSWORD is ${PASSWORD}"
- export MGMT_IP_1=$(cat deployment_info.json | jq .instances[0].mgmt_address -r) && echo "MGMT_IP_1 is ${MGMT_IP_1}"
- export MGMT_IP_2=$(cat deployment_info.json | jq .instances[1].mgmt_address -r) && echo "MGMT_IP_2 is ${MGMT_IP_2}"
- sshpass -p $PASSWORD ssh -o StrictHostKeyChecking=no $USERNAME@$MGMT_IP_1 "bigstart restart restnoded restjavad"
- sshpass -p $PASSWORD ssh -o StrictHostKeyChecking=no $USERNAME@$MGMT_IP_2 "bigstart restart restnoded restjavad"
- sleep 30
# executing fuctional test
- validate npm run functional-test
tags:
- cm-official-docker-executor
only:
variables:
- $CI_COMMIT_REF_NAME == "master"
- $CI_COMMIT_REF_NAME == "develop"
- $RUN_FUNCTIONAL_TESTS == "true"
- $TESTS_TIER == "1"
- $TESTS_TIER == "2"
- $TESTS_TIER == "all"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "false"
artifacts:
paths:
- logs
when: always
expire_in: 1 month
# run functional tests: azure
test_functional_execute_azure:
extends: .test_functional_execute_generic
dependencies:
- test_functional_init_azure
- build_package
needs:
- test_functional_init_azure
- build_package
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "aws"
- $CF_ENV_CLOUD == "gcp"
# run functional tests: azure 1 nic
test_functional_execute_azure_1nic:
extends: .test_functional_execute_generic
dependencies:
- test_functional_init_azure_1nic
- build_package
needs:
- test_functional_init_azure_1nic
- build_package
when: manual
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "aws"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
# run functional tests: aws - across network topology
test_functional_execute_aws_across_net:
extends: .test_functional_execute_generic
dependencies:
- test_functional_init_aws_across_net
- build_package
needs:
- test_functional_init_aws_across_net
- build_package
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
# run functional tests: aws - across network topology for 1nic
test_functional_execute_aws_across_net_1nic:
extends: .test_functional_execute_generic
dependencies:
- test_functional_init_aws_across_net_1nic
- build_package
needs:
- test_functional_init_aws_across_net_1nic
- build_package
when: manual
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
# run functional tests: aws - same network topology
test_functional_execute_aws:
extends: .test_functional_execute_generic
dependencies:
- test_functional_init_aws
- build_package
needs:
- test_functional_init_aws
- build_package
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
# run functional tests: aws - same network topology for 1nic
test_functional_execute_aws_1nic:
extends: .test_functional_execute_generic
dependencies:
- test_functional_init_aws_1nic
- build_package
needs:
- test_functional_init_aws_1nic
- build_package
when: manual
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
# run functional tests: gcp with forwarding rule
test_functional_execute_gcp:
extends: .test_functional_execute_generic
dependencies:
- test_functional_init_gcp
- build_package
needs:
- test_functional_init_gcp
- build_package
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "aws"
# run functional tests: gcp without forwarding rules
test_functional_execute_gcp_no_forwarding:
extends: .test_functional_execute_generic
dependencies:
- test_functional_init_gcp_no_forwarding
- build_package
needs:
- test_functional_init_gcp_no_forwarding
- build_package
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "aws"
# Functional Tests - Cleanup phase (executes always with 1 retry in a case of any failures)
.test-uninstall:
stage: test_functional_cleanup
image: $DT_IMAGE_V3
retry: 1
when: always
services:
- alias: mongo
name: ${ARTIFACTORY_SERVER}/dockerhub-remote/mongo:4.0-xenial
tags:
- azure-autoscale-runner
script:
- mkdir -p /deployment-tool/deployment && cp -a ./deployment/. /deployment-tool/deployment
- deployment-tool database import --uri "mongodb://root:root@mongo:27017/porter?authSource=admin" --backup-path ./deployment/porter
- deployment-tool delete $(cat ./deployment/name.txt)
only:
variables:
- $CI_COMMIT_REF_NAME == "master"
- $CI_COMMIT_REF_NAME == "develop"
- $RUN_FUNCTIONAL_TESTS == "true"
- $TESTS_TIER == "1"
- $TESTS_TIER == "2"
- $TESTS_TIER == "all"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "false"
allow_failure: true
# run functional tests: azure
test_functional_cleanup_azure:
extends: .test-uninstall
variables:
PLAN: "azure_bigip_classic_ha"
dependencies:
- test_functional_init_azure
- test_functional_execute_azure
needs:
- test_functional_init_azure
- test_functional_execute_azure
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "aws"
- $CF_ENV_CLOUD == "gcp"
# run functional tests: azure_1nic
test_functional_cleanup_azure_1nic:
extends: .test-uninstall
variables:
PLAN: "azure_bigip_classic_ha"
dependencies:
- test_functional_init_azure_1nic
- test_functional_execute_azure_1nic
needs:
- test_functional_init_azure_1nic
- test_functional_execute_azure_1nic
when: manual
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "aws"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
# run functional tests: aws - across network topology
test_functional_cleanup_aws_across_net:
extends: .test-uninstall
variables:
PLAN: "aws_bigip_classic_ha"
dependencies:
- test_functional_init_aws_across_net
- test_functional_execute_aws_across_net
needs:
- test_functional_init_aws_across_net
- test_functional_execute_aws_across_net
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
# run functional tests: aws - across network topology for 1nic
test_functional_cleanup_aws_across_net_1nic:
extends: .test-uninstall
variables:
PLAN: "aws_bigip_classic_ha"
dependencies:
- test_functional_init_aws_across_net_1nic
- test_functional_execute_aws_across_net_1nic
needs:
- test_functional_init_aws_across_net_1nic
- test_functional_execute_aws_across_net_1nic
when: manual
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
# run functional tests: aws - same network topology
test_functional_cleanup_aws:
extends: .test-uninstall
variables:
PLAN: "aws_bigip_classic_ha"
dependencies:
- test_functional_init_aws
- test_functional_execute_aws
needs:
- test_functional_init_aws
- test_functional_execute_aws
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
# run functional tests: aws - same network topology for 1nic
test_functional_cleanup_aws_1nic:
extends: .test-uninstall
variables:
PLAN: "aws_bigip_classic_ha"
dependencies:
- test_functional_init_aws_1nic
- test_functional_execute_aws_1nic
needs:
- test_functional_init_aws_1nic
- test_functional_execute_aws_1nic
when: manual
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "gcp"
- $CI_COMMIT_MESSAGE =~ /smart:run_functional_tests/
# run functional tests: gcp
test_functional_cleanup_gcp:
extends: .test-uninstall
variables:
PLAN: "gcp_bigip_classic_ha"
dependencies:
- test_functional_init_gcp
- test_functional_execute_gcp
needs:
- test_functional_init_gcp
- test_functional_execute_gcp
except:
variables:
- $TESTS_TIER == "2"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "aws"
# run functional tests: gcp no forwarding rule
test_functional_cleanup_gcp_no_forwarding:
extends: .test-uninstall
variables:
PLAN: "gcp_bigip_classic_ha"
dependencies:
- test_functional_init_gcp_no_forwarding
- test_functional_execute_gcp_no_forwarding
needs:
- test_functional_init_gcp_no_forwarding
- test_functional_execute_gcp_no_forwarding
except:
variables:
- $TESTS_TIER == "1"
- $CF_ENV_CLOUD == "azure"
- $CF_ENV_CLOUD == "aws"
### End of Functional Tests
build_api_docs:
stage: build_api_docs_and_postman_collection
script:
# install packages
- npm install
# generate docs
- npm run make-api-docs
- mkdir apidocs && mv redoc-static.html apidocs/index.html
tags:
- docker-executor
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
artifacts:
name: docs
paths:
- apidocs
expire_in: 1 month
build_postman_collection:
stage: build_api_docs_and_postman_collection
script:
# install packages
- npm install
# generate postman-collection
- npm run make-postman-collection
tags:
- docker-executor
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
artifacts:
name: ${POSTMAN_EXAMPLES}
paths:
- examples
expire_in: 1 month
build_docs:
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/f5devcentral/containthedocs:latest
stage: build_docs
script:
# generate docs
- if [ "$CI_COMMIT_REF_NAME" = "docs_staging" ] || [ "$CI_COMMIT_REF_NAME" = "docs_production" ] || [ "$CI_COMMIT_REF_NAME" = "master" ]; then
- rm -rf docs/_templates
- fi
- make html
# overwrite apidocs html in generated docs folder
- API_DOCS_INDEX=${DOCS_BUILD_DIR}/userguide/apidocs.html
- cp apidocs/index.html ${API_DOCS_INDEX}
tags:
- docker-executor
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
artifacts:
name: docs
paths:
- ${DOCS_BUILD_DIR}
expire_in: 1 month
publish_dev_to_artifactory:
stage: publish
only:
variables:
- $CI_COMMIT_REF_NAME == "develop"
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
tags:
- cm-official-docker-executor
script:
- RPM_FILE=$(ls dist/new_build/*.rpm)
- RPM_NAME=$(basename $RPM_FILE)
- URL=${ARTIFACTORY_BASE_URL}/ecosystems-f5-cloud-failover-rpm/develop-${RPM_NAME}
- echo "Uploading RPM"
- >-
UPLOAD_RESULT=$(curl -H "Authorization: Bearer ${ARTIFACTORY_BEARER_TOKEN}" -X PUT --data-binary @${RPM_FILE} ${URL})
- if [[ $? -eq 0 ]] && [[ "$UPLOAD_RESULT" == *created* ]]; then echo "Upload complete"; else echo "Upload failed"; exit 1; fi
- echo $UPLOAD_RESULT
- POSTMAN_COLLECTION_FILE=$(ls examples/postmanCollection.json)
- URL=${ARTIFACTORY_BASE_URL}/ecosystems-f5-cloud-failover-rpm/develop-${POSTMAN_EXAMPLES}
- echo "Uploading Postman Collection and Examples"
- >-
UPLOAD_RESULT=$(curl -H "Authorization: Bearer ${ARTIFACTORY_BEARER_TOKEN}" -X PUT --data-binary @${POSTMAN_COLLECTION_FILE} ${URL})
- if [[ $? -eq 0 ]] && [[ "$UPLOAD_RESULT" == *created* ]]; then echo "Upload complete"; else echo "Upload failed"; exit 1; fi
- echo $UPLOAD_RESULT
publish_release_to_artifactory:
stage: publish
only:
variables:
- $CI_COMMIT_REF_NAME == "master"
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
tags:
- cm-official-docker-executor
script:
- RPM_FILE=$(ls dist/new_build/*.rpm)
- RPM_NAME=$(basename $RPM_FILE)
- URL=${ARTIFACTORY_BASE_URL}/ecosystems-f5-cloud-failover-rpm/${RPM_NAME}
- >-
UPLOAD_RESULT=$(curl -H "Authorization: Bearer ${ARTIFACTORY_BEARER_TOKEN}" -X PUT --data-binary @${RPM_FILE} ${URL})
- if [[ $? -eq 0 ]] && [[ "$UPLOAD_RESULT" == *created* ]]; then echo "Upload complete"; else echo "Upload failed"; exit 1; fi
- echo $UPLOAD_RESULT
# Publish pre-release RPMs to CDN
publish_dev_cdn:
stage: publish
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/node:14
only:
variables:
- $CI_COMMIT_REF_NAME == "develop"
- $PUBLISH_RPM_DEVELOP == "true"
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
script:
- apt-get update
- apt-get install -y jq
- VERSION=$(cat package.json | jq -r ".version")
- echo "Version:${VERSION}"
- CDN_FOLDER="f5-cloud-failover-extension"
- AUTH_OPTS="--username ${CDN_SVC_ACCOUNT_USER} --password ${CDN_SVC_ACCOUNT_PWD} --non-interactive"
- svn co ${F5_CDN_SVN_ROOT}/cloudsolutions/${CDN_FOLDER} ${AUTH_OPTS}
- mkdir -p ${CDN_FOLDER}/develop/v${VERSION}
- cp -r dist/new_build/* ${CDN_FOLDER}/develop/v${VERSION}
- cd ${CDN_FOLDER}/develop
- status=$(svn status)
- echo "$status"
- if echo "$status" | grep -F '?'; then svn add --force v${VERSION}; else echo "No new directory to add"; fi
- changed_files_count=$(svn diff --summarize | wc -l)
- echo "$changed_files_count"
- if [[ $changed_files_count -ge 1 ]]; then svn add --force v${VERSION}/*; svn commit -m "F5 automation templates project automation - ${CI_COMMIT_REF_NAME}" ${AUTH_OPTS}; else echo "RPM files unchanged"; fi
tags:
- cm-official-docker-executor
allow_failure: true
# Create release on Github
publish_to_github:
stage: publish
only:
- /(^publish-v(\d+\.){1,2}(\d)-(\d+)?$)/
script:
- apt-get update
- apt-get install -y jq
- bash ./scripts/publish_github.sh
# publish docs to internal pages: - this job MUST be named 'pages'
pages:
stage: publish
environment:
name: staging
url: https://${CI_PROJECT_NAMESPACE}.${PAGES_DOMAIN}/${CI_PROJECT_NAME}
script:
- 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_DIR}/* ${PUBLIC_DOCS}
#### place API docs under: /api-docs ####
- API_DOCS=${PUBLIC_DIR}/api-docs
- mkdir -p ${API_DOCS}
- cp -R apidocs/* ${API_DOCS}
#### place code coverage docs under: /coverage-docs ####
- COVERAGE_DOCS=${PUBLIC_DIR}/coverage
- mkdir -p ${COVERAGE_DOCS}
- cp -R coverage/* ${COVERAGE_DOCS}
#### place code contribution docs (mainly for presentation) under: /contribute-docs ####
- CONTRIBUTE_DOCS=${PUBLIC_DIR}/contribute-docs
- CONTRIBUTE_DIR=contributing
# install presentation site dependencies
- cd ${CONTRIBUTE_DIR} && npm install && cd ..
- mkdir -p ${CONTRIBUTE_DOCS}
- cp -R ${CONTRIBUTE_DIR}/* ${CONTRIBUTE_DOCS}
# make relative links absolute - this could be better...
# ![diagram](../test/README.md) -> ![diagram](https://base.url/../test/README.md)
- BASE_URL_FOR_LINKS=${CI_PROJECT_URL}/tree/${CI_COMMIT_REF_NAME}/${CONTRIBUTE_DIR}/
- README=${CONTRIBUTE_DOCS}/README.md
# make absolute URL(s) for relative URL(s) outside current directory '../'
- sed -i -E 's/\[.*\]\(\.\./&SED_TEMP/' ${README} && sed -i "s|..SED_TEMP|${BASE_URL_FOR_LINKS}..|" ${README}
tags:
- cm-official-docker-executor
artifacts:
paths:
- public
expire_in: 1 month
only:
- develop
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
- $PUBLISH_RPM_DEVELOP == "true"
when: manual
# Publish docs to clouddocs.f5networks.com
docs to staging:
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/f5devcentral/containthedocs:latest
stage: publish
environment:
name: stage
url: https://clouddocs.f5networks.net/products/extensions/f5-cloud-failover/latest
only:
variables:
# Currently will only deploy to clouddocs.f5networks.com on commits to develop branch
- $CI_COMMIT_REF_NAME == "develop"
- $CI_COMMIT_REF_NAME == "docs_staging"
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
- $PUBLISH_RPM_DEVELOP == "true"
tags:
- cm-official-docker-executor
dependencies:
- build_docs
script:
- aws configure set aws_access_key_id $DOCS_AWS_ACCESS_KEY_ID --profile=docs
- aws configure set aws_secret_access_key $DOCS_AWS_SECRET_ACCESS_KEY --profile=docs
# Uncomment and set to create desired version format
- aws s3 sync ${DOCS_BUILD_DIR} s3://clouddocs.f5networks.net/products/extensions/f5-cloud-failover/latest --profile=docs
# create invalidation to clear cloudfront cache
- aws cloudfront create-invalidation --distribution-id $AWS_DIST_STAGE --paths /products/extensions/f5-cloud-failover/latest --profile=docs
# Publish docs to clouddocs.f5.com
docs to production:
image: ${ARTIFACTORY_SERVER}/dockerhub-remote/f5devcentral/containthedocs:latest
stage: publish
environment:
name: production
url: https://clouddocs.f5.com/products/extensions/f5-cloud-failover/latest
only:
variables:
# Currently will only deploy to clouddocs.f5.com on commits to master and docs_production branch
# note: master should be added here when ready to publish externally
- $CI_COMMIT_REF_NAME == "master"
- $CI_COMMIT_REF_NAME == "docs_production"
except:
variables:
- $RUN_FUNCTIONAL_TESTS == "true"
- $PUBLISH_RPM_DEVELOP == "true"
tags:
- cm-official-docker-executor
dependencies:
- build_docs
script:
- aws configure set aws_access_key_id $DOCS_AWS_ACCESS_KEY_ID --profile=docs
- aws configure set aws_secret_access_key $DOCS_AWS_SECRET_ACCESS_KEY --profile=docs
# Uncomment and set to create desired version format
- aws s3 sync ${DOCS_BUILD_DIR} s3://clouddocs.f5.com/products/extensions/f5-cloud-failover/latest --profile=docs
# create invalidation to clear cloudfront cache
- aws cloudfront create-invalidation --distribution-id $AWS_DIST --paths /products/extensions/f5-cloud-failover/latest --profile=docs