forked from mojaloop/central-services-stream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
301 lines (284 loc) · 8.52 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
# CircleCI v2 Config
version: 2
defaults_working_directory: &defaults_working_directory
working_directory: /home/circleci/project
defaults_docker_node: &defaults_docker_node
docker:
- image: node:10.15.3-alpine
defaults_Dependencies: &defaults_Dependencies |
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
apk add --no-cache -t build-dependencies make gcc g++ python libtool autoconf automake
npm config set unsafe-perm true
npm install -g node-gyp
defaults_awsCliDependencies: &defaults_awsCliDependencies |
apk --no-cache add \
python \
py-pip \
groff \
less \
mailcap
pip install --upgrade awscli==1.14.5 s3cmd==2.0.1 python-magic
apk -v --purge del py-pip
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_npm_auth: &defaults_npm_auth
name: Update NPM registry auth token
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
defaults_npm_publish_version: &defaults_npm_publish
name: Update version to prerelease
command: |
source $BASH_ENV
echo "Publishing tag $CIRCLE_TAG"
npm publish --tag $CIRCLE_TAG --access public
defaults_npm_publish_release: &defaults_npm_publish_release
name: Publish NPM $RELEASE_TAG artifact
command: |
source $BASH_ENV
echo "Publishing tag $RELEASE_TAG"
npm publish --tag $RELEASE_TAG --access public
defaults_slack_announcement: &defaults_slack_announcement
name: Slack announcement for tag releases
command: |
curl -X POST \
$SLACK_WEBHOOK_ANNOUNCEMENT \
-H 'Content-type: application/json' \
-H 'cache-control: no-cache' \
-d "{
\"text\": \"*${CIRCLE_PROJECT_REPONAME}* - Release \`${CIRCLE_TAG}\`: https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/${CIRCLE_TAG}\"
}"
jobs:
setup:
<<: *defaults_working_directory
<<: *defaults_docker_node
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- run:
name: Update NPM install
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
test-unit:
<<: *defaults_working_directory
<<: *defaults_docker_node
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install tape, tapes and tap-xunit
command: npm install tape tapes tap-xunit
- run:
name: Create dir for test results
command: mkdir -p ./test/results
- run:
name: Execute unit tests
command: npm -s run test:xunit > ./test/results/tape.xml
- store_artifacts:
path: ./test/results
prefix: test
- store_test_results:
path: ./test/results
test-coverage:
<<: *defaults_working_directory
<<: *defaults_docker_node
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- run:
name: Install AWS CLI dependencies
command: *defaults_awsCliDependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Execute code coverage check
command: npm -s run test:coverage-check
- store_artifacts:
path: coverage
prefix: test
- store_test_results:
path: coverage/lcov.info
- run:
name: Copy code coverage to SonarQube
command: |
if [ "${CIRCLE_BRANCH}" == "master" ];
then
echo "Sending lcov.info to SonarQube..."
aws s3 cp coverage/lcov.info $AWS_S3_DIR_SONARQUBE/${CIRCLE_PROJECT_REPONAME}/lcov.info
else
echo "Not a release (env CIRCLE_BRANCH != 'master'), skipping sending lcov.info to SonarQube."
fi
vulnerability-check:
<<: *defaults_working_directory
<<: *defaults_docker_node
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Create dir for test results
command: mkdir -p ./audit/results
- run:
name: Check for new npm vulnerabilities
command: npm run audit:check --silent -- --json > ./audit/results/auditResults.json
- store_artifacts:
path: ./audit/results
prefix: audit
audit-licenses:
<<: *defaults_working_directory
<<: *defaults_docker_node
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- run:
<<: *defaults_license_scanner
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Run the license-scanner
command: cd /tmp/license-scanner && pathToRepo=$CIRCLE_WORKING_DIRECTORY make run
- store_artifacts:
path: /tmp/license-scanner/results
prefix: licenses
build-snapshot:
<<: *defaults_working_directory
<<: *defaults_docker_node
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- run:
name: setup environment vars for SNAPSHOT release
command: |
echo 'export RELEASE_TAG=$RELEASE_TAG_SNAPSHOT' >> $BASH_ENV
- run:
<<: *defaults_npm_auth
- run:
<<: *defaults_npm_publish_release
- run:
<<: *defaults_slack_announcement
build:
<<: *defaults_working_directory
<<: *defaults_docker_node
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- run:
name: setup environment vars for LATEST release
command: |
echo 'export RELEASE_TAG=$RELEASE_TAG_PROD' >> $BASH_ENV
- run:
<<: *defaults_npm_auth
- run:
<<: *defaults_npm_publish_release
- run:
<<: *defaults_slack_announcement
workflows:
version: 2
build_and_test:
jobs:
- 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*/
- test-coverage:
context: org-global
requires:
- setup
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*/
- build-snapshot:
context: org-global
requires:
- setup
- test-unit
- test-coverage
- vulnerability-check
- audit-licenses
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*\-snapshot+((\.[0-9]+)?)/
branches:
ignore:
- /.*/
- build:
context: org-global
requires:
- setup
- test-unit
- test-coverage
- vulnerability-check
- audit-licenses
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
branches:
ignore:
- /.*/