-
Notifications
You must be signed in to change notification settings - Fork 26
/
config.yml
1087 lines (1024 loc) · 35.1 KB
/
config.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
# CircleCI v2.1 Config
version: 2.1
##
# orbs
#
# Orbs used in this pipeline
###
orbs:
anchore: anchore/anchore-engine@1.9.0 # Ref: https://circleci.com/developer/orbs/orb/anchore/anchore-engine
slack: circleci/slack@4.12.5 # Ref: https://github.com/mojaloop/ci-config/tree/master/slack-templates
pr-tools: mojaloop/pr-tools@0.1.10 # Ref: https://github.com/mojaloop/ci-config/
gh: circleci/github-cli@2.1.0 # Ref: https://github.com/CircleCI-Public/github-cli-orb
nx: nrwl/nx@1.6.0 # Ref: https://github.com/nrwl/nx-orb
##
# defaults
#
# YAML defaults templates
##
## Default 'default-docker' executor dependencies
defaults_docker_Dependencies: &defaults_docker_Dependencies |
apk --no-cache add coreutils
apk --no-cache add util-linux pciutils usbutils coreutils binutils findutils grep iproute2
apk --no-cache add git
apk --no-cache add ca-certificates
apk --no-cache add curl
apk --no-cache add openssh-client
apk --no-cache add bash bash-doc bash-completion
apk --no-cache add -t build-dependencies make gcc g++ python3 libtool autoconf automake
apk --no-cache add librdkafka-dev
## Default 'default-machine' executor dependencies
defaults_machine_Dependencies: &defaults_machine_Dependencies |
## Add Package Repos
## Ref: https://docs.confluent.io/platform/current/installation/installing_cp/deb-ubuntu.html#get-the-software
wget -qO - https://packages.confluent.io/deb/7.4/archive.key | sudo apt-key add -
sudo add-apt-repository -y "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
## Install deps
sudo apt install -y librdkafka-dev
defaults_YarnConfig: &defaults_YarnConfig |
## Example configs that could be applied here
# yarn config set unsafe-perm true
# yarn global add node-gyp
echo "This is placeholder...Nothing to do here!"
defaults_awsCliDependencies: &defaults_awsCliDependencies |
apk --no-cache add aws-cli
defaults_license_scanner: &defaults_license_scanner
name: Install and set up license-scanner
command: |
git clone https://github.com/mojaloop/license-scanner /tmp/license-scanner
cd /tmp/license-scanner && make build default-files set-up
defaults_export_version_from_package: &defaults_export_version_from_package
name: Format the changelog into the github release body and get release tag
command: |
git diff --no-indent-heuristic master~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes
echo 'export RELEASE_CHANGES=`cat /tmp/changes`' >> $BASH_ENV
echo 'export RELEASE_TAG=`cat package.json | jq -r .version`' >> $BASH_ENV
defaults_configure_git: &defaults_configure_git
name: Configure git
command: |
git config user.email ${GIT_CI_EMAIL}
git config user.name ${GIT_CI_USER}
defaults_configure_nvmrc: &defaults_configure_nvmrc
name: Configure NVMRC
command: |
if [ -z "$NVMRC_VERSION" ]; then
echo "==> Configuring NVMRC_VERSION!"
export ENV_DOT_PROFILE=$HOME/.profile
touch $ENV_DOT_PROFILE
export NVMRC_VERSION=$(cat $CIRCLE_WORKING_DIRECTORY/.nvmrc)
echo "export NVMRC_VERSION=$NVMRC_VERSION" >> $ENV_DOT_PROFILE
fi
echo "NVMRC_VERSION=$NVMRC_VERSION"
defaults_configure_nvm: &defaults_configure_nvm
name: Configure NVM
command: |
cd $HOME
export ENV_DOT_PROFILE=$HOME/.profile
touch $ENV_DOT_PROFILE
echo "1. Export env variable"
export NVM_DIR="$HOME/.nvm"
if [ -z "$NVMRC_VERSION" ]; then
echo "==> Configuring NVMRC_VERSION!"
export NVMRC_VERSION=$(cat $CIRCLE_WORKING_DIRECTORY/.nvmrc)
echo "export NVMRC_VERSION=$NVMRC_VERSION" >> $ENV_DOT_PROFILE
fi
if [ -f "$NVM_DIR" ]; then
echo "==> $NVM_DIR exists. Skipping steps 2-4!"
else
echo "==> $NVM_DIR does not exists. Executing steps 2-4!"
echo "2. Installing NVM"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
echo "3. Executing $NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# echo "4. Update $ENV_DOT_PROFILE"
# echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $ENV_DOT_PROFILE
# echo "export NVM_DIR=$NVM_DIR" >> $ENV_DOT_PROFILE
fi
## Ref: https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
if [ ! -z "$NVM_ARCH_UNOFFICIAL_OVERRIDE" ]; then
echo "==> Handle NVM_ARCH_UNOFFICIAL_OVERRIDE=$NVM_ARCH_UNOFFICIAL_OVERRIDE!"
echo "nvm_get_arch() { nvm_echo \"${NVM_ARCH_UNOFFICIAL_OVERRIDE}\"; }" >> $ENV_DOT_PROFILE
echo "export NVM_NODEJS_ORG_MIRROR=https://unofficial-builds.nodejs.org/download/release" >> $ENV_DOT_PROFILE
source $ENV_DOT_PROFILE
fi
echo "4. Installing Node version: $NVMRC_VERSION"
nvm install $NVMRC_VERSION
nvm alias default $NVMRC_VERSION
nvm use $NVMRC_VERSION
cd $CIRCLE_WORKING_DIRECTORY
defaults_display_versions: &defaults_display_versions
name: Display Versions
command: |
echo "What is the active version of Nodejs?"
echo "node: $(node --version)"
echo "yarn: $(yarn --version)"
echo "npm: $(npm --version)"
echo "nvm: $(nvm --version)"
defaults_environment: &defaults_environment
## env var for nx to set main branch
MAIN_BRANCH_NAME: master
## Disable LIBRDKAFKA build since we install it via general dependencies
BUILD_LIBRDKAFKA: 0
##
# Executors
#
# CircleCI Executors
##
executors:
default-docker:
working_directory: &WORKING_DIR /home/circleci/project
shell: "/bin/sh -leo pipefail" ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
environment:
BASH_ENV: /etc/profile ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
NVM_ARCH_UNOFFICIAL_OVERRIDE: x64-musl ## Ref: https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
docker:
- image: node:lts-alpine # Ref: https://hub.docker.com/_/node?tab=tags&page=1&name=alpine
default-machine:
working_directory: *WORKING_DIR
shell: "/bin/bash -leo pipefail"
machine:
image: ubuntu-2204:2023.04.2 # Ref: https://circleci.com/developer/machine/image/ubuntu-2204
##
# Jobs
#
# A map of CircleCI jobs
##
jobs:
setup:
executor: default-docker
environment:
<<: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- run:
name: Configure Yarn
command: *defaults_YarnConfig
- run:
name: Install Dependencies
command: |
yarn install --immutable
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- .yarn/cache
- .yarn/unplugged
- node_modules
test-unit:
executor: default-docker
environment:
<<: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- run:
name: Configure Yarn
command: *defaults_YarnConfig
## TODO: figure out why jest is not installed
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Install Yarn dependencies
command: yarn install --immutable
- run:
name: Execute build
command: yarn run build
- run:
name: Execute unit tests
command: yarn run test:unit
- store_test_results:
path: /home/circleci/project/modules
- store_artifacts:
path: /home/circleci/project/modules/api-svc/junit.xml
build-local:
executor: default-machine
environment:
<<: *defaults_environment
steps:
- checkout
- run:
<<: *defaults_configure_nvmrc
- run:
name: Build Docker local image
command: |
source ~/.profile
export DOCKER_NODE_VERSION="$NVMRC_VERSION-alpine"
echo "export DOCKER_NODE_VERSION=$NVMRC_VERSION-alpine" >> $BASH_ENV
echo "Building Docker image: ${DOCKER_ORG:-mojaloop}/$CIRCLE_PROJECT_REPONAME:local --build-arg NODE_VERSION=$DOCKER_NODE_VERSION"
docker build -t ${DOCKER_ORG:-mojaloop}/$CIRCLE_PROJECT_REPONAME:local --build-arg NODE_VERSION=$DOCKER_NODE_VERSION .
- run:
name: Save docker image to workspace
command: docker save -o /tmp/docker-image.tar ${DOCKER_ORG:-mojaloop}/$CIRCLE_PROJECT_REPONAME:local
- persist_to_workspace:
root: /tmp
paths:
- ./docker-image.tar
test-integration:
executor: default-machine
environment:
<<: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_machine_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- run:
name: Configure Yarn
command: *defaults_YarnConfig
- run:
name: Install Yarn dependencies
command: yarn install --immutable
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: docker load -i /tmp/docker-image.tar
## This shouldn't be needed as the docker image is pre-built by build-local job
# - run:
# name: Build docker-compose
# command: |
# docker-compose build
- run:
name: Start docker-compose
command: |
docker-compose up -d
- run:
name: Wait 4 Health Services
command: |
yarn run wait-4-docker
- run:
name: Execute Build
command: yarn run build
- run:
name: Execute Integration Tests
command: |
run_int_tests() {
pushd /home/circleci/project/modules/$1
yarn run start & echo $! > /tmp/sdk-scheme-adapter.pid
sleep 10
yarn run test:integration
kill $(cat /tmp/sdk-scheme-adapter.pid)
popd
sleep 10
}
run_int_tests outbound-domain-event-handler
run_int_tests outbound-command-event-handler
## TODO Capture results
# - run:
# name: prepare test/results
# command: |
# mkdir -p test/results
# mv junit.xml test/results
# - store_artifacts:
# path: ./test/results
# - store_test_results:
# path: ./test/results
test-integration-pm4ml:
executor: default-machine
environment: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_machine_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
name: Install Yarn dependencies
command: yarn install --immutable
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: docker load -i /tmp/docker-image.tar
## This shouldn't be needed as the docker image is pre-built by build-local job
# - run:
# name: Build docker-compose
# command: |
# docker-compose build
- run:
name: Generate certificates
command: |
cd docker/haproxy/tls
sh createSecrets.sh
cd $CIRCLE_WORKING_DIRECTORY
- run:
name: Start docker-compose in PM4ML mode
command: |
docker-compose -f ./docker-compose.yml -f ./docker-compose.pm4ml.yml up -d
- run:
name: Wait 4 Health Services
command: |
yarn run wait-4-docker
- run:
name: Execute Build
command: yarn run build
- run:
name: Execute PM4ML Integration Tests
command: |
run_int_tests() {
pushd /home/circleci/project/modules/$1
yarn run test:integration-pm4ml
popd
sleep 10
}
run_int_tests api-svc
## TODO Capture results
# - run:
# name: prepare test/results
# command: |
# mkdir -p test/results
# mv junit.xml test/results
# - store_artifacts:
# path: ./test/results
# - store_test_results:
# path: ./test/results
test-func:
executor: default-machine
environment:
<<: *defaults_environment
steps:
- checkout
- run:
<<: *defaults_configure_nvmrc
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: docker load -i /tmp/docker-image.tar
- run:
name: Start docker-compose for SDK and simulators
command: |
cd test/func
docker-compose up -d
- run:
name: Wait for some time
command: |
sleep 10
- run:
name: Execute Functional Tests
command: |
cd test/func
docker-compose -f ./ttk-tests-docker-compose.yml up --abort-on-container-exit
docker compose down
- store_artifacts:
path: ./test/func/reports
prefix: test
validate-openapi:
executor: default-docker
environment:
<<: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Validate openapi
command: yarn run build:openapi && yarn run validate:api
test-dependencies:
executor: default-docker
environment:
<<: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- run:
name: Configure Yarn
command: *defaults_YarnConfig
## TODO: Resolve cache issue to replace `Install Dependencies`
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Install Dependencies
command: yarn install --immutable
- run:
name: Execute dependency tests
command: yarn run dep:check
test-lint:
executor: default-docker
environment:
<<: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- run:
name: Configure Yarn
command: *defaults_YarnConfig
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Install Dependencies
command: yarn install --immutable
- run:
name: Execute lint tests
command: yarn run lint
vulnerability-check:
executor: default-docker
environment:
<<: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- run:
name: Configure Yarn
command: *defaults_YarnConfig
- restore_cache:
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Create dir for test results
command: mkdir -p ./audit/results
- run:
name: Check for new npm vulnerabilities
command: npm run audit:check -- -o json > ./audit/results/auditResults.json
- store_artifacts:
path: ./audit/results
prefix: audit
audit-licenses:
executor: default-docker
environment:
<<: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_docker_Dependencies
- run:
name: Configure Yarn
command: *defaults_YarnConfig
- checkout
- run:
<<: *defaults_license_scanner
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Run the license-scanner
command: cd /tmp/license-scanner && pathToRepo=$CIRCLE_WORKING_DIRECTORY make run
- store_artifacts:
path: /tmp/license-scanner/results
license-scan:
executor: default-machine
environment:
<<: *defaults_environment
steps:
- checkout
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: docker load -i /tmp/docker-image.tar
- run:
<<: *defaults_license_scanner
- run:
name: Run the license-scanner
command: cd /tmp/license-scanner && mode=docker dockerImages=$DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local make run
- store_artifacts:
path: /tmp/license-scanner/results
image-scan:
executor: anchore/anchore_engine
shell: /bin/sh -leo pipefail ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
environment:
<<: *defaults_environment
BASH_ENV: /etc/profile ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
ENV: ~/.profile
NVM_ARCH_UNOFFICIAL_OVERRIDE: x64-musl ## Ref: https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
working_directory: *WORKING_DIR
steps:
- setup_remote_docker
- attach_workspace:
at: /tmp
- run:
name: Install general dependencies
command: *defaults_docker_Dependencies
- run:
name: Install docker dependencies for anchore
command: |
apk add --update py-pip docker python3-dev libffi-dev openssl-dev gcc libc-dev make jq
- run:
name: Install AWS CLI dependencies
command: *defaults_awsCliDependencies
- checkout
- run:
name: Setup Slack config
command: |
echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
echo "export SLACK_RELEASE_TYPE='GitHub Release'" >> $BASH_ENV
echo "export SLACK_RELEASE_TAG='${RELEASE_TAG} on ${CIRCLE_BRANCH} branch'" >> $BASH_ENV
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
echo "export SLACK_CUSTOM_MSG='Anchore Image Scan failed for: \`${DOCKER_ORG}/${CIRCLE_PROJECT_REPONAME}:${CIRCLE_TAG}\`'" >> $BASH_ENV
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- run:
name: Load the pre-built docker image from workspace
command: docker load -i /tmp/docker-image.tar
- run:
name: Download the mojaloop/ci-config repo
command: |
git clone https://github.com/mojaloop/ci-config /tmp/ci-config
# Generate the mojaloop anchore-policy
cd /tmp/ci-config/container-scanning && ./mojaloop-policy-generator.js /tmp/mojaloop-policy.json
- run:
name: Pull base image locally
command: |
echo "Pulling docker image: node:$NVMRC_VERSION-alpine"
docker pull node:$NVMRC_VERSION-alpine
## Analyze the base and derived image
## Note: It seems images are scanned in parallel, so preloading the base image result doesn't give us any real performance gain
- anchore/analyze_local_image:
# Force the older version, version 0.7.0 was just published, and is broken
anchore_version: v0.6.1
image_name: "docker.io/node:$NVMRC_VERSION-alpine $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local"
policy_failure: false
timeout: '500'
# Note: if the generated policy is invalid, this will fallback to the default policy, which we don't want!
policy_bundle_file_path: /tmp/mojaloop-policy.json
- run:
name: Upload Anchore reports to s3
command: |
aws s3 cp anchore-reports ${AWS_S3_DIR_ANCHORE_REPORTS}/${CIRCLE_PROJECT_REPONAME}/ --recursive
aws s3 rm ${AWS_S3_DIR_ANCHORE_REPORTS}/latest/ --recursive --exclude "*" --include "${CIRCLE_PROJECT_REPONAME}*"
aws s3 cp anchore-reports ${AWS_S3_DIR_ANCHORE_REPORTS}/latest/ --recursive
- run:
name: Evaluate failures
command: /tmp/ci-config/container-scanning/anchore-result-diff.js anchore-reports/node_${NVMRC_VERSION}-alpine-policy.json anchore-reports/${CIRCLE_PROJECT_REPONAME}*-policy.json
- store_artifacts:
path: anchore-reports
- slack/notify:
event: fail
template: SLACK_TEMP_RELEASE_FAILURE
release:
executor: default-docker
environment:
<<: *defaults_environment
steps:
- run:
name: Install general dependencies
command: *defaults_docker_Dependencies
- run:
name: Configure Yarn
command: *defaults_YarnConfig
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Configure git
command: |
git config user.email ${GIT_CI_EMAIL}
git config user.name ${GIT_CI_USER}
git checkout ${CIRCLE_BRANCH}
- run:
name: Configure ssh
command: |
mkdir -p ~/.ssh
ssh-keyscan -p 443 ssh.github.com >> ~/.ssh/known_hosts
ssh-keyscan github.com >> ~/.ssh/known_hosts
- run:
name: Generate changelog and bump package version
command: yarn run release
- run:
name: Push the release
command: git push --follow-tags origin ${CIRCLE_BRANCH}
github-release:
executor: default-machine
shell: "/bin/bash -eo pipefail"
environment:
<<: *defaults_environment
steps:
- run:
name: Install git
command: |
sudo apt-get update && sudo apt-get install -y git
- gh/install
- checkout
- run:
<<: *defaults_configure_git
- run:
name: Fetch updated release branch
command: |
git fetch origin
git checkout origin/${CIRCLE_BRANCH}
- run:
<<: *defaults_export_version_from_package
- run:
name: Check the release changes
command: |
echo "Changes are: ${RELEASE_CHANGES}"
- run:
name: Setup Slack config
command: |
echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
echo "export SLACK_RELEASE_TYPE='Github Release'" >> $BASH_ENV
echo "export SLACK_RELEASE_TAG=v${RELEASE_TAG}" >> $BASH_ENV
echo "export SLACK_RELEASE_URL=https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/v${RELEASE_TAG}" >> $BASH_ENV
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
- run:
name: Create Release
command: |
gh release create "v${RELEASE_TAG}" --title "v${RELEASE_TAG} Release" --draft=false --notes "${RELEASE_CHANGES}" ./CHANGELOG.md
- slack/notify:
event: pass
template: SLACK_TEMP_RELEASE_SUCCESS
- slack/notify:
event: fail
template: SLACK_TEMP_RELEASE_FAILURE
publish-docker:
executor: default-machine
shell: "/bin/bash -eo pipefail"
environment:
<<: *defaults_environment
steps:
- checkout
- run:
name: Setup for LATEST release
command: |
echo "export RELEASE_TAG=$RELEASE_TAG_PROD" >> $BASH_ENV
echo "RELEASE_TAG=$RELEASE_TAG_PROD"
PACKAGE_VERSION=$(cat package.json | jq -r .version)
echo "export PACKAGE_VERSION=${PACKAGE_VERSION}" >> $BASH_ENV
echo "PACKAGE_VERSION=${PACKAGE_VERSION}"
- run:
name: Setup Slack config
command: |
echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
echo "export SLACK_RELEASE_TYPE='Docker Release'" >> $BASH_ENV
echo "export SLACK_RELEASE_TAG=v${CIRCLE_TAG:1}" >> $BASH_ENV
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: |
docker load -i /tmp/docker-image.tar
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run:
name: Re-tag pre built image
command: |
docker tag $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
docker tag $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
- run:
name: Publish Docker image $CIRCLE_TAG & Latest tag to Docker Hub
command: |
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
- run:
name: Set Image Digest
command: |
IMAGE_DIGEST=$(docker inspect $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:v${CIRCLE_TAG:1} | jq '.[0].RepoDigests | .[]')
echo "IMAGE_DIGEST=${IMAGE_DIGEST}"
echo "export IMAGE_DIGEST=${IMAGE_DIGEST}" >> $BASH_ENV
- run:
name: Update Slack config
command: |
echo "export SLACK_RELEASE_URL='https://hub.docker.com/layers/${CIRCLE_PROJECT_REPONAME}/${DOCKER_ORG}/${CIRCLE_PROJECT_REPONAME}/v${CIRCLE_TAG:1}/images/${IMAGE_DIGEST}?context=explore'" | sed -r "s/${DOCKER_ORG}\/${CIRCLE_PROJECT_REPONAME}@sha256:/sha256-/g" >> $BASH_ENV
- slack/notify:
event: pass
template: SLACK_TEMP_RELEASE_SUCCESS
- slack/notify:
event: fail
template: SLACK_TEMP_RELEASE_FAILURE
publish-docker-snapshot:
executor: default-machine
shell: "/bin/bash -eo pipefail"
environment:
<<: *defaults_environment
steps:
- checkout
- run:
name: Setup for SNAPSHOT release
command: |
echo "export RELEASE_TAG=$RELEASE_TAG_SNAPSHOT" >> $BASH_ENV
echo "RELEASE_TAG=$RELEASE_TAG_SNAPSHOT"
PACKAGE_VERSION=$(cat package.json | jq -r .version)
echo "export PACKAGE_VERSION=${PACKAGE_VERSION}" >> $BASH_ENV
echo "PACKAGE_VERSION=${PACKAGE_VERSION}"
- run:
name: Setup Slack config
command: |
echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
echo "export SLACK_RELEASE_TYPE='Docker Release'" >> $BASH_ENV
echo "export SLACK_RELEASE_TAG=v${CIRCLE_TAG:1}" >> $BASH_ENV
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image from workspace
command: |
docker load -i /tmp/docker-image.tar
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run:
name: Re-tag pre built image
command: |
docker tag $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
docker tag $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
- run:
name: Publish Docker image $CIRCLE_TAG & Latest tag to Docker Hub
command: |
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
- run:
name: Set Image Digest
command: |
IMAGE_DIGEST=$(docker inspect $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:v${CIRCLE_TAG:1} | jq '.[0].RepoDigests | .[]')
echo "IMAGE_DIGEST=${IMAGE_DIGEST}"
echo "export IMAGE_DIGEST=${IMAGE_DIGEST}" >> $BASH_ENV
- run:
name: Update Slack config
command: |
echo "export SLACK_RELEASE_URL='https://hub.docker.com/layers/${CIRCLE_PROJECT_REPONAME}/${DOCKER_ORG}/${CIRCLE_PROJECT_REPONAME}/v${CIRCLE_TAG:1}/images/${IMAGE_DIGEST}?context=explore'" | sed -r "s/${DOCKER_ORG}\/${CIRCLE_PROJECT_REPONAME}@sha256:/sha256-/g" >> $BASH_ENV
- slack/notify:
event: pass
template: SLACK_TEMP_RELEASE_SUCCESS
- slack/notify:
event: fail
template: SLACK_TEMP_RELEASE_FAILURE
##
# Workflows
#
# CircleCI Workflow config
##
workflows:
version: 2
build_and_test:
jobs:
- pr-tools/pr-title-check:
context: org-global
- setup:
context: org-global
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- test-unit:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- validate-openapi:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- test-dependencies:
context: org-global
requires:
- setup
filters:
tags:
ignore: /.*/
branches:
ignore:
- master
- main
- test-lint:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- build-local:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- test-integration:
context: org-global
requires:
- setup
- build-local
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- test-integration-pm4ml:
context: org-global
requires:
- setup
- build-local
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- test-func:
context: org-global
requires:
- setup
- build-local
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- vulnerability-check:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- audit-licenses:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- license-scan:
context: org-global
requires:
- build-local
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(\-snapshot(\.[0-9]+)?)?(\-hotfix(\.[0-9]+)?)?(\-perf(\.[0-9]+)?)?/
branches:
ignore:
- /.*/