-
Notifications
You must be signed in to change notification settings - Fork 392
/
config.yml
667 lines (635 loc) · 20.6 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
#
# CircleCI configuration for salesforcedx-vscode
#
# The following environment variables are required in the 'vscode-test' context
# when running tests for Windows:
# SFDX_CI_DEVHUB_CLIENTID -- connected app client ID for the dev hub
# SFDX_CI_DEVHUB_JWT_KEY -- private key for the connected app (base64 encoded)
# SFDX_CI_DEVHUB_USERNAME -- username of an authorized user of the dev hub
#
version: 2.1
orbs:
win: circleci/windows@2.4.0
release-management: salesforce/npm-release-management@4
slack: circleci/slack@3.4.2
github-cli: circleci/github-cli@2.1.0
parameters:
# Configurable Versions
cli-version:
type: string
default: '7.45.1'
lerna-version:
type: string
default: '3.13.1'
node-version:
# 16.14 doesn't exist yet on https://hub.docker.com/r/circleci/node (Apr 2022)
type: string
default: '16.13'
# Constants
cache-version:
type: string
default: 'dependency-cache-v4-'
domain-retry:
description: 'SFDX Domain Retry Wait in Seconds'
type: integer
default: 300
fingerprint:
type: string
default: '3b:68:69:7d:19:a4:50:69:ad:b8:db:57:f9:9c:f0:3f'
# Workflow Triggers
create-release:
type: boolean
default: false
publish:
type: boolean
default: false
publish-type:
type: string
default: minor
pre-publish:
type: boolean
default: false
commands:
build-artifacts:
description: 'Building and archiving extension artifacts.'
steps:
- checkout
- restore_dependency_cache
- install
- compile
- package-extensions
- stage-and-store-artifacts
- save_dependency_cache
build-win:
description: 'Build for Windows.'
steps:
- run: git config --global core.autocrlf false
- checkout
- restore_dependency_cache:
base-cache-path: << pipeline.parameters.cache-version >>-win
- run:
name: 'Install node'
shell: bash.exe
command: |
nvm install $NODE_VERSION
nvm use $NODE_VERSION
nvm install-latest-npm
- run:
name: 'Install dependent modules'
shell: bash.exe
command: |
touch ~/.bashrc
curl -o- -L https://yarnpkg.com/install.sh | bash
source ~/.bashrc
npm install -g sfdx-cli@<< pipeline.parameters.cli-version >>
npm install -g junit-merge
yarn install --frozen-lockfile
- run:
name: 'Compile'
shell: bash.exe
command: npm run compile
- save_dependency_cache:
base-cache-path: << pipeline.parameters.cache-version >>-win
- run:
name: 'Run lint'
shell: bash.exe
command: |
npm run lint
compile:
parameters:
compile-mode:
type: string
default: production
steps:
- run:
name: 'Compile in << parameters.compile-mode >> mode'
environment:
- NODE_ENV: << parameters.compile-mode >>
- BASH_ENV: ~/.bashrc
command: |
npm run compile
gh-config:
parameters:
cache_timeout:
description: 'Cache timeout in seconds'
type: integer
default: 120
gh_email:
description: 'GitHub email'
type: string
default: $GH_EMAIL
gh_username:
description: 'GitHub username'
type: string
default: 'Release Bot'
steps:
- run:
name: 'Configuring GitHub'
command: |
git config credential.helper 'cache --timeout=<< parameters.cache_timeout >>'
git config user.email "<< parameters.gh_email >>"
git config user.name "<< parameters.gh_username >>"
git config --global pull.rebase true
install:
description: 'Installing dependencies'
steps:
- run: node --version
- run: npm --version
- run: yarn --version
- run: yarn install --frozen-lockfile
merge-validation:
description: 'Verify the release branch is not older than main'
parameters:
package-json-path:
type: string
default: './packages/salesforcedx-vscode/package.json'
steps:
- run:
name: 'Validate release version against main'
command: |
git checkout main
echo "export MAIN_RELEASE_VERSION="$(node -pe "require('<< parameters.package-json-path >>').version")"" >> $BASH_ENV
source $BASH_ENV
echo "MAIN_RELEASE_VERSION is: ${MAIN_RELEASE_VERSION}"
LOWER_VERSION="`echo -e "${MAIN_RELEASE_VERSION}\n${RELEASE_VERSION}" | sort -V | cut --delimiter $'\n' --fields 1`"
echo "Lower version was: ${LOWER_VERSION}"
if [ ${LOWER_VERSION} != ${MAIN_RELEASE_VERSION} ]
then
echo "The release branch is older than main. We do not want to rebase off of an old branch. Exiting."
exit 1;
fi
package-extensions:
steps:
- run:
name: 'Packaging extensions'
command: npm run vscode:package
prepare-gus-environment-variables:
parameters:
package-json-path:
type: string
default: './packages/salesforcedx-vscode/package.json'
release-tag-name:
type: string
default: 'offcore.tooling'
steps:
- run:
name: 'Prepare environment variables for GUS Change Case Management'
command: |
export GUS_BUILD="$(node -pe "require('<< parameters.package-json-path >>').version")"
echo "export SF_CHANGE_CASE_SCHEDULE_BUILD=<< parameters.release-tag-name >>.$GUS_BUILD" >> $BASH_ENV
source $BASH_ENV
prepare-release-environment-variables:
parameters:
package-json-path:
type: string
default: './packages/salesforcedx-vscode/package.json'
steps:
- run:
name: 'Prepare release branch environment variable'
command: |
echo "export RELEASE_VERSION="$(node -pe "require('<< parameters.package-json-path >>').version")"" >> $BASH_ENV
source $BASH_ENV
echo "RELEASE_VERSION is: ${RELEASE_VERSION}"
restore_dependency_cache:
# This logic cannot be done within the node orb currently. This is due to the fact that we use
# the package.json instead of the package-lock.json for our checksum.
parameters:
base-cache-path:
type: string
default: << pipeline.parameters.cache-version >>
steps:
- restore_cache:
keys:
- << parameters.base-cache-path >>{{ checksum "yarn.lock" }}
save_dependency_cache:
parameters:
base-cache-path:
type: string
default: << pipeline.parameters.cache-version >>
path-to-save:
type: string
default: 'node_modules'
steps:
- save_cache:
key: << parameters.base-cache-path >>{{ checksum "yarn.lock" }}
paths:
- << parameters.path-to-save >>
ssh-config:
steps:
- add_ssh_keys:
fingerprints:
- << pipeline.parameters.fingerprint >>
stage-and-store-artifacts:
parameters:
location:
type: string
default: 'extensions'
steps:
- run:
name: 'Staging artifacts'
command: |
mkdir << parameters.location >>
find packages -name "*.vsix" -type f -exec cp {} ./<< parameters.location >> \;
- store_artifacts:
path: ./<< parameters.location >>
store-crash-logs:
parameters:
location:
type: string
default: 'vscode-crash-logs'
steps:
- store_artifacts:
path: ./<< parameters.location >>
updating-sha-for-publish:
steps:
- run:
name: 'Generating the SHA256 and appending to the file.'
command: npm run vscode:sha256
- run:
name: 'Concatenating the contents to the proper SHA256.md'
command: scripts/concatenate-sha256.js
- run:
name: 'Removing the temp SHA256 file.'
command: rm ./SHA256
- run:
name: 'Adding the SHA256 to git.'
command: |
git add SHA256.md
git commit -m "chore: updated SHA256 v${RELEASE_VERSION}"
executors:
default-executor:
parameters:
# We are unable to use the recommended cimg docker images since they use the root path instead of home
image:
type: string
default: circleci/node:<< pipeline.parameters.node-version >>
working-dir:
type: string
default: ~/cli
docker:
- image: << parameters.image >>
working_directory: << parameters.working-dir >>
jobs:
build-all:
description: 'Build artifacts in a non-Windows environment'
executor:
name: default-executor
working-dir: ~/project
environment:
- SFDX_URL_LINUX: https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz
- SFDX_AUTOUPDATE_DISABLE: true
- SFDX_USE_GENERIC_UNIX_KEYCHAIN: true
- SFDX_DOMAIN_RETRY: << pipeline.parameters.domain-retry >>
- BASH_ENV: ~/.bashrc
steps:
- build-artifacts
unit-tests:
description: 'Run tests on Windows'
executor: win/default
environment:
- SFDX_AUTOUPDATE_DISABLE: true
- SFDX_DOMAIN_RETRY: << pipeline.parameters.domain-retry >>
- NODE_VERSION: << pipeline.parameters.node-version >>
- BASH_ENV: ~/.bashrc
steps:
- build-win
- run:
name: 'Running unit tests'
shell: bash.exe
command: npm run test:unit
- run:
name: 'Aggregate test results'
shell: bash.exe
command: |
set -e
npm run aggregateJUnit -- -t unit
junit-merge -d junit-aggregate -o junit-aggregate.xml
- store_test_results:
path: ./junit-aggregate/
- run:
name: 'Check for Test Failures'
shell: powershell.exe
command: |
[xml]$results = Get-Content junit-aggregate.xml
$failure = $results.SelectSingleNode("//failure")
if ($failure -ne $null) {
Write-Host "Forcing build failure due to test failure(s) :'("
$host.SetShouldExit(1)
}
soql-ui-tests:
description: 'Run E2E SOQL UI Tests'
executor: win/default
environment:
- SFDX_AUTOUPDATE_DISABLE: true
- SFDX_DOMAIN_RETRY: << pipeline.parameters.domain-retry >>
- NODE_VERSION: << pipeline.parameters.node-version >>
- BASH_ENV: ~/.bashrc
steps:
- build-win
- run:
name: 'Run SOQL UI Tests if Needed'
shell: bash.exe
command: |
set -e
npm run test:ui
integration-tests:
description: 'Run tests on Windows'
executor: win/default
environment:
- SFDX_AUTOUPDATE_DISABLE: true
- SFDX_DOMAIN_RETRY: << pipeline.parameters.domain-retry >>
- NODE_VERSION: << pipeline.parameters.node-version >>
- BASH_ENV: ~/.bashrc
steps:
- build-win
- run:
name: 'Authenticate to the default DevHub'
shell: bash.exe
command: |
echo $SFDX_CI_DEVHUB_JWTKEY | base64 --decode > devhub.key
sfdx force:auth:jwt:grant --clientid ${SFDX_CI_DEVHUB_CLIENTID} --username ${SFDX_CI_DEVHUB_USERNAME} --jwtkeyfile devhub.key --setdefaultdevhubusername --setalias devhub
rm devhub.key
- run:
name: 'Running integration tests'
shell: bash.exe
command: npm run test:integration-tests-without-system-tests
- run:
name: 'Assert all tests ran and aggregate results'
shell: bash.exe
command: |
set -e
npm run aggregateJUnit -- -t integration vscode-integration
junit-merge -d junit-aggregate -o junit-aggregate.xml
- store_test_results:
path: ./junit-aggregate/
- store-crash-logs
- run:
name: 'Check for Test Failures'
shell: powershell.exe
command: |
[xml]$results = Get-Content junit-aggregate.xml
$failure = $results.SelectSingleNode("//failure")
if ($failure -ne $null) {
Write-Host "Forcing build failure due to test failure(s) :'("
$host.SetShouldExit(1)
}
merge-release-branch:
parameters:
e:
type: executor
executor: << parameters.e >>
steps:
- slack/notify:
channel: 'pdt_releases'
color: '#FFDEAD'
message: 'Merging release branch into main'
- ssh-config
- checkout
- gh-config
- prepare-release-environment-variables
- merge-validation
- run:
name: 'Rebasing main off of release branch'
command: |
echo "Rebasing main off of release branch ${RELEASE_VERSION}"
git checkout main
git rebase -Xtheirs release/v${RELEASE_VERSION}
git push
- slack/notify:
channel: 'pdt_releases'
color: '#d8bfd8'
message: 'Main should now be rebased off of the release branch ${RELEASE_VERSION}'
- slack/status:
channel: 'pdt_releases'
fail_only: true
publish:
parameters:
e:
type: executor
executor: << parameters.e >>
steps:
- slack/notify:
channel: 'pdt_releases'
color: '#FFDEAD'
message: 'Starting publish for VSCode Extensions'
- ssh-config
- checkout
- prepare-release-environment-variables
- prepare-gus-environment-variables
- restore_dependency_cache
- gh-config
- run:
name: 'Setup gus case management'
command: |
sudo npm install -g @salesforce/change-case-management@latest
- release-management/change-case-create
- install
- compile
- package-extensions
- updating-sha-for-publish
- stage-and-store-artifacts
- run:
name: 'Publishing to the VS Code Marketplace.'
command: npm run vscode:publish
- run:
name: 'Create git tag (e.g. v48.1.0) & push changes back to main branch'
command: |
git tag v${RELEASE_VERSION}
git push origin v${RELEASE_VERSION}
git push origin main
- github-cli/setup
- run:
name: 'Create release on git tag'
command: |
gh release create v${RELEASE_VERSION} ./packages/**/*.vsix --title "Release v${RELEASE_VERSION}" --notes-file ./packages/salesforcedx-vscode/CHANGELOG.md
- slack/notify:
channel: 'pdt_releases'
color: '#9bcd9b'
message: 'VSCode Extensions v${RELEASE_VERSION} have been published to the marketplace'
- slack/notify:
channel: 'pdt_releases'
color: '#FFDEAD'
message: 'VSCode Extensions v${RELEASE_VERSION} Post Publish - Starting merge of main into develop'
- run:
name: 'Merge changes from main back into develop'
command: |
git checkout develop
git pull
git merge main --commit --no-edit
git push origin develop
- slack/notify:
channel: 'pdt_releases'
color: '#9bcd9b'
message: 'VSCode Extensions v${RELEASE_VERSION} Post Publish - Succeeded'
- slack/status:
channel: 'pdt_releases'
fail_only: true
- run:
when: on_fail
name: Close CTC case as Not Implemented
command: |
if [ -z "${SF_CHANGE_CASE_SFDX_AUTH_URL}" ] || [ -z "${SF_CHANGE_CASE_TEMPLATE_ID}" ] || [ -z "${SF_CHANGE_CASE_SCHEDULE_BUILD}" ]; then
echo "Environment not configured for CTC"
else
sfchangecase close --location "https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" --status "Not Implemented"
fi
- run:
when: on_success
name: All Good! Close CTC case/implementations
command: |
if [ -z "${SF_CHANGE_CASE_SFDX_AUTH_URL}" ] || [ -z "${SF_CHANGE_CASE_TEMPLATE_ID}" ] || [ -z "${SF_CHANGE_CASE_SCHEDULE_BUILD}" ]; then
echo "Environment not configured for CTC"
else
sfchangecase close --location "https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME"
fi
create-release-branch:
parameters:
e:
type: executor
executor: << parameters.e >>
steps:
- slack/notify:
channel: 'pdt_releases'
color: '#FFDEAD'
message: 'Starting creation of release branch for VSCode Extensions'
- ssh-config
- checkout
- restore_dependency_cache
- gh-config
- install
- run:
name: Install Lerna
command: sudo npm install -g lerna@<< pipeline.parameters.lerna-version >>
- run:
name: Create release branch
command: |
git branch
scripts/create-release-branch.js -r << pipeline.parameters.publish-type >>
- slack/notify:
channel: 'pdt_releases'
color: '#d8bfd8'
message: 'VSCode Extensions release branch has been cut'
- slack/status:
channel: 'pdt_releases'
fail_only: true
workflows:
version: 2.1
# run a build and a windows test on every commit
commit-workflow:
when:
and:
- not: << pipeline.parameters.create-release >>
- not: << pipeline.parameters.publish >>
- not: << pipeline.parameters.pre-publish >>
jobs:
- build-all
- unit-tests
- integration-tests
pre-publish-workflow:
when: << pipeline.parameters.pre-publish >>
jobs:
- slack/approval-notification:
context: IEAT_keys
message: Pending Approval for merge of release branch into main
channel: 'pdt_releases'
color: '#0E1111'
- hold: # Requires manual approval in Circle Ci
type: approval
- merge-release-branch:
e: default-executor
context: IEAT_keys
requires:
- hold
filters:
branches:
only:
- /^release/v.*/
publish-workflow:
when: << pipeline.parameters.publish >>
jobs:
- slack/approval-notification:
context: IEAT_keys
message: Pending Approval for Publish
channel: 'pdt_releases'
color: '#0E1111'
- build-all
- unit-tests
- integration-tests
- hold: # Requires manual approval in Circle Ci
type: approval
- publish:
e: default-executor
context:
- IEAT_keys
- CLI_CTC
requires:
- build-all
- unit-tests
- integration-tests
- hold
filters:
branches:
only:
- main
create-release-branch-workflow:
when: << pipeline.parameters.create-release >>
jobs:
- slack/approval-notification:
context: IEAT_keys
message: Pending Approval for Creation of Release Branch
channel: 'pdt_releases'
color: '#0E1111'
- hold: # Requires manual approval in Circle Ci
type: approval
- create-release-branch:
e: default-executor
context: IEAT_keys
requires:
- hold
filters:
branches:
only:
- develop
# run a build/test every mid-night
scheduled-workflow:
triggers:
- schedule:
cron: '0 0 * * *'
filters:
branches:
only:
- develop
- main
jobs:
- build-all
- unit-tests
- integration-tests
- soql-ui-tests
cut-release:
triggers:
- schedule:
cron: '0 13 * * 1'
filters:
branches:
only:
- develop
jobs:
- create-release-branch:
e: default-executor
# TODO: Re-enable after issue with dependabot automerge ignoring failed status checks is fixed.
# dependabot-automerge:
# triggers:
# - schedule:
# # Every hour after regular working hours (8pm-4am) specified in UTC
# # on Thu to Fri, giving time before and after release cutoff for changes to get tested
# # Ref: https://circleci.com/docs/2.0/workflows/#scheduling-a-workflow
# cron: '0 4,6,8,10,12 * * 4,5'
# filters:
# branches:
# only:
# - develop
# jobs:
# # Merges 1 mergeable PR created by dependabot containing minor, patch updates
# # Requires "repository" property in package.json to be a string of 'owner/repo'
# - release-management/dependabot-automerge:
# merge-method: squash