-
-
Notifications
You must be signed in to change notification settings - Fork 168
796 lines (677 loc) · 34.6 KB
/
build.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
# Pipeline for Nebula Logger
name: Build
env:
SF_DISABLE_AUTOUPDATE: true
SF_LOG_LEVEL: debug
SF_SKIP_NEW_VERSION_CHECK: true
on:
push:
branches:
- main
paths:
- .github/workflows/**
- config/scratch-orgs/**
- nebula-logger/**
- sfdx-project.json
pull_request:
types: [opened, synchronize, reopened]
paths:
- .github/workflows/**
- config/scratch-orgs/**
- nebula-logger/**
- sfdx-project.json
jobs:
code-quality-tests:
name: 'Run Code Quality Tests'
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Check for changes in core directory'
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
core:
- './nebula-logger/core/**'
- name: 'Authorize Dev Hub'
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.draft == false) && (steps.changes.outputs.core == 'true') }}
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Verify package version number is updated'
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.draft == false) && (steps.changes.outputs.core == 'true') }}
run: npm run package:version:number:verify
- name: 'Verify LWC with ESLint'
run: npm run scan:lwc
- name: 'Verify Apex with SFDX Scanner'
run: |
npm run sf:plugins:link:scanner
npm run scan:apex
# TODO - uncomment - temporarily commented-out due to an issue with apexdocs in the pipeline
# - name: 'Verify docs are updated'
# run: npm run docs:verify
- name: 'Verify formatting with Prettier'
run: npm run prettier:verify
lwc-jest-tests:
name: 'Run LWC Jest Tests'
needs: [code-quality-tests]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Run LWC Tests'
run: npm run test:lwc
- name: 'Upload LWC code coverage to Codecov.io'
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
flags: LWC
token: ${{ secrets.CODECOV_TOKEN }}
advanced-scratch-org-tests:
environment: 'Advanced Scratch Org'
name: 'Run Advanced Scratch Org Tests'
needs: [code-quality-tests]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Authorize Dev Hub'
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Create Scratch Org'
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/advanced-scratch-def.json --wait 20 --set-default --json
# https://help.salesforce.com/s/articleView?id=000394906&type=1
- name: 'Install OmniStudio managed package v250.7.1 (Summer ‘24 release)'
run: npx sf package install --package 04t4W000002Z6oC --security-type AdminsOnly --wait 30 --no-prompt
# To ensure that all of the Apex classes in the core directory have 75+ code coverage,
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests`
- name: 'Validate Core Source in Scratch Org'
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata
- name: 'Deploy All Source to Scratch Org'
run: npx sf project deploy start --source-dir ./nebula-logger/
- name: 'Deploy Test Metadata'
run: npx sf project deploy start --source-dir ./config/scratch-orgs/
- name: 'Assign Logger Admin Permission Set'
run: npm run permset:assign:admin
- name: 'Validate Custom Metadata Records'
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session.
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously.
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously).
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of
# integration testing to ensure that everything works with or without an active session.
- name: 'Run Apex Tests Asynchronously'
run: npm run test:apex:nocoverage
- name: 'Run Apex Tests Synchronously'
run: npm run test:apex:nocoverage -- --synchronous
- name: 'Delete Scratch Org'
run: npx sf org delete scratch --no-prompt
if: ${{ always() }}
base-scratch-org-tests:
environment: 'Base Scratch Org'
name: 'Run Base Scratch Org Tests'
needs: [code-quality-tests]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Authorize Dev Hub'
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Create Scratch Org'
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/base-scratch-def.json --wait 20 --set-default --json
# To ensure that all of the Apex classes in the core directory have 75+ code coverage,
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests`
- name: 'Validate Core Source in Scratch Org'
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata
- name: 'Deploy All Source to Scratch Org'
run: npx sf project deploy start --source-dir ./nebula-logger/
- name: 'Assign Logger Admin Permission Set'
run: npm run permset:assign:admin
- name: 'Validate Custom Metadata Records'
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session.
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously.
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously).
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of
# integration testing to ensure that everything works with or without an active session.
- name: 'Run Apex Tests Asynchronously'
run: npm run test:apex:nocoverage
- name: 'Run Apex Tests Synchronously'
run: npm run test:apex:nocoverage -- --synchronous
- name: 'Delete Scratch Org'
run: npx sf org delete scratch --no-prompt
if: ${{ always() }}
event-monitoring-scratch-org-tests:
environment: 'Event Monitoring Scratch Org'
name: 'Run Event Monitoring Scratch Org Tests'
needs: [code-quality-tests]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Authorize Dev Hub'
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Create Scratch Org'
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/event-monitoring-scratch-def.json --wait 20 --set-default --json
# To ensure that all of the Apex classes in the core directory have 75+ code coverage,
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests`
- name: 'Validate Core Source in Scratch Org'
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata
- name: 'Deploy All Source to Scratch Org'
run: npx sf project deploy start --source-dir ./nebula-logger/
- name: 'Assign Logger Admin Permission Set'
run: npm run permset:assign:admin
- name: 'Validate Custom Metadata Records'
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session.
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously.
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously).
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of
# integration testing to ensure that everything works with or without an active session.
- name: 'Run Apex Tests Asynchronously'
run: npm run test:apex:nocoverage
- name: 'Run Apex Tests Synchronously'
run: npm run test:apex:nocoverage -- --synchronous
- name: 'Delete Scratch Org'
run: npx sf org delete scratch --no-prompt
if: ${{ always() }}
experience-cloud-scratch-org-tests:
environment: 'Experience Cloud Scratch Org'
name: 'Run Experience Cloud Scratch Org Tests'
needs: [code-quality-tests, advanced-scratch-org-tests]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Authorize Dev Hub'
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Create Scratch Org'
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/experience-cloud-scratch-def.json --wait 20 --set-default --json
# To ensure that all of the Apex classes in the core directory have 75+ code coverage,
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests`
- name: 'Validate Core Source in Scratch Org'
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata
- name: 'Deploy All Source to Scratch Org'
run: npx sf project deploy start --source-dir ./nebula-logger/
- name: 'Deploy Test Experience Sites Metadata'
run: npx sf project deploy start --source-dir ./config/scratch-orgs/experience-cloud/
- name: 'Assign Logger Admin Permission Set'
run: npm run permset:assign:admin
- name: 'Validate Custom Metadata Records'
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session.
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously.
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously).
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of
# integration testing to ensure that everything works with or without an active session.
- name: 'Run Apex Tests Asynchronously'
run: npm run test:apex:nocoverage
- name: 'Run Apex Tests Synchronously'
run: npm run test:apex:nocoverage -- --synchronous
- name: 'Delete Scratch Org'
run: npx sf org delete scratch --no-prompt
if: ${{ always() }}
omnistudio-scratch-org-tests:
environment: 'OmniStudio Scratch Org'
name: 'Run OmniStudio Scratch Org Tests'
needs: [code-quality-tests, base-scratch-org-tests]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Authorize Dev Hub'
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Create Scratch Org'
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/omnistudio-scratch-def.json --wait 20 --set-default --json
# https://help.salesforce.com/s/articleView?id=000394906&type=1
- name: 'Install OmniStudio managed package v250.7.1 (Summer ‘24 release)'
run: npx sf package install --package 04t4W000002Z6oC --security-type AdminsOnly --wait 30 --no-prompt
# To ensure that all of the Apex classes in the core directory have 75+ code coverage,
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests`
- name: 'Validate Core Source in Scratch Org'
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata
- name: 'Deploy All Source to Scratch Org'
run: npx sf project deploy start --source-dir ./nebula-logger/
- name: 'Deploy Test OmniStudio Metadata'
run: npx sf project deploy start --source-dir ./config/scratch-orgs/omnistudio/
- name: 'Assign Logger Admin Permission Set'
run: npm run permset:assign:admin
- name: 'Validate Custom Metadata Records'
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session.
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously.
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously).
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of
# integration testing to ensure that everything works with or without an active session.
- name: 'Run Apex Tests Asynchronously'
run: npm run test:apex:nocoverage
- name: 'Run Apex Tests Synchronously'
run: npm run test:apex:nocoverage -- --synchronous
- name: 'Delete Base Scratch Org'
run: npx sf org delete scratch --no-prompt
if: ${{ always() }}
platform-cache-scratch-org-tests:
environment: 'Platform Cache Scratch Org'
name: 'Run Platform Cache Scratch Org Tests'
needs: [code-quality-tests, event-monitoring-scratch-org-tests]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Authorize Dev Hub'
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Create Scratch Org'
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/platform-cache-scratch-def.json --wait 20 --set-default --json
# To ensure that all of the Apex classes in the core directory have 75+ code coverage,
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests`
- name: 'Validate Core Source in Scratch Org'
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata
- name: 'Deploy All Source to Scratch Org'
run: npx sf project deploy start --source-dir ./nebula-logger/
- name: 'Assign Logger Admin Permission Set'
run: npm run permset:assign:admin
- name: 'Validate Custom Metadata Records'
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session.
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously.
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously).
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of
# integration testing to ensure that everything works with or without an active session.
- name: 'Run Apex Tests Asynchronously'
run: npm run test:apex:nocoverage
- name: 'Run Apex Tests Synchronously'
run: npm run test:apex:nocoverage -- --synchronous
- name: 'Delete Scratch Org'
run: npx sf org delete scratch --no-prompt
if: ${{ always() }}
create-managed-package-beta:
if: ${{ github.ref != 'refs/heads/main' }}
environment: 'Base Scratch Org'
name: 'Create Managed Package Beta'
needs:
[
code-quality-tests,
lwc-jest-tests,
advanced-scratch-org-tests,
base-scratch-org-tests,
event-monitoring-scratch-org-tests,
experience-cloud-scratch-org-tests,
omnistudio-scratch-org-tests,
platform-cache-scratch-org-tests
]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Authorize Dev Hub'
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Create Beta Managed Package Version'
run: npm run package:version:create:managed
create-unlocked-package-release-candidate:
if: ${{ github.ref != 'refs/heads/main' }}
environment: 'Base Scratch Org'
name: 'Create Core Package Release Candidate'
needs: [create-managed-package-beta]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Authorize Dev Hub'
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Create Scratch Org'
run: npx sf org create scratch --no-namespace --no-track-source --alias base_package_subscriber_scratch_org --duration-days 1 --definition-file ./config/scratch-orgs/base-scratch-def.json --wait 20 --set-default --json
- name: 'Create & Install Package Version'
run: npx pwsh ./scripts/build/create-and-install-package-version.ps1 -targetpackagealias '"Nebula Logger - Core"' -targetreadme ./README.md -targetusername base_package_subscriber_scratch_org
# This is the only place in Nebula Logger's pipeline where the `LoggerCore` test suite runs & the results are sent to Codecov.io.
# This is specifically done in the base scratch org, using only the `LoggerCore test` suite, in order to help validate that the core metadata
# provides sufficient code coverage for teams that deploy Nebula Logger's metadata directly to their org, instead of installing one of Nebula Logger's 2GP packages.
# 1. Many teams cannot use one of the 2GP packages for various reasons, including company policies, security concerns, etc.,
# and being able to deploy the core metadata is something that should be supported.
# 2. And even though the pipeline runs the `extra-tests` directory to validate logging works correctly in various types of scratch orgs,
# for teams that are trying to deploy Nebula Logger's metadata, it's critical that the core tests have sufficient code coverage to be deployed to a prod org.
# - In the past, this has not always been the case, resulting in some teams having deployment issues & project delays due to the low code coverage
# that was (formerly) provided by some of the core tests classes.
# - In orgs that do not have some optional Salesforce features enabled/available (e.g., orgs without Experience Cloud, OmniStudio, Platform Cache, etc.),
# the code coverage can be especially low, so using the base scratch org acts
#
# So now only the core test suite's results, from a base scratch org, are used for reporting code coverage, even though the project's overall code coverage
# is much higher when using the `extra-tests` directory.
- name: 'Get Core Test Suite Code Coverage'
run: npm run test:apex:suite:core
# This is the only scratch org that's used for uploading code coverage
- name: 'Upload Apex test code coverage to Codecov.io'
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
flags: Apex
token: ${{ secrets.CODECOV_TOKEN }}
# The metadata API / sf CLI support deploying metadata using package manifest XML files - see docs for more details:
# Docs: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/manifest_samples.htm
# _Some_ people (@jongpie) dislike using manifest files, and find them to be unnecessary for most teams/projects/implementations.
#
#
#
# But sometimes.................
# ...........
# .......just............
#.........occassionally.........
# .........
#..................ooooooooooooooooccassionally.........
# ..........................
# ....... every.......
# ...................once in a while.....
# ...........
# .........
# .....somewhere.....
# .......................
# ...........
# .............
# ...................
# ...........there are a few brave individuals....
# ...............
# .....tasked with the impossible task....
# .........
# ................
# .........
# .........
# ... Deploy a crazy amount of stuff to production..........
# ...................................
# .......all at once.......
# ...........................
# ....................
# ...........WITHOUT............................................
# ................A.....................
# ..................PROPER...................
# .......................PIPELINE!!!!!!!........?!
# ...
# ...
# ...
# 💀💀💀💀😱😱😱😭😭😭😭
# ...
# ...
# ...
# ...
# ...
# ...
# So, let's auto-generate an up-to-date package manifest XML file and store it in the repo,
# juuuuuuust in case another fellow Salesforce nerd ever needs them....
# ..............
# ...................
# ...............
# .....
# .........and may the force......
# ........................
# .......be with you..........
# ....................
# .....
# ...
# TODO Add some extra steps to try to deploy to the scratch org, using the manifest file, to ensure it works
- name: 'Generate core package metadata manifest file'
run: |
npm run package:manifest:generate:core
git add ./nebula-logger/core.package.xml
git commit -m "Generated updated package.xml manifest file for core unlocked package version"
- name: 'Commit New Package Version'
if: ${{ github.event_name == 'pull_request' }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action Bot"
# npm run sf:plugins:link:bummer
echo y | npx sf plugins install @jongpie/sfdx-bummer-plugin --force
npx sf bummer:package:aliases:sort
npx prettier --write ./sfdx-project.json
git add ./sfdx-project.json
git commit -m "Created new core unlocked package version"
git push
promote-package-versions:
if: ${{ github.ref == 'refs/heads/main' }}
name: 'Promote Package Versions'
needs:
[
code-quality-tests,
lwc-jest-tests,
advanced-scratch-org-tests,
base-scratch-org-tests,
event-monitoring-scratch-org-tests,
experience-cloud-scratch-org-tests,
omnistudio-scratch-org-tests,
platform-cache-scratch-org-tests
]
runs-on: ubuntu-22.04
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Authorize Dev Hub'
shell: bash
run: |
npx sf version
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
- name: 'Promote package versions'
run: npx pwsh ./scripts/build/promote-readme-packages.ps1