-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy path.gitlab-ci.yml
1890 lines (1788 loc) · 61.9 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
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/pipeline/#customization
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
variables:
#Docker config
DOCKER_AUTH_CONFIG: "{\"auths\":{\"https://index.docker.io/v1/\":{\"auth\":\"$CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD\"}}}"
DOCKER_APP_IMAGE: milmove01/transcom-docker:milmove-app
DOCKER_BASE_IMAGE: milmove01/transcom-docker:base
DOCKERHUB_USERNAME: DOCKERHUB_USERNAME
DOCKERHUB_PASSWORD: DOCKERHUB_PASSWORD
DOCKER_TOKEN: DOCKER_TOKEN
registry: https://registry.hub.docker.com/
#Circle CI need to replace
#CIRCLE_PROJECT_USERNAME: "my-username" # Replace with the actual namespace
CIRCLE_PROJECT_REPONAME: "mymove" # Replace with your GitLab project name
CIRCLE_JOB: "$CI_JOB_NAME" # Map to GitLab's job name variable
CIRCLE_BRANCH: "$CI_COMMIT_BRANCH" # Map to GitLab's branch variable
#CIRCLE_TOKEN: "$GITLAB_API_TOKEN" # GitLab API token for querying pipelines
CIRCLE_BUILD_NUM: "$CI_PIPELINE_ID"
GOPATH: "$CI_PROJECT_DIR/go"
GOLANGCI_LINT_CONCURRENCY: "4"
GOLANGCI_LINT_VERBOSE: "-v"
# Specify the environment: loadtest, demo, exp
DP3_ENV: &dp3_env placeholder_env
# Specify the branch to deploy TODO: this might be not needed. So far useless
DP3_BRANCH: &dp3_branch placeholder_branch_name
# Ignore branches for integration tests
INTEGRATION_IGNORE_BRANCH: &integration_ignore_branch placeholder_branch_name
INTEGRATION_MTLS_IGNORE_BRANCH: &integration_mtls_ignore_branch placeholder_branch_name
CLIENT_IGNORE_BRANCH: &client_ignore_branch placeholder_branch_name
SERVER_IGNORE_BRANCH: &server_ignore_branch placeholder_branch_name
RUNNER_TAG: &runner_tag milmove
DOCKER_RUNNER_TAG: &docker_runner_tag eks_cluster_runner
postgres: &postgres postgres:16.4
#postgres: &postgres postgres:16.4
redis: &redis redis:5.0.6
stages:
- pre_checks
- build
- test
- push
- deploy
- prod_approval
- push_prd
- deploy_prd
#anchors
#set safe directory and path
.setup_milmove_env: &setup_milmove_env
- git config --global --add safe.directory /builds/milmove/mymove
- export PATH=${PATH}:${GOPATH}/bin:~/transcom/mymove/builds/milmove/mymove
- export REACT_APP_ERROR_LOGGING=otel
.announce_failure: &announce_failure
#- if [[ "$CI_COMMIT_BRANCH" == "main" && "$CI_JOB_STATUS" == "failed" ]]; then
- echo $CI_COMMIT_BRANCH
- echo $CI_JOB_STATUS
- echo "Announcing broken branch in GitLab CI"
# fi
.setup_tls_vars_dp3: &setup_tls_vars_dp3
- |
if [[ "$DP3_ENV" == "exp" || "$DP3_ENV" == "loadtest" || "$DP3_ENV" == "demo" ]]; then
export ENV=$(echo ${DP3_ENV} | tr '[:lower:]' '[:upper:]');
export TLS_CERT=$(eval echo \$${ENV}_DP3_CERT);
export TLS_KEY=$(eval echo \$${ENV}_DP3_KEY);
export TLS_CA=$(eval echo \$${ENV}_DP3_CA);
fi
.setup_aws_vars_dp3: &setup_aws_vars_dp3
- |
if [[ "$DP3_ENV" == "exp" || "$DP3_ENV" == "loadtest" || "$DP3_ENV" == "demo" ]]; then
export ENV=$(echo ${DP3_ENV} | tr '[:lower:]' '[:upper:]');
export AWS_DEFAULT_REGION=$(eval echo \$${ENV}_REGION);
export AWS_ACCOUNT_ID=$(eval echo \$${ENV}_ACCOUNT_ID);
export AWS_ACCESS_KEY_ID=$(eval echo \$${ENV}_ACCESS_KEY_ID);
export AWS_SECRET_ACCESS_KEY=$(eval echo \$${ENV}_SECRET_ACCESS_KEY);
fi
.setup_release_dp3: &setup_release_dp3
- |
if [[ "$DP3_ENV" == "exp" || "$DP3_ENV" == "loadtest" || "$DP3_ENV" == "demo" ]]; then
export ENV=$(echo ${DP3_ENV} | tr '[:lower:]' '[:upper:]');
export AWS_DEFAULT_REGION=$(eval echo \$${ENV}_REGION);
export AWS_ACCOUNT_ID=$(eval echo \$${ENV}_ACCOUNT_ID);
export ECR_REPOSITORY_URI=$(echo ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com)
export APP_DOCKER_FILE=Dockerfile.dp3
export TASK_DOCKER_FILE=Dockerfile.tasks_dp3
export APP_ENVIRONMENT=$DP3_ENV
fi
.setup_aws_vars_stg: &setup_aws_vars_stg
- export AWS_DEFAULT_REGION=$STG_REGION
- export AWS_ACCOUNT_ID=$STG_ACCOUNT_ID
- export AWS_ACCESS_KEY_ID=$STG_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$STG_SECRET_ACCESS_KEY
- export SERVICE_RESERVATION_CPU=2048
- export SERVICE_RESERVATION_MEM=4096
.setup_tls_vars_stg: &setup_tls_vars_stg
- export TLS_CERT=$STG_MOVE_MIL_DOD_TLS_CERT
- export TLS_KEY=$STG_MOVE_MIL_DOD_TLS_KEY
- export TLS_CA=$STG_MOVE_MIL_DOD_TLS_CA
.setup_aws_vars_prd: &setup_aws_vars_prd
- export AWS_DEFAULT_REGION=$PRD_REGION
- export AWS_ACCOUNT_ID=$PRD_ACCOUNT_ID
- export AWS_ACCESS_KEY_ID=$PRD_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$PRD_SECRET_ACCESS_KEY
.setup_tls_vars_prd: &setup_tls_vars_prd
- export TLS_CERT=$PRD_MOVE_MIL_DOD_TLS_CERT
- export TLS_KEY=$PRD_MOVE_MIL_DOD_TLS_KEY
- export TLS_CA=$PRD_MOVE_MIL_DOD_TLS_CA
.setup_release_stg: &setup_release_stg
#if main
- export ECR_REPOSITORY_URI=${STG_ACCOUNT_ID}.dkr.ecr.${STG_REGION}.amazonaws.com
- export APP_DOCKER_FILE=Dockerfile.dp3
- export TASK_DOCKER_FILE=Dockerfile.tasks_dp3
#TODO: update demo to stg
- export APP_ENVIRONMENT=demo
.setup_release_prd: &setup_release_prd
#build off prd variables
- export ECR_REPOSITORY_URI=${PRD_ACCOUNT_ID}.dkr.ecr.${PRD_REGION}.amazonaws.com
- export APP_DOCKER_FILE=Dockerfile.dp3
- export TASK_DOCKER_FILE=Dockerfile.tasks_dp3
#TODO: update exp to prod
- export APP_ENVIRONMENT=exp
.kaniko_before_setup: &kaniko_before_setup
# prep login for kaniko
mkdir -p /kaniko/.docker
echo "Simulating Docker image build setup..."
echo "{\"credHelpers\":{\"${ECR_REPOSITORY_URI}\":\"ecr-login\"}}" > /kaniko/.docker/config.json
.check_dp3: &check_dp3
- if: $DP3_ENV == "exp" || $DP3_ENV == "loadtest" || $DP3_ENV == "demo"
.check_main: &check_main
- if: '$CI_COMMIT_BRANCH == "main"'
.check_debug: &check_debug
- if: '$debug == "true"'
.check_integration_ignore_branch: &check_integration_ignore_branch
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == $INTEGRATION_IGNORE_BRANCH'
.check_integration_mtls_ignore_branch: &check_integration_mtls_ignore_branch
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == $INTEGRATION_MTLS_IGNORE_BRANCH'
.check_client_ignore_branch: &check_client_ignore_branch
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == $CLIENT_IGNORE_BRANCH'
.check_server_ignore_branch: &check_server_ignore_branch
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == $SERVER_IGNORE_BRANCH'
.install_yarn: &install_yarn
- |
mkdir -p /builds/milmove/mymove/.cache
mkdir -p /builds/milmove/mymove/.cache/yarn
yarn install --frozen-lockfile --cache-folder /builds/milmove/mymove/.cache/yarn
scripts/check-generated-code yarn.lock
echo "yarn check dependencies"
./scripts/rebuild-dependencies-without-binaries
.yarn_cache: &yarn_cache
key:
files:
- yarn.lock
paths:
- .cache/yarn
policy: pull-push
.go_cache: &go_cache
key:
files:
- go.sum
paths:
- $GOPATH/pkg/mod
- /builds/milmove/mymove/bin
policy: pull-push
.setup_generic_app_env_variables: &setup_generic_app_env_variables
- |
export APPLICATION=app
export DB_PASSWORD=mysecretpassword
export DB_USER_LOW_PRIV=crud
export DB_PASSWORD_LOW_PRIV=mysecretpassword
export DB_USER=postgres
export DB_HOST=localhost
export DB_PORT=5432
export MIGRATION_MANIFEST='/builds/milmove/mymove/migrations/app/migrations_manifest.txt'
export MIGRATION_PATH='file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure'
export EIA_KEY=db2522a43820268a41a802a16ae9fd26
.setup_devseed_env_variables: &setup_devseed_env_variables
- |
export DB_NAME=dev_db
export DB_NAME_DEV=dev_db
export ENVIRONMENT=development
export DOD_CA_PACKAGE=/builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b
.setup_server_env_variables: &setup_server_env_variables
- |
echo "make server_test_build for app"
export LOGIN_GOV_SECRET_KEY=$(echo $E2E_LOGIN_GOV_SECRET_KEY | base64 --decode)
export OKTA_CUST_CLIENT_ID=notrealkey
export OKTA_CUSTOMER_SECRET_KEY=notrealkey
export OKTA_OFFICE_SECRET_KEY=notrealkey1
export OKTA_ADMIN_SECRET_KEY=notrealkey2
export OKTA_TENANT_ORG_URL=test-milmove.okta.mil
export GOTEST_PARALLEL=8
export DB_PORT_TEST=5433
export DB_NAME=test_db
export DB_NAME_TEST=test_db
export DTOD_USE_MOCK='true'
export ENV=test
export ENVIRONMENT=test
export SERVER_REPORT=1
export COVERAGE=1
export SERVE_API_INTERNAL='true'
export OKTA_CUSTOMER_CLIENT_ID=1q2w3e4r5t6y7u8i9o
export OKTA_ADMIN_CLIENT_ID=AQ1SW2DE3FR4G5
export OKTA_OFFICE_CLIENT_ID=9f9f9s8s90gig9
export OKTA_API_KEY=notrealapikey8675309
export OKTA_OFFICE_GROUP_ID=notrealgroupId
export OKTA_CUSTOMER_GROUP_ID=notrealcustomergroupId
# .setup_host_intergration_tests: &setup_host_intergration_tests
# - echo "Setting up /etc/hosts for local domain simulation"
# - echo "127.0.0.1 milmovelocal" | sudo tee -a /etc/hosts
# - echo "127.0.0.1 officelocal" | sudo tee -a /etc/hosts
# - echo "127.0.0.1 adminlocal" | sudo tee -a /etc/hosts
# - echo "127.0.0.1 primelocal" | sudo tee -a /etc/hosts
.setup_env_intergration_mtls: &setup_env_intergration_mtls
- |
echo "Setting up environment variables"
export MIL_MOVE_DOD_CA_CERT=$(cat config/tls/devlocal-ca.pem)
export MIL_MOVE_DOD_TLS_CERT=$(cat config/tls/devlocal-https.pem)
export MIL_MOVE_DOD_TLS_KEY=$(cat config/tls/devlocal-https.key)
export CLIENT_AUTH_SECRET_KEY=$(cat config/tls/devlocal-client_auth_secret.key)
export LOGIN_GOV_SECRET_KEY=$(echo $E2E_LOGIN_GOV_SECRET_KEY | base64 --decode)
export HERE_MAPS_APP_ID=$E2E_HERE_MAPS_APP_ID
export HERE_MAPS_APP_CODE=$E2E_HERE_MAPS_APP_CODE
echo "Overriding application-specific configurations"
sed 's,^,export ,' config/env/review.app.env > server_env
source server_env
export HERE_MAPS_GEOCODE_ENDPOINT=https://geocoder.api.here.com/6.2/geocode.json
export HERE_MAPS_ROUTING_ENDPOINT=https://route.api.here.com/routing/7.2/calculateroute.json
export LOGIN_GOV_CALLBACK_PORT=4000
export LOGIN_GOV_CALLBACK_PROTOCOL=http
make db_dev_create
bin/milmove migrate
mkdir -p build
touch build/index.html
bin/milmove serve 2>&1 | tee server.log &
.e2e_tests_playwright: &e2e_tests_playwright
- |
echo "Preparing the environment"
export MIL_MOVE_DOD_CA_CERT=$(cat config/tls/devlocal-ca.pem)
export MIL_MOVE_DOD_TLS_CERT=$(cat config/tls/devlocal-https.pem)
export MIL_MOVE_DOD_TLS_KEY=$(cat config/tls/devlocal-https.key)
export CLIENT_AUTH_SECRET_KEY=$(cat config/tls/devlocal-client_auth_secret.key)
export LOGIN_GOV_SECRET_KEY=$(echo $E2E_LOGIN_GOV_SECRET_KEY | base64 --decode)
export HERE_MAPS_APP_ID=$E2E_HERE_MAPS_APP_ID
export HERE_MAPS_APP_CODE=$E2E_HERE_MAPS_APP_CODE
sed 's,^,export ,' config/env/review.app.env > server_env
source server_env
make db_dev_create
bin/milmove migrate
bin/milmove serve &
echo "Waiting for server to start"
dockerize -wait http://milmovelocal:4000 -timeout 5m
echo "Installing Playwright dependencies"
yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
./node_modules/.bin/playwright install
sast:
stage: pre_checks
tags:
- $RUNNER_TAG
include:
- template: Jobs/SAST.gitlab-ci.yml
- template: Jobs/Dependency-Scanning.gitlab-ci.yml
- template: Jobs/Secret-Detection.gitlab-ci.yml
anti_virus:
stage: pre_checks
tags:
- $RUNNER_TAG
image: milmove/clamav-ci # Custom image with ClamAV pre-installed
script:
- pwd
- clamscan --version # Verify ClamAV installation
- ls -la $CI_PROJECT_DIR/anti-virus # Debug to confirm whitelist files exist
- cp -v $CI_PROJECT_DIR/anti-virus/whitelist-*.{fp,ign2} /var/lib/clamav/ # Update paths
- echo "Running ClamAV scan..."
- >
clamscan \
--recursive \
--infected \
--detect-pua=yes \
--exclude-pua=NetTool \
--exclude-pua=PWTool \
--max-scansize=300M \
--max-filesize=100M \
--max-recursion=30 \
--max-files=50000 \
--tempdir=/tmp \
$CI_PROJECT_DIR
after_script:
- *announce_failure
rules:
- *check_main
# Prep the public folder for frontend dependency serving
# This is needed for things like pdfjs-dist
prep_server_hosted_client_deps:
stage: pre_checks
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
before_script:
- *setup_milmove_env
script: |
echo "Running prep_server_hosted_client_deps"
./scripts/fetch-react-file-viewer-from-yarn
after_script:
- *announce_failure
artifacts:
paths:
- /builds/milmove/mymove/public
pre_deps_golang:
stage: pre_checks
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
before_script:
- *setup_milmove_env
variables:
KUBERNETES_CPU_REQUEST: "4"
KUBERNETES_MEMORY_REQUEST: "4Gi"
KUBERNETES_MEMORY_LIMIT: "4Gi"
script:
- for i in $(seq 1 5); do go mod download && break || s=$? && sleep 5; done; (exit $s)
- scripts/check-generated-code go.sum
- make bin/swagger
after_script:
- *announce_failure
cache:
- <<: *go_cache
artifacts:
paths:
- /builds/milmove/mymove/bin/
- /builds/milmove/mymove/swagger/
#TODO: Optimization potential
# cache:
# key: "$CI_COMMIT_REF_SLUG-go"
# paths:
# - $GOPATH/pkg/mod
# - /builds/milmove/mymove/bin # Ensure this path is correct and writable.
# Optionally, you can define an after_script for cleanup or notifications.
pre_deps_yarn:
stage: pre_checks
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
before_script:
- *setup_milmove_env
script:
- *install_yarn
cache:
- <<: *yarn_cache
after_script:
- *announce_failure
check_generated_code:
stage: pre_checks
image: $DOCKER_APP_IMAGE # Replace with the appropriate Docker image
needs:
- pre_deps_golang
before_script:
- *setup_milmove_env
script:
- make server_generate mocks_generate
- scripts/check-generated-code pkg/gen/ $(find . -type d -name "*mocks" -exec echo -n '{} ' \;)
after_script:
- *announce_failure
rules:
- *check_debug
check_tls_certificate_dp3:
stage: pre_checks
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE # Replace with your appropriate Docker image.
before_script:
- *setup_aws_vars_dp3
- *setup_tls_vars_dp3
- *announce_failure
script:
# Check if we are using a DP3 environment
- echo "Checking if we are using a DP3 environment at all..."
- |
if [[ $DP3_ENV != "demo" && $DP3_ENV != "exp" && $DP3_ENV != "loadtest" ]]; then
echo "Not a DP3 environment. Skipping TLS checks."
exit 0
fi
- echo "Running TLS pair check..."
- /usr/local/bin/check-tls-pair "${TLS_KEY}" "${TLS_CERT}"
after_script:
- *announce_failure
rules:
- *check_dp3
check_tls_certificate_stg:
stage: pre_checks
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
before_script:
- *setup_aws_vars_stg
- *setup_tls_vars_stg
script:
- echo "Running TLS pair check..."
- /usr/local/bin/check-tls-pair "${TLS_KEY}" "${TLS_CERT}"
after_script:
- *announce_failure
check_tls_certificate_prd:
stage: pre_checks
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
before_script:
- *setup_tls_vars_prd
- *setup_aws_vars_prd
script:
- echo "Running TLS pair check for PRD environment..."
- /usr/local/bin/check-tls-pair "${TLS_KEY}" "${TLS_CERT}"
after_script:
- *announce_failure
build_storybook:
stage: build
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
variables:
KUBERNETES_CPU_REQUEST: "4"
KUBERNETES_MEMORY_REQUEST: "8Gi"
KUBERNETES_MEMORY_LIMIT: "8Gi"
needs:
- pre_deps_yarn
- anti_virus
cache:
- <<: *yarn_cache
policy: pull
before_script:
- *setup_milmove_env
- *install_yarn
script:
- yarn build-storybook
after_script:
- *announce_failure
artifacts:
paths:
- /builds/milmove/mymove/storybook-static
rules:
- *check_main
deploy_storybook_dp3:
stage: deploy
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
needs:
- pre_deps_yarn
- build_storybook
before_script:
- *setup_milmove_env
script:
- echo "TODO Add steps"
- echo "deploy_storybook_dp3"
after_script:
- *announce_failure
artifacts:
paths:
- /builds/milmove/mymove/storybook-static
rules:
- *check_main
compile_app_client:
stage: build
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
cache:
- <<: *yarn_cache
policy: pull
variables:
KUBERNETES_CPU_REQUEST: "6"
KUBERNETES_MEMORY_REQUEST: "8Gi"
KUBERNETES_MEMORY_LIMIT: "8Gi"
before_script:
- *setup_milmove_env
- *install_yarn
needs:
- pre_deps_yarn
script:
- make client_build
artifacts:
paths:
- /builds/milmove/mymove/bin
- /builds/milmove/mymove/build
- playwright
- playwright.config.js
- package.json
- eslint-plugin-ato
expire_in: 1 week
after_script:
- *announce_failure
compile_app_server:
stage: build
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
cache:
- <<: *go_cache
policy: pull
- <<: *yarn_cache
policy: pull
variables:
KUBERNETES_CPU_REQUEST: "6"
KUBERNETES_MEMORY_REQUEST: "6Gi"
KUBERNETES_MEMORY_LIMIT: "8Gi"
needs:
- pre_deps_golang
- pre_deps_yarn
before_script:
- *setup_milmove_env
- *install_yarn
script:
- make -j 4 server_build build_tools
- echo "Skipping server and tools compilation."
artifacts:
paths:
- /builds/milmove/mymove/bin/milmove-tasks
- /builds/milmove/mymove/bin/milmove
- /builds/milmove/mymove/bin/rds-ca-rsa4096-g1.pem
- /builds/milmove/mymove/bin/rds-ca-2019-root.pem
- /builds/milmove/mymove/bin/tls-checker
- /builds/milmove/mymove/bin/health-checker
- /builds/milmove/mymove/bin/*
- /builds/milmove/mymove/bin/ecs-deploy
- /builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b
- /builds/milmove/mymove/config/tls/dod-sw-ca-66.pem
- /builds/milmove/mymove/swagger/*
- /builds/milmove/mymove/build
- pkg/testdatagen/testdata
- /builds/milmove/mymove/config/otel/*
expire_in: 1 week
after_script:
- *announce_failure
#####################################
## Test stages various conditions ##
#####################################
pre_test:
stage: test
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
cache:
- <<: *go_cache
policy: pull
- <<: *yarn_cache
policy: pull
needs:
- pre_deps_golang
- pre_deps_yarn
- check_tls_certificate_stg
- check_tls_certificate_prd
variables:
KUBERNETES_CPU_REQUEST: "4"
KUBERNETES_MEMORY_REQUEST: "6Gi"
KUBERNETES_MEMORY_LIMIT: "6Gi"
before_script: *setup_milmove_env
script:
- export GODEBUG=asyncpreemptoff=1
- echo "Save Baseline Spectral Lint"
- |
[ -d ~/transcom/mymove/spectral ] && cp -r ~/transcom/mymove/spectral /tmp/spectral_baseline || echo "Skipping saving baseline"
- rm -rf ~/transcom/mymove/spectral
- *install_yarn
- echo "Run pre-commit tests without golangci-lint, eslint, or prettier"
- SKIP=golangci-lint,eslint,prettier,ato-go-linter,gomod,appcontext-linter pre-commit run --all-files
- |
echo "Run pre-commit tests with ato-go-linter only"
pre-commit run -v --all-files ato-go-linter
- |
echo "Run pre-commit tests with gomod only"
pre-commit run -v --all-files gomod,appcontext-linter
- |
echo "Run pre-commit tests with appcontext-linter only"
pre-commit run -v --all-files appcontext-linter
- echo "Run pre-commit tests with golangci-lint only"
- |
echo 'export GOLANGCI_LINT_CONCURRENCY=4' >> $BASH_ENV
echo 'export GOLANGCI_LINT_VERBOSE=-v' >> $BASH_ENV
source $BASH_ENV
mkdir -p tmp/test-results/pretest
pre-commit run -v --all-files golangci-lint | tee tmp/test-results/pretest/golangci-lint.out
- echo "Run prettier, eslint, danger checks"
- yarn prettier-ci
- yarn lint
- yarn danger ci --failOnErrors
- echo "Run spectral linter on all files"
- ./scripts/ensure-spectral-lint /tmp/spectral_baseline spectral
- ./scripts/pre-commit-go-mod || exit 0
allow_failure: true
after_script:
- *announce_failure
rules:
- *check_server_ignore_branch
server_test:
stage: test
tags:
- $DOCKER_RUNNER_TAG
image: $DOCKER_APP_IMAGE
needs:
- pre_deps_golang
before_script:
- *setup_milmove_env
- *setup_generic_app_env_variables
- *setup_server_env_variables
services:
- name: docker:dind
alias: docker
- name: $postgres
- name: $redis
variables:
DOCKER_HOST: "tcp://docker-backend.gitlab-runner.svc.cluster.local:2375"
DOCKER_TLS_CERTDIR: ""
APPLICATION: app
# 8 since this runs on xlarge with 8 CPUs
GOTEST_PARALLEL: 8
DB_PASSWORD: mysecretpassword
DB_USER_LOW_PRIV: crud
DB_PASSWORD_LOW_PRIV: mysecretpassword
DB_USER: postgres
DB_HOST: localhost
DB_PORT_TEST: 5433
DB_PORT: 5432
DB_NAME: test_db
DB_NAME_TEST: test_db
DTOD_USE_MOCK: 'true'
MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt'
MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure'
EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16
ENV: test
ENVIRONMENT: test
SERVER_REPORT: 1
COVERAGE: 1
SERVE_API_INTERNAL: 'true'
OKTA_CUSTOMER_CLIENT_ID: 1q2w3e4r5t6y7u8i9o
OKTA_ADMIN_CLIENT_ID: AQ1SW2DE3FR4G5
OKTA_OFFICE_CLIENT_ID: 9f9f9s8s90gig9
OKTA_API_KEY: notrealapikey8675309
OKTA_OFFICE_GROUP_ID: notrealgroupId
OKTA_CUSTOMER_GROUP_ID: notrealcustomergroupId
script:
- psql --version
- for i in $(seq 1 5); do go mod download && break || s=$? && sleep 5; done; (exit $s)
- scripts/check-generated-code go.sum
- make bin/swagger
- echo "server test -- TODO Add steps need to potentially pass job id to file and persist"
- make -j 2 bin/milmove bin/gotestsum
- make server_test for app
# - go install gotest.tools/gotestsum@latest
# - go mod tidy
#- bin/gotestsum --junitfile server_test_report.xml --format server_test
allow_failure: true
artifacts:
paths:
- /builds/milmove/mymove/bin/gotestsum
- /builds/milmove/mymove/tmp/test-results
when: always
reports:
junit: /builds/milmove/mymove/tmp/test-results/gotest/app/go-test-report.xml
after_script:
- *announce_failure
rules:
- *check_server_ignore_branch
server_test_coverage:
stage: test
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
needs:
- pre_deps_golang
- server_test
before_script: *setup_milmove_env
script:
- echo "TODO understand recording stats and PR interaction"
- echo "server test coverage"
- |
echo "Ensure Test Coverage Increasing"
./scripts/ensure-go-test-coverage \
tmp/baseline-go-coverage/go-coverage.txt \
tmp/test-results/gotest/app/go-coverage.txt
allow_failure: true
after_script:
- *announce_failure
rules:
- *check_server_ignore_branch
###may need to rethink the logic and intent of this they save per the following and do some PR interaction
# only save the cache on default branch builds because we only want to
# change the baseline of test results on main builds
#
# Save the new baseline regardless of if the coverage succeeds
# or fails as a merge to main means we have a new baseline. We
# will use other means to measure if our coverage is increasing
client_test:
stage: test
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
variables:
KUBERNETES_CPU_REQUEST: "4"
KUBERNETES_MEMORY_REQUEST: "8Gi"
KUBERNETES_MEMORY_LIMIT: "8Gi"
needs:
- pre_deps_yarn
cache:
- <<: *yarn_cache
policy: pull
before_script:
- *setup_milmove_env
- *install_yarn
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
dependencies:
- pre_deps_yarn
script:
- echo "client test coverage"
- JEST_JUNIT_OUTPUT_DIR=jest-junit-reports yarn test:coverage -results=false >> $CI_PROJECT_DIR/coverage.output
artifacts:
when: always
reports:
junit:
- jest-junit-reports/junit.xml
paths:
- /builds/milmove/mymove/coverage
- /builds/milmove/mymove/jest-junit-reports
after_script:
- *announce_failure
rules:
- *check_client_ignore_branch
client_test_coverage:
stage: test
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
needs:
- pre_deps_yarn
- client_test
before_script: *setup_milmove_env
# TODO: need to add cache for max coverage increase similar to this
# https://stackoverflow.com/questions/54542922/force-coverage-increase-in-gitlab-prs
script:
- echo "TODO understand recording stats and PR interaction"
- |
echo "Ensure Test Coverage Increasing"
./scripts/ensure-js-test-coverage \
tmp/baseline-jest-coverage/clover.xml \
coverage/clover.xml
after_script:
- *announce_failure
rules:
- *check_client_ignore_branch
integration_test_devseed:
stage: test
tags:
- $DOCKER_RUNNER_TAG
image: $DOCKER_APP_IMAGE
services:
- name: docker:dind
alias: docker
- name: $postgres
- name: $redis
variables:
DOCKER_HOST: "tcp://docker-backend.gitlab-runner.svc.cluster.local:2375"
DOCKER_TLS_CERTDIR: ""
APPLICATION: app
DB_PASSWORD: mysecretpassword
DB_USER_LOW_PRIV: crud
DB_PASSWORD_LOW_PRIV: mysecretpassword
DB_USER: postgres
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: dev_db
DB_NAME_DEV: dev_db
MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt'
MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure'
EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16
ENVIRONMENT: development
DOD_CA_PACKAGE: /builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_DB: test_db
needs:
- pre_deps_golang
- prep_server_hosted_client_deps
before_script:
- *setup_milmove_env
- *setup_generic_app_env_variables
- *setup_devseed_env_variables
script:
- echo "integration_test_devseed"
- |
export MOVE_MIL_DOD_CA_CERT=$(cat config/tls/devlocal-ca.pem)
export MOVE_MIL_DOD_TLS_CERT=$(cat config/tls/devlocal-https.pem)
export MOVE_MIL_DOD_TLS_KEY=$(cat config/tls/devlocal-https.key)
- make db_dev_fresh
allow_failure: true
after_script:
- *announce_failure
rules:
- *check_integration_ignore_branch
integration_tests:
stage: test
tags:
- $RUNNER_TAG
image: $DOCKER_APP_IMAGE
needs:
- pre_deps_yarn
- pre_deps_golang
- compile_app_client
- compile_app_server
- integration_test_my
- integration_test_office
- integration_test_admin
- integration_test_devseed
before_script: *setup_milmove_env
script:
- echo "TODO Add steps"
- echo "integration_tests"
allow_failure: true
after_script:
- *announce_failure
rules:
- *check_integration_ignore_branch
integration_test_mtls:
stage: test
tags:
- $DOCKER_RUNNER_TAG
image: $DOCKER_APP_IMAGE
services:
- name: docker:dind
alias: docker
- name: $postgres
- name: $redis
variables:
DOCKER_HOST: "tcp://docker-backend.gitlab-runner.svc.cluster.local:2375"
DOCKER_TLS_CERTDIR: ""
APPLICATION: app
DB_PASSWORD: mysecretpassword
DB_USER_LOW_PRIV: crud
DB_PASSWORD_LOW_PRIV: mysecretpassword
DB_USER: postgres
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: dev_db
DB_NAME_DEV: dev_db
MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt'
MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure'
EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16
ENVIRONMENT: development
DOD_CA_PACKAGE: /builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_DB: test_db
needs:
- pre_deps_yarn
- compile_app_server
before_script:
- *setup_milmove_env
- *setup_env_intergration_mtls
script:
- echo "TODO Add steps"
- echo "integration_test_mtls"
- echo "Waiting for server to start"
- dockerize -wait http://milmovelocal:4000 -timeout 5m
- echo "Running E2E mTLS tests"
- ./scripts/run-e2e-mtls-test
artifacts:
paths:
- test-results/
when: always
allow_failure: true
after_script:
- *announce_failure
rules:
- *check_integration_mtls_ignore_branch
integration_test_admin:
stage: test
tags:
- $DOCKER_RUNNER_TAG
image: $DOCKER_APP_IMAGE
services:
- name: docker:dind
alias: docker
- name: $postgres
- name: $redis
variables:
DOCKER_HOST: "tcp://docker-backend.gitlab-runner.svc.cluster.local:2375"
DOCKER_TLS_CERTDIR: ""
APPLICATION: app
DB_PASSWORD: mysecretpassword
DB_USER_LOW_PRIV: crud
DB_PASSWORD_LOW_PRIV: mysecretpassword
DB_USER: postgres
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: dev_db
DB_NAME_DEV: dev_db
MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt'
MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure'
EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16
ENVIRONMENT: development
DOD_CA_PACKAGE: /builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_DB: test_db
needs:
- pre_deps_yarn
- pre_deps_golang
- compile_app_client
- compile_app_server
before_script:
- *setup_milmove_env
- *e2e_tests_playwright
script:
- echo "TODO Add steps"
- echo "integration_test_admin"
- echo "Running integration tests for Admin"
- ./node_modules/.bin/playwright test playwright/tests/admin \
--reporter=html,junit \
--trace=on \
--workers=1
artifacts:
paths:
- playwright-report/
- complete-playwright-report.zip
- playwright-results.xml
when: always
allow_failure: true
after_script:
- *announce_failure
rules:
- *check_integration_ignore_branch
integration_test_my:
stage: test
tags:
- $DOCKER_RUNNER_TAG
image: $DOCKER_APP_IMAGE
services:
- name: docker:dind
alias: docker