-
Notifications
You must be signed in to change notification settings - Fork 70
910 lines (888 loc) · 39.3 KB
/
ci.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
name: CI
on:
# Postsubmit CI on main.
push:
branches:
- main
- release/**
# Presubmit CI on PRs to all branches.
pull_request:
types: [labeled, unlabeled, opened, synchronize, reopened]
# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:
# cancel workflow when a newer version of the workflow is triggered on the same github ref
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: read-all
jobs:
# get matrix for ci-jobs
get_matrix:
name: Load CI Matrix Details
runs-on: ${{ vars.RUNS_ON }}
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE so job can access it
- uses: actions/checkout@v4
with:
sparse-checkout: |
common
# Ensure node version is great enough
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- id: get-matrix
run: echo "matrix=$(node ./common/scripts/workflow-read-matrix.mjs)" >> $GITHUB_OUTPUT
build_packages:
needs: get_matrix
name: 'Build Packages (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE so job can access it
- uses: actions/checkout@v4
with:
# This job requires to fetch the entire history to access to diff the SHA for change file check.
# Otherwise, it can lead to issues when trying to compare branches, as the fetched commits may not
# include the common ancestor between the branches.
fetch-depth: 0
# Ensure node version is great enough
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
# Try get node_modules from cache
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Dependencies
id: install-dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- name: Check result of flavor switch
if: ${{ always() && steps.install-dependencies.outcome == 'failure' }}
run: echo "Failed to install dependencies, please make sure you run `rush update:all-flavors` if dependencies were updated." && exit 1
- name: Check the necessary change file has been submitted
if: ${{ github.event_name == 'pull_request' && !contains( github.event.pull_request.labels.*.name, 'does not need changelog')}}
run: node common/scripts/changelog/check.mjs ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
# Perform lint check
- name: Run linter
run: rush lint
# Builds
- name: Build Packages
run: rush build -v -t @azure/communication-react
# Type check test folder
# - must be run after building all packlets because it depends on compiled packlet dependencies
# - must be run only on beta flavor build because the browser test code is not conditional compiled
- name: Type check test folder
if: ${{ matrix.flavor == 'beta' }}
run: cd packages/react-composites && rushx tsc:e2e
# Verify no uncommitted api extractor changes
- name: API Extractor Check
if: ${{ always() }}
run: |
if [[ -z $(git status ${{ matrix.flavor != 'stable' && '**/review/beta/**' || '**/review/stable/**' }}.md -s) ]]
then
echo "Success, no new api changes found."
else
echo "API CHANGES FOUND in ${{ matrix.flavor }} flavor - PLEASE RUN \"${{ matrix.flavor == 'stable' && 'rush switch-flavor:stable &&' || '' }} rush build -v -t @azure/communication-react\""
echo "Changes:"
git status ${{ matrix.flavor != 'stable' && '**/review/beta/**' || '**/review/stable/**' }}.md -s
exit 1
fi
# Tree-shaking check
- name: Treeshaking check
run: rush build --only @internal/check-treeshaking
# Typescript version check
- name: Typescript version compatibility check
run: rush build --only @internal/check-typescript-regression
# Scripts tests
- name: Test scripts/ folder
run: rush test --only @internal/scripts
# Ensure all downstream packlet versions are consitent with the base packlet version
- name: Ensure all package versions are consistent
run: rush ensure-consistent-versions
# Upload azure-communication api.md files for easy access
- name: Upload communication-react api files
uses: actions/upload-artifact@v4
with:
name: communication-react.${{ matrix.flavor }}.api.json
path: |
packages/communication-react/temp/communication-react.api.json
jest-test-coverage:
needs: [get_matrix, build_packages]
name: 'Jest Test Coverage (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
permissions:
pull-requests: write
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE so job can access it
- uses: actions/checkout@v4
# Ensure node version is great enough
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
# Try get node_modules from cache
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
# Install dependencies
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
# Build and test
- name: Build Packages
run: rush build -v -t @azure/communication-react
- name: Test Packages
run: rush test:ci-coverage -t @azure/communication-react
env:
NODE_OPTIONS: '--max_old_space_size=4096'
- name: Merge all jest test coverage reports from the current branch
# No need to run this step when the base is a release branch
# but it's still needed for the upload bundle report step when main is updated
if: ${{ !startsWith(github.event.pull_request.base.ref, 'release/') }}
run: npx nyc merge temp/jest/coverage/detailed-report/ temp/jest/current/merge/detailed-full/coverage-report.json
- name: Create a summary report from the detailed report
# No need to run this step when the base is a release branch
# but it's still needed for the upload bundle report step when main is updated
if: ${{ !startsWith(github.event.pull_request.base.ref, 'release/') }}
run: npx nyc report --temp-dir temp/jest/current/merge/detailed-full/ --report-dir temp/jest/current/merge/summary/ --reporter json-summary
# Upload coverage report to review the merged report locally
- name: Upload detailed and summary jest coverage reports
uses: actions/upload-artifact@v4
with:
name: jest-coverage-report-${{ matrix.flavor }}
path: temp/jest/current/merge/
# Pull requests show details of coverage changes
- name: Get jest tests coverage of main from gist
if: ${{ github.event_name == 'pull_request' && !startsWith(github.event.pull_request.base.ref, 'release/') }}
run: curl -o temp/jest/base/coverage-report.json "https://gist.github.com/alkwa-msft/${{ matrix.coverage_gist_id }}/raw/communication-react-jest-report-${{ matrix.flavor }}.json" --create-dirs -L
- name: Calculate coverage change
if: ${{ github.event_name == 'pull_request' && !startsWith(github.event.pull_request.base.ref, 'release/') }}
id: coverage
run: |
node ./common/config/workflows/coverage-utils.js ../../../temp/jest/base/coverage-report.json ../../../temp/jest/current/merge/summary/coverage-summary.json lines
node ./common/config/workflows/coverage-utils.js ../../../temp/jest/base/coverage-report.json ../../../temp/jest/current/merge/summary/coverage-summary.json statements
node ./common/config/workflows/coverage-utils.js ../../../temp/jest/base/coverage-report.json ../../../temp/jest/current/merge/summary/coverage-summary.json functions
node ./common/config/workflows/coverage-utils.js ../../../temp/jest/base/coverage-report.json ../../../temp/jest/current/merge/summary/coverage-summary.json branches
- name: Find Comment
if: ${{ github.event_name == 'pull_request' && !startsWith(github.event.pull_request.base.ref, 'release/') }}
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '## @azure/communication-react jest test coverage for ***${{ matrix.flavor }}'
- name: Create or update comment
if: ${{ github.event_name == 'pull_request' && !startsWith(github.event.pull_request.base.ref, 'release/') }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## @azure/communication-react jest test coverage for ***${{ matrix.flavor }}***.
| | Lines | Statements | Functions | Branches |
| --- | :-------: | :-------: | :-------: | :-------: |
| Base |${{ steps.coverage.outputs.base_lines }}|${{ steps.coverage.outputs.base_statements }}|${{ steps.coverage.outputs.base_functions }}|${{ steps.coverage.outputs.base_branches }}|
| Current |${{ steps.coverage.outputs.current_lines }}|${{ steps.coverage.outputs.current_statements }}|${{ steps.coverage.outputs.current_functions }}|${{ steps.coverage.outputs.current_branches }}|
| Diff |${{ steps.coverage.outputs.lines_diff }}|${{ steps.coverage.outputs.statements_diff }}|${{ steps.coverage.outputs.functions_diff }}|${{ steps.coverage.outputs.branches_diff }}|
edit-mode: replace
# Main branch gets coverage report uploaded
- name: Upload bundle report to gist
if: github.ref == 'refs/heads/main'
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
gist_id: ${{ matrix.coverage_gist_id }}
gist_description: 'Jest report for tracking tests coverage for ${{ matrix.flavor }}'
gist_file_name: communication-react-jest-report-${{ matrix.flavor }}.json
file_path: temp/jest/current/merge/summary/coverage-summary.json
in-progress-feature-validation:
needs: get_matrix
name: Check if in progress feature can be removed separately (${{ matrix.flavor }})
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
runs-on: ${{ vars.RUNS_ON }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE so job can access it
- uses: actions/checkout@v4
# Ensure node version is great enough
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
# Try get node_modules from cache
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
# Install dependencies
- name: Install Dependencies
if: ${{ matrix.flavor == 'beta-release'}}
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
# Perform lint check
- name: Run linter
if: ${{ matrix.flavor == 'beta-release'}}
run: rush lint
# Builds
- name: Build Packages
if: ${{ matrix.flavor == 'beta-release'}}
run: rush build -v -t @azure/communication-react
# # Type check test folder
# # - must be run after building all packlets because it depends on compiled packlet dependencies
# # - must be run only on beta flavor build because the browser test code is not conditional compiled
# - name: Type check test folder
# if: ${{ matrix.flavor == 'beta' }}
# run: cd packages/react-composites && rushx tsc:e2e
# Tests
- name: Test Packages
if: ${{ matrix.flavor == 'beta-release'}}
run: rush test -t @azure/communication-react
# Upload azure-communication api.md files for easy access
- name: Upload communication-react api files
if: ${{ matrix.flavor == 'beta-release'}}
uses: actions/upload-artifact@v4
with:
name: communication-react.beta-release.api.json
path: |
packages/communication-react/temp/communication-react.api.json
call_composite_automation_test:
needs: get_matrix
name: 'Call Composite automation test (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
permissions:
pull-requests: write
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 120.0.6099
- name: Build Call Composite Test App
run: |
cd packages/react-composites
rushx build:e2e:call
- name: Install packlets used by browser tests
run: |
cd packages/react-composites
rush build -v -t .
- name: Call Composite Visual Regression Tests
id: visualregressiontests
run: |
cd packages/react-composites
rushx test:e2e:call
env:
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
- name: Upload playwright test results
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e-results-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.flavor }}-call.json
path: packages/react-composites/test-results/*/e2e-results.json
if-no-files-found: error
- name: Upload snapshot diff
if: ${{ always() && steps.visualregressiontests.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: snapshots
path: packages/react-composites/test-results
- name: Comment on PR
if: ${{ github.event_name == 'pull_request' && always() && steps.visualregressiontests.outcome == 'failure' && !contains( github.event.pull_request.labels.*.name, 'update_snapshots') }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Failed to pass the UI Test. If this PR is for UI change and the error is snapshot mismatch, please add "update_snapshots" label to the PR for updating the snapshot.'
})
chat_composite_automation_test:
needs: get_matrix
name: 'Chat Composite automation test (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
permissions:
pull-requests: write
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 120.0.6099
- name: Build Chat Composite Test App
run: |
cd packages/react-composites
rushx build:e2e:chat
- name: Install packlets used by browser tests
run: |
cd packages/react-composites
rush build -v -t .
- name: Chat Composite Visual Regression Tests
id: visualregressiontests
run: |
cd packages/react-composites
rushx test:e2e:chat
env:
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
- name: Upload playwright test results
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e-results-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.flavor }}-chat.json
path: packages/react-composites/test-results/*/e2e-results.json
if-no-files-found: error
- name: Upload snapshot diff
if: ${{ always() && steps.visualregressiontests.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: snapshots
path: packages/react-composites/test-results
- name: Comment on PR
if: ${{ github.event_name == 'pull_request' && always() && steps.visualregressiontests.outcome == 'failure' && !contains( github.event.pull_request.labels.*.name, 'update_snapshots') }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Failed to pass the UI Test. If this PR is for UI change and the error is snapshot mismatch, please add "update_snapshots" label to the PR for updating the snapshot.'
})
call_with_chat_composite_automation_test:
needs: get_matrix
name: 'Call With Chat Composite automation test (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
permissions:
pull-requests: write
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 120.0.6099
- name: Build CallWithChatComposite Test App
run: |
cd packages/react-composites
rushx build:e2e:callwithchat
- name: Install packlets used by browser tests
run: |
cd packages/react-composites
rush build -v -t .
- name: CallWithChatComposite Visual Regression Tests
id: visualregressiontests
run: |
cd packages/react-composites
rushx test:e2e:callwithchat
env:
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
- name: Upload playwright test results
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e-results-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.flavor }}-callwithchat.json
path: packages/react-composites/test-results/*/e2e-results.json
if-no-files-found: error
- name: Upload snapshot diff
if: ${{ always() && steps.visualregressiontests.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: snapshots
path: packages/react-composites/test-results
- name: Comment on PR
if: ${{ github.event_name == 'pull_request' && always() && steps.visualregressiontests.outcome == 'failure' && !contains( github.event.pull_request.labels.*.name, 'update_snapshots') }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Failed to pass the composite UI Test. If this PR is for UI change and the error is snapshot mismatch, please add "update_snapshots" label to the PR for updating the snapshot.'
})
components_automation_test:
needs: get_matrix
name: 'Components automation test (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
permissions:
pull-requests: write
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 120.0.6099
# Build the packages
# This is needed because react-components depends on acs-ui-common and
# acs-ui-common specifies main/module variables in package.json
- name: Build Common Package
run: rush build -v -t acs-ui-common
- name: Components Visual Regression Tests
id: visualregressiontests
run: |
cd packages/react-components
rushx test:components
env:
CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
- name: Upload snapshot diff
if: ${{ always() && steps.visualregressiontests.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: Components-snapshots
path: packages/react-components/tests/temp
- name: Comment on PR
if: ${{ github.event_name == 'pull_request' && always() && steps.visualregressiontests.outcome == 'failure' && !contains( github.event.pull_request.labels.*.name, 'update_snapshots') }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Failed to pass the UI Test. If this PR is for UI change and the error is snapshot mismatch, please add "update_snapshots" label to the PR for updating the snapshot.'
})
build_storybook8:
needs: get_matrix
name: Build Storybook v8 (${{ matrix.flavor }})
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
runs-on: ${{ vars.RUNS_ON }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install rush
run: npm install -g @microsoft/rush@$(jq -r '.rushVersion' "rush.json")
- name: Install dependencies
if: ${{ matrix.flavor == 'beta' || matrix.flavor == 'beta-release'}}
run: rush install --max-install-attempts 3
- name: Build
if: ${{ matrix.flavor == 'beta' || matrix.flavor == 'beta-release' }}
run: rushx build
working-directory: packages/storybook8
- name: Tests
if: ${{ matrix.flavor == 'beta' || matrix.flavor == 'beta-release' }}
run: rushx test
working-directory: packages/storybook8
build_calling_sample:
needs: get_matrix
name: 'Build Calling Sample (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- name: Build dependencies
run: rush build -v -t @azure/communication-react
- name: Build
run: rush build:minify -o calling
- name: Tests
run: rush test -o calling
# upload bundle stats.json which will be consumed later
- uses: actions/upload-artifact@v4
if: ${{ matrix.flavor == 'beta'}}
with:
name: Calling-report
path: samples/Calling/dist/build/report.json
build_chat_sample:
needs: get_matrix
name: 'Build Chat Sample (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- name: Build dependencies
run: rush build -v -t @azure/communication-react
- name: Build
run: rush build:minify -o chat
- name: Tests
run: rush test -o chat
# upload bundle stats.json which will be consumed later
- uses: actions/upload-artifact@v4
if: ${{ matrix.flavor == 'beta'}}
with:
name: Chat-report
path: samples/Chat/dist/build/report.json
build_call_with_chat_sample:
needs: get_matrix
name: 'Build CallWithChat Sample (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- name: Build dependencies
run: rush build -v -t @azure/communication-react
- name: Build
run: rush build:minify -o callwithchat
- name: Tests
run: rush test -o callwithchat
# upload bundle stats.json which will be consumed later
- uses: actions/upload-artifact@v4
if: ${{ matrix.flavor == 'beta'}}
with:
name: CallWithChat-report
path: samples/CallWithChat/dist/build/report.json
build_calling_stateful_samples:
needs: get_matrix
name: 'Build Calling Stateful Samples (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Restore node_modules from cache
uses: actions/cache@v4
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- name: Build dependencies
run: rush build -t @azure/communication-react
- name: Build
run: rush build -o calling-stateful-samples
- name: Tests
run: rush test -o calling-stateful-samples
build_static_html_composites_sample:
needs: get_matrix
name: 'Build And Test Static HTML Composites Sample (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
permissions:
pull-requests: write
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 120.0.6099
- name: Build
run: rush build -v -t sample-static-html-composites
- name: Visual Regression Tests
id: visualregressiontests
run: |
cd samples/tests
npx playwright install --with-deps
rushx test:e2e:bundle
env:
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
- name: Upload snapshot diff
if: ${{ always() && steps.visualregressiontests.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: snapshots
path: samples/tests/test-results/ # or path/to/artifact
- name: Comment on PR
if: ${{ github.event_name == 'pull_request' && always() && steps.visualregressiontests.outcome == 'failure' && !contains( github.event.pull_request.labels.*.name, 'update_snapshots') }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Failed to pass the Static HTML UI Test. If this PR is for UI change and the error is snapshot mismatch, please add "update_snapshots" label to the PR for updating the snapshot.'
})
build_component_examples:
needs: get_matrix
name: 'Build And Test Component+Binding Examples (${{ matrix.flavor }})'
runs-on: ${{ vars.RUNS_ON }}
permissions:
pull-requests: write
strategy:
matrix: ${{ fromJSON(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install Dependencies
run: node ./common/scripts/install-dependencies-ci.mjs ${{ matrix.flavor }}
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 120.0.6099
- name: Build
run: rush build -v -t component-examples
- name: Visual Regression Tests
id: visualregressiontests
run: |
cd samples/tests
npx playwright install --with-deps
rushx test:e2e:examples
env:
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
- name: Upload snapshot diff
if: ${{ always() && steps.visualregressiontests.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: snapshots
path: samples/tests/test-results/ # or path/to/artifact
- name: Comment on PR
if: ${{ github.event_name == 'pull_request' && always() && steps.visualregressiontests.outcome == 'failure' && !contains( github.event.pull_request.labels.*.name, 'update_snapshots') }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Failed to pass the component examples UI Test. If this PR is for UI change and the error is snapshot mismatch, please add "update_snapshots" label to the PR for updating the snapshot.'
})
compare_base_bundle_stats:
runs-on: ${{ vars.RUNS_ON }}
permissions:
pull-requests: write
if: ${{ github.event_name == 'pull_request' && !startsWith(github.event.pull_request.base.ref, 'release/') }}
name: Compare bundle size from pr head ref to base ref - ${{ matrix.app }}
needs: [build_calling_sample, build_chat_sample, build_call_with_chat_sample]
strategy:
matrix:
include:
# These are gist to track bundle sizes
- app: Chat
gist: https://gist.github.com/alkwa-msft/f19649d941b2739b13402ee4802aa851
- app: Calling
gist: https://gist.github.com/alkwa-msft/8160c0362cb05b7b09f3dbf803007c73
- app: CallWithChat
gist: https://gist.github.com/alkwa-msft/c43393ae31b5b08215f3f49ed327d912
steps:
# checkout base bundle stats
- name: Get bundle stats of main from gist
run: curl -o base/report.json "${{ matrix.gist }}/raw/${{ matrix.app }}-report.json" --create-dirs -L
- uses: actions/download-artifact@v4
with:
path: current
name: ${{ matrix.app }}-report
- name: Calculate size change
id: bundles
run: |
base_size=$(jq -r ".[0].parsedSize" base/report.json)
echo "base_size=${base_size}" >> $GITHUB_OUTPUT
current_size=$(jq -r ".[0].parsedSize" current/report.json)
echo "current_size=${current_size}" >> $GITHUB_OUTPUT
change=$([ $current_size -gt $base_size ] && echo "increased❗" || ([ $current_size = $base_size ] && echo "not changed" || echo "decreased✅"))
echo "change=${change}" >> $GITHUB_OUTPUT
echo "diff=$(($current_size - $base_size))" >> $GITHUB_OUTPUT
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '## ${{ matrix.app }} bundle size is'
- name: Checkout repository
uses: actions/checkout@v4
- name: Delete existing comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const commentId = '${{ steps.fc.outputs.comment-id }}'
if (commentId) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: commentId
})
}
- name: Post new comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `## ${{ matrix.app }} bundle size is ***${{ steps.bundles.outputs.change }}***.
- Current size: ${{ steps.bundles.outputs.current_size }}
- Base size: ${{ steps.bundles.outputs.base_size }}
- Diff size: ${{ steps.bundles.outputs.diff }}`
});
- name: Check whether the bundle size is increased significantly
if: ${{ github.event_name == 'pull_request' && !contains( github.event.pull_request.labels.*.name, 'significant bundle size change') }}
run: |
significantBundleSizeThreshold=800
app="${{ matrix.app }}"
bundleSizeDiff="${{ steps.bundles.outputs.diff }}"
if [ "$bundleSizeDiff" -ge "$significantBundleSizeThreshold" ]; then
echo "The bundle size diff for $app is greater than the threshold of $significantBundleSizeThreshold kb! If the bundle size increase is intended, please add \`significant bundle size change\` label to the PR." >&2
exit 1
fi
echo "Bundle size diff for $app is below the threshold of $significantBundleSizeThreshold. All is good!"
update_base_bundle_report:
runs-on: ${{ vars.RUNS_ON }}
name: Upload bundle size report to gist - ${{ matrix.app }}
needs: [build_calling_sample, build_chat_sample, build_call_with_chat_sample]
if: github.ref == 'refs/heads/main'
strategy:
matrix:
include:
# These are gist to track bundle sizes
- app: Chat
gist_id: f19649d941b2739b13402ee4802aa851
- app: Calling
gist_id: 8160c0362cb05b7b09f3dbf803007c73
- app: CallWithChat
gist_id: c43393ae31b5b08215f3f49ed327d912
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.app }}-report
- name: Upload bundle report to gist
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
gist_id: ${{ matrix.gist_id }}
gist_description: 'Bundle report for tracking ${{ matrix.app }} sample app'
gist_file_name: ${{ matrix.app }}-report.json
file_path: report.json
check_failure:
runs-on: ${{ vars.RUNS_ON }}
permissions:
issues: write
needs:
[build_packages, build_calling_sample, build_chat_sample, build_static_html_composites_sample, build_storybook8]
if: failure() && github.ref == 'refs/heads/main'
name: File issue if main CI failed
steps:
# Create a GitHub issue if the CI failed when running on the `main` branch
- name: Create issue if main branch CI failed
id: create-issue
run: |
# check for an issue that is already open
curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/search/issues?q=org:Azure+repo:communication-ui-library+label:CI_FAILURE+state:open > $HOME/ci_issues.json
issue_count=$(jq -r '.total_count' $HOME/ci_issues.json)
if [ $issue_count -gt 0 ]; then
echo "No need to create new issue, one already exists"
else
curl -X POST -H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/Azure/communication-ui-library/issues -d '{"title":"Main branch CI Failed", "body": "Main CI Pipeline has failed. Please investigate: https://github.com/Azure/communication-ui-library/actions/runs/${{ github.run_id }}", "labels":["CI_FAILURE", "status:triage"]}'
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}