-
Notifications
You must be signed in to change notification settings - Fork 533
/
config.yml
629 lines (621 loc) · 20.7 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
version: 2.1
orbs:
win: circleci/windows@2.2.0
aws-cli: circleci/aws-cli@1.4.0
defaults: &defaults
parameters:
node_version:
type: string
default: ''
root_tap_tests:
type: boolean
default: false
jest_tests:
type: boolean
default: false
acceptance_tests:
type: boolean
default: false
system_tests:
type: boolean
default: false
package_tests:
type: boolean
default: false
working_directory: ~/snyk
windows_defaults: &windows_defaults
environment:
npm_config_loglevel: silent
executor:
name: win/default
commands:
install_deps:
description: Install dependencies
steps:
- run:
name: Install dependencies
command: npm install
update_local_npmrc_linux:
description: Update local .npmrc file (Linux)
steps:
- run:
name: Update local .npmrc file (Linux)
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
build_ts:
description: Build js files from ts
steps:
- run:
name: Build
command: npm run build
- persist_to_workspace:
root: .
paths:
- dist/
install_gradle_windows:
description: Install gradle
steps:
- run: choco install gradle
install_maven_windows:
description: Install maven
steps:
- run: choco install maven
install_sbt_windows:
description: Install SBT
steps:
- run: choco install sbt
install_sdkman_linux:
description: Install SDKMAN
steps:
- run:
name: Installing SDKMAN
command: |
curl -s "https://get.sdkman.io?rcupdate=false" | bash
echo -e '\nsource "/home/circleci/.sdkman/bin/sdkman-init.sh"' >> $BASH_ENV
source $BASH_ENV
install_jdk_linux:
description: Install JDK
steps:
- run:
name: Installing JDK
command: sdk install java $(sdk list java | grep -o -m1 "11\.[0-9\.]\+hs-adpt")
install_gradle_linux:
description: Install gradle
steps:
- run:
name: Installing Gradle
command: sdk install gradle 6.4.1
install_maven_linux:
description: Install maven
steps:
- run:
name: Installing maven
command: sdk install maven 3.6.3
install_sbt_linux:
description: Install SBT
steps:
- run:
name: Installing sbt
command: sdk install sbt 1.3.12
install_node_windows:
description: Install the given Node version on Windows using Chocolatey
parameters:
node_version:
type: string
default: ''
steps:
- run:
name: Install Node with Chocolatey
command: |
$current_node_version = node --version
nvm uninstall $current_node_version
choco install nodejs --version=<< parameters.node_version >>
install_shellspec:
description: Install Shellspec
steps:
- run: curl -fsSL https://git.io/shellspec | sh -s -- -y
- run: sudo ln -s ${HOME}/.local/lib/shellspec/shellspec /usr/local/bin/shellspec
- run: sudo apt-get install jq
show_node_version:
description: Log Node and npm version
steps:
- run:
name: Node version
command: node --version
- run:
name: NPM version
command: npm --version
install_github_cli:
description: Install GitHub CLI (gh)
steps:
- run:
name: Install GitHub CLI (gh)
command: |
mkdir gh-download
curl -Lo ./gh-download/gh_1.3.1_linux_amd64.tar.gz https://github.com/cli/cli/releases/download/v1.3.1/gh_1.3.1_linux_amd64.tar.gz
tar -xf ./gh-download/gh_1.3.1_linux_amd64.tar.gz --directory gh-download
chmod a+x gh-download/gh_1.3.1_linux_amd64/bin/gh
mkdir -p /home/circleci/bin
mv gh-download/gh_1.3.1_linux_amd64/bin/gh /home/circleci/bin
which gh
gh --version
install_lerna_linux:
description: Setup Lerna
steps:
- run: sudo npm install -g lerna@3.22.1
jobs:
regression-test:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
steps:
- checkout
- install_shellspec
- run: sudo npm install -g npm@7
- show_node_version
- update_local_npmrc_linux
- install_deps
- build_ts
- run:
name: Run auth
command: npm run snyk-auth
- run:
name: Run tests
command: npm run test:common
- run:
name: Clear Snyk config
command: rm ~/.config/configstore/snyk.json
- run:
name: Clear node_modules
command: rm -rf node_modules/
- run:
name: Install only production dependencies
command: npx npm@6 install # kludge because npm@7 will invoke the lifecycle scripts (thus running prepare -> tsc) even if we use --ignore-scripts
environment:
NODE_ENV: production
- run:
name: npm install for fixture project
working_directory: ~/snyk/test/fixtures/basic-npm
command: npm install
- run:
name: Setup alias for snyk
working_directory: ~/snyk/
command: sudo ./test/smoke/setup-alias-for-snyk.sh
- run:
name: Run shellspec
working_directory: ~/snyk/test/smoke
command: |
echo "Checkout the README in test/smoke folder for more details about this step"
unset SNYK_API
unset SNYK_API_KEY
shellspec --profile --output junit --reportdir ../../test-results/shellspec-regression-tests -f d -e REGRESSION_TEST=1
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
test-windows:
<<: *defaults
<<: *windows_defaults
steps:
- run: git config --global core.autocrlf false
- install_gradle_windows
- install_maven_windows
- install_sbt_windows
- show_node_version
- install_node_windows:
node_version: << parameters.node_version >>
- show_node_version
- checkout
- attach_workspace:
at: ~/snyk
- run: npm install -g npm@7
- show_node_version
- run:
name: Setup Lerna
command: npm install -g lerna@3.22.1
- run:
name: Update local .npmrc file (Windows)
command: echo "//registry.npmjs.org/:_authToken=$env:NPM_TOKEN" >> .npmrc
- run:
name: Install dependencies (Windows)
command: npm install --ignore-scripts # ignore-scripts required because of postinstall script in snyk-resolve-deps package
- build_ts
- run:
name: npm version
command: npm --version
- run:
name: Run auth
shell: bash.exe
command: npm run snyk-auth-windows
- when:
condition: << parameters.package_tests >>
steps:
- run:
name: Run Package unit tests
command: npm run test:packages-unit -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:packages-unit'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-packages-unit'
- when:
condition: << parameters.package_tests >>
steps:
- run:
name: Run Package acceptance tests
command: npm run test:packages-acceptance -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:packages-acceptance'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-packages-acceptance'
- when:
condition: << parameters.root_tap_tests >>
steps:
- run:
name: Run "Root" tap tests
command: |
npm run test:test -- --output-file tap-output
npx tap-junit --input tap-output --output test-results/tap-test-test
- when:
condition: << parameters.jest_tests >>
steps:
- run:
name: Run Jest tests in root (to remove)
command: npm run test:jest -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:jest'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest'
- run:
name: Run Jest Unit Tests
command: npm run test:jest-unit -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:jest-unit'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-unit'
- run:
name: Run Jest System Tests
command: npm run test:jest-system -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:jest-system'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-system'
- run:
name: Run Jest Acceptance Tests
command: npm run test:jest-acceptance -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:jest-acceptance'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-acceptance'
- when:
condition: << parameters.acceptance_tests >>
steps:
- run:
name: Run Acceptance tests
command: |
npm run test:acceptance-windows -- --output-file tap-output
npx tap-junit --input tap-output --output test-results/tap-test-acceptance-windows
- when:
condition: << parameters.system_tests >>
steps:
- run:
name: Run System tests
command: |
npm run test:system -- --output-file tap-output
npx tap-junit --input tap-output --output test-results/tap-test-system
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
test-linux:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
resource_class: large
steps:
- install_sdkman_linux
- install_jdk_linux
- install_gradle_linux
- install_maven_linux
- install_sbt_linux
- show_node_version
- checkout
- attach_workspace:
at: ~/snyk
- run: sudo npm install -g npm@7
- show_node_version
- install_lerna_linux
- update_local_npmrc_linux
- install_deps
- build_ts
- run:
name: npm version
command: npm --version
- run:
name: Run auth
command: npm run snyk-auth
- when:
condition: << parameters.package_tests >>
steps:
- run:
name: Run Package unit tests
command: npm run test:packages-unit -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:packages-unit'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-packages-unit'
- when:
condition: << parameters.package_tests >>
steps:
- run:
name: Run Package acceptance tests
command: npm run test:packages-acceptance -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:packages-acceptance'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-packages-acceptance'
- when:
condition: << parameters.root_tap_tests >>
steps:
- run:
name: Run "Root" tap tests
command: |
npm run test:test -- --output-file tap-output
npx tap-junit --input tap-output --output test-results/tap-test-test
- when:
condition: << parameters.jest_tests >>
steps:
- run:
name: Run Jest tests in root (to remove)
command: npm run test:jest -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:jest'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest'
- run:
name: Run Jest Unit Tests
command: npm run test:jest-unit -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:jest-unit'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-unit'
- run:
name: Run Jest System Tests
command: npm run test:jest-system -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:jest-system'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-system'
- run:
name: Run Jest Acceptance Tests
command: npm run test:jest-acceptance -- --ci --reporters="default" --reporters="jest-junit"
environment:
JEST_SUITE_NAME: 'test:jest-acceptance'
JEST_JUNIT_OUTPUT_DIR: 'test-results/jest-acceptance'
- when:
condition: << parameters.acceptance_tests >>
steps:
- run:
name: Run Acceptance tests
command: |
npm run test:acceptance -- --output-file tap-output
npx tap-junit --input tap-output --output test-results/tap-test-acceptance
- when:
condition: << parameters.system_tests >>
steps:
- run:
name: Run System tests
command: |
npm run test:system -- --output-file tap-output
npx tap-junit --input tap-output --output test-results/tap-test-system
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
dev-release:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
resource_class: small
steps:
- checkout
- run:
name: Install npm@7
command: |
sudo npm install -g npm@7
- show_node_version
- install_lerna_linux
- install_deps
- run:
name: Update package versions
command: ./release-scripts/update-versions.sh
- run:
name: Install osslsigncode
command: sudo apt-get install -y osslsigncode
- run:
name: Create Binaries
command: |
./release-scripts/make-binaries.sh
ls -la ./binary-releases
- store_artifacts:
path: ./binary-releases
- run:
name: Validate binary release checksums
working_directory: ~/snyk/binary-releases
command: |
../release-scripts/validate-checksums.sh
release:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
resource_class: small
steps:
- checkout
- run:
name: Should I release?
command: ./release-scripts/should-i-release.sh
- install_github_cli
- aws-cli/install
- run:
name: Install npm@7
command: |
sudo npm install -g npm@7
- show_node_version
- install_lerna_linux
- update_local_npmrc_linux
- install_deps
- run:
name: Update package versions
command: ./release-scripts/update-versions.sh
- run:
name: Make git ignore changes relating to version updates and to .npmrc
command: |
git update-index --skip-worktree -- ./lerna.json
git update-index --skip-worktree -- ./package.json
git update-index --skip-worktree -- ./packages/snyk-protect/package.json
git update-index --skip-worktree -- ./.npmrc
- run:
name: Lerna Publish
command: |
lerna publish minor --yes --no-push --no-git-tag-version --exact
- run:
name: Install osslsigncode
command: sudo apt-get install -y osslsigncode
- run:
name: Create Binaries
command: |
./release-scripts/make-binaries.sh
ls -la ./binary-releases
- store_artifacts:
path: ./binary-releases
- run:
name: Validate binary release checksums
working_directory: ~/snyk/binary-releases
command: |
../release-scripts/validate-checksums.sh
- run:
name: Generate Release Notes
command: |
npx conventional-changelog-cli -p angular -l -r 1 > RELEASE_NOTES.txt
- run:
name: Upload Artifacts
command: ./release-scripts/upload-artifacts.sh
- run:
name: Handle failed CLI release
command: |
./release-scripts/handle-failed-release.sh
when: on_fail
workflows:
version: 2
test_and_release:
jobs:
- regression-test:
name: Regression Test
context: nodejs-install
node_version: '12.16.2'
filters:
branches:
ignore:
- master
- dev-release:
name: Dev Release
node_version: '14'
requires:
- Regression Test
- test-windows:
name: Windows, Node 14 - Packages, Jest, Acceptance, System tests
context: nodejs-install
node_version: '14.15.4'
jest_tests: true
acceptance_tests: true
system_tests: true
package_tests: true
requires:
- Regression Test
- test-windows:
name: Windows, Node 14 - "Root" tap tests
context: nodejs-install
node_version: '14.15.4'
root_tap_tests: true
requires:
- Regression Test
- test-windows:
name: Windows, Node 12 - Packages, Jest, Acceptance, System tests
context: nodejs-install
node_version: '12.21.0'
jest_tests: true
acceptance_tests: true
system_tests: true
package_tests: true
requires:
- Regression Test
- test-windows:
name: Windows, Node 12 - "Root" tap tests
context: nodejs-install
node_version: '12.21.0'
root_tap_tests: true
requires:
- Regression Test
- test-windows:
name: Windows, Node 10 - Packages, Jest, Acceptance, System tests
context: nodejs-install
node_version: '10.23.1'
jest_tests: true
acceptance_tests: true
system_tests: true
package_tests: true
requires:
- Regression Test
- test-windows:
name: Windows, Node 10 - "Root" tap tests
context: nodejs-install
node_version: '10.23.1'
root_tap_tests: true
requires:
- Regression Test
- test-linux:
name: Linux, Node 14 - Packages, Jest, Acceptance, System tests
context: nodejs-install
node_version: '14.15.4'
jest_tests: true
acceptance_tests: true
system_tests: true
package_tests: true
requires:
- Regression Test
- test-linux:
name: Linux, Node 14 - "Root" tap tests
context: nodejs-install
node_version: '14.15.4'
root_tap_tests: true
requires:
- Regression Test
- test-linux:
name: Linux, Node 12 - Packages, Jest, Acceptance, System tests
context: nodejs-install
node_version: '12.21.0'
jest_tests: true
acceptance_tests: true
system_tests: true
package_tests: true
requires:
- Regression Test
- test-linux:
name: Linux, Node 12 - "Root" tap tests
context: nodejs-install
node_version: '12.21.0'
root_tap_tests: true
requires:
- Regression Test
- test-linux:
name: Linux, Node 10 - Packages, Jest, Acceptance, System tests
context: nodejs-install
node_version: '10.23.1'
jest_tests: true
acceptance_tests: true
system_tests: true
package_tests: true
requires:
- Regression Test
- test-linux:
name: Linux, Node 10 - "Root" tap tests
context: nodejs-install
node_version: '10.23.1'
root_tap_tests: true
requires:
- Regression Test
- release:
name: Release
context: nodejs-app-release
node_version: '14.15.4'
filters:
branches:
only:
- master