-
Notifications
You must be signed in to change notification settings - Fork 382
1637 lines (1458 loc) · 70.6 KB
/
Copy pathpr-builder.yml
File metadata and controls
1637 lines (1458 loc) · 70.6 KB
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
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This workflow will build the project on pull requests with tests
# Uses:
# OS: ubuntu-latest
# Go: go 1.x
name: 👷🛠️ PR Builder
# TEMPORARY WORKAROUND for runner saturation (see #4268): on pull requests, the
# builder only runs once the `trigger-pr-builder` label is present. Early pushes
# iterate against the review bots without consuming runners, and the label
# (added when the PR is ready) turns CI on for that push and every subsequent
# one. Merge queue runs are always on. Remove this gate (restore unconditional
# pull_request runs) once queue pressure is resolved.
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
merge_group:
workflow_dispatch:
# Avoid running multiple PR builders for the same PR on subsequent pushes. GitHub Actions'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GOFLAGS: "-mod=readonly"
PRODUCT_NAME: "ThunderID"
PRODUCT_NAME_LOWER: "thunderid"
NODE_VERSION: "lts/*"
jobs:
# Single job for the fast gate checks (security audit, dependency review, and
# change detection for docs/PowerShell) so they occupy one runner slot instead
# of four. Runner concurrency is shared across all PRs, so fewer jobs per run
# directly reduces queue time on busy periods.
#
# This is also the root of the job graph: every other job depends on it, so a
# run requests one runner up front instead of eight competing for slots, and
# nothing expensive starts until these ~20s of checks pass.
preflight:
name: 🛡️ Preflight Checks
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
outputs:
docs-changed: ${{ steps.filter.outputs.docs }}
powershell-changed: ${{ steps.filter.outputs.powershell }}
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
# Diff-based steps need a base/head pair from the pull_request or
# merge_group payload, which a manual dispatch does not carry.
- name: 🔍 Detect Docs and PowerShell Changes
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: filter
with:
base: ${{ github.event_name == 'merge_group' && github.event.merge_group.base_sha || github.event.pull_request.base.sha }}
ref: ${{ github.event_name == 'merge_group' && github.sha || github.event.pull_request.head.sha }}
filters: |
docs:
- 'docs/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
powershell:
- '**.ps1'
- '.github/workflows/windows-powershell-validation.yml'
# This job only audits the lockfile, so it must not cache a pnpm store:
# an empty store published here is what every later job restored.
- name: ⚙️ Set up Node.js and pnpm
uses: ./.github/actions/setup-pnpm
with:
node-version: ${{ env.NODE_VERSION }}
cache-store: 'false'
- name: 🔍 Run pnpm audit
run: |
echo "🔍 Running pnpm audit for all workspace dependencies..."
# CVE ignores are managed via auditConfig.ignoreCves in pnpm-workspace.yaml
# Remove `--ignore-registry-errors` once pnpm 11 is generally available. Tracker: https://github.com/pnpm/pnpm/issues/11265
pnpm audit --ignore-registry-errors --audit-level=high
- name: 🔎 Dependency Review
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4
with:
fail-on-severity: high
deny-licenses: GPL-3.0-only,GPL-3.0-or-later,AGPL-3.0-only,AGPL-3.0-or-later
comment-summary-in-pr: always
base-ref: ${{ github.event_name == 'merge_group' && github.event.merge_group.base_sha || github.event.pull_request.base.sha }}
head-ref: ${{ github.event_name == 'merge_group' && github.sha || github.event.pull_request.head.sha }}
codecov-merge-queue-status:
name: 📊 Codecov Merge Queue Status
# Codecov does not reliably process merge queue (merge_group) commits, leaving the
# required codecov/patch status stuck at "Expected" and timing the queue entry out.
# Patch coverage is already enforced on the pull request before it can enter the
# queue, and the queue commit carries the same diff rebased onto main, so this job
# marks codecov/patch as passed on the queue commit instead of re-running Codecov.
# Tracker: https://github.com/codecov/codecov-action/issues/1796
if: github.event_name == 'merge_group'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
statuses: write
steps:
- name: 📊 Mark codecov/patch as passed on the merge queue commit
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api "repos/${{ github.repository }}/statuses/${{ github.sha }}" \
-f state=success \
-f context=codecov/patch \
-f description="Patch coverage was enforced on the pull request"
verify-mocks:
name: 🔍 Verify Mock Files
needs: [preflight]
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: 🔧 Install Mockery
run: make install-mockery
- name: 🏭 Generate Mocks
run: make mockery
- name: 🔎 Check for Outdated Mocks
run: |
if [ -n "$(git status --porcelain --untracked-files=all -- backend/tests/mocks backend/internal)" ]; then
echo "❌ Mock files are out of sync with interface definitions!"
echo ""
echo "The following mock files need to be regenerated:"
git status --porcelain --untracked-files=all -- backend/tests/mocks backend/internal | awk '{print $2}'
echo ""
echo "To fix this:"
echo " 1. Run: make mockery"
echo " 2. Commit the updated mock files"
echo " 3. Push your changes"
echo ""
echo "This ensures mock implementations stay synchronized with their interfaces."
exit 1
fi
echo "✅ All mock files are up to date"
lint:
name: 🧹 Lint Code
needs: [preflight]
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
# We need the full history so that Turbo's --affected can diff against the PR or merge-group base commit.
fetch-depth: 0
- name: ⚙️ Set up Node.js and pnpm
uses: ./.github/actions/setup-pnpm
with:
node-version: ${{ env.NODE_VERSION }}
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: 📦 Prepare golangci-lint Locally
run: make golangci-lint
- name: 🔍 Run Backend Linter
run: make lint_backend
# The frontend build is needed because linting is type-aware: apps resolve
# @thunderid/* package types from their built dist output. The Turbo cache
# makes it a near no-op when nothing relevant changed.
- name: 🗂️ Set up Turbo Cache
uses: ./.github/actions/setup-turbo-cache
- name: 🧩 Install Dependencies & Build Frontend
run: |
make build_frontend
- name: 🔍 Run Frontend Linter
run: |
pnpm turbo run lint --affected --filter=!./tests/**
env:
TURBO_SCM_BASE: ${{ github.event_name == 'merge_group' && github.event.merge_group.base_sha || github.event.pull_request.base.sha }}
- name: 🎨 Check Frontend Formatting
run: |
pnpm format:check
build:
name: 🛠️ Build Product
needs: [preflight]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
id-token: write
contents: read
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: ⚙️ Set up Node.js and pnpm
uses: ./.github/actions/setup-pnpm
with:
node-version: ${{ env.NODE_VERSION }}
- name: 🗄️ Cache Go Modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
id: cache-go-modules
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-modules-
- name: 📦 Install Backend Dependencies
run: |
cd backend
go mod download
cd ../tests/integration
go mod download
- name: 🗂️ Set up Turbo Cache
uses: ./.github/actions/setup-turbo-cache
- name: 📦 Install Frontend Dependencies
run: |
pnpm install --frozen-lockfile
- name: 🧹 Clean Previous Builds
run: |
set -e
make clean
- name: 🔨 Build Frontend
env:
# Activates the Codecov bundle-analysis plugin in the gate/console Vite
# builds, which uploads bundle stats to Codecov via GitHub OIDC.
CODECOV_BUNDLE_UPLOAD: "true"
run: |
make build_frontend
- name: 🔨 Build Backend with Coverage Instrumentation
run: |
set -e
export LOG_LEVEL=debug
ENABLE_COVERAGE=true ./build.sh build_backend $(go env GOOS) $(go env GOARCH)
# Find the built distribution
DIST_PATH=$(find target/dist -name "$PRODUCT_NAME_LOWER-*.zip" | head -1)
echo "Built distribution: $DIST_PATH"
- name: 📦 Upload Built Distribution
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: product-distribution
path: target/dist/*.zip
if-no-files-found: error
test-backend-unit:
name: 🧪 Backend Unit Tests
needs: [preflight]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
id-token: write
contents: read
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: 🗄️ Cache Go Modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-modules-
- name: 📦 Install Backend Dependencies
run: |
cd backend
go mod download
- name: 🧪 Run Backend Unit Tests
run: |
set -e
./build.sh test_unit $(go env GOOS) $(go env GOARCH)
- name: 📊 Upload Unit Test Coverage Report to Codecov
# Skipped on merge queue commits: Codecov cannot process them, and the
# codecov-merge-queue-status job stamps the required status instead.
if: github.event_name != 'merge_group'
uses: codecov/codecov-action@v5
timeout-minutes: 5
continue-on-error: true
with:
use_oidc: true
files: backend/coverage_unit.out
disable_search: true
flags: backend-unit
name: Backend Unit Tests
fail_ci_if_error: false
- name: 📦 Archive Unit Coverage Report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: unit-coverage-report
path: backend/coverage_unit.out
if-no-files-found: error
test-frontend-packages:
name: 🧪 Frontend Packages Tests
needs: [preflight]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
# Checkout, turbo cache and artifact upload need nothing beyond read access; the
# artifact action authenticates with its own token rather than the GITHUB_TOKEN.
permissions:
contents: read
container:
image: mcr.microsoft.com/playwright:v1.60.0-noble
options: --user root
# PLAYWRIGHT_BROWSERS_PATH: the Playwright image installs browsers under /ms-playwright but
# some tooling (e.g. @vitest/browser-playwright) resolves off HOME/.cache/ms-playwright
# when the image's ENV is masked by the runner. Pinning at job level guarantees resolution.
#
# HOME=/root: GitHub Actions overrides HOME=/github/home for container jobs, but that
# directory is owned by uid 1001 (the default runner user); since we run as root, Firefox
# refuses to launch ("$HOME folder isn't owned by the current user"). Chromium and WebKit
# tolerate it; Firefox does not. Setting HOME=/root aligns ownership with the running user.
env:
PLAYWRIGHT_BROWSERS_PATH: /ms-playwright
HOME: /root
# GitHub Actions defaults container jobs to POSIX `sh`; force bash so brace expansion,
# arrays, and `[[ ... ]]` used elsewhere in this workflow behave the same as on runners.
defaults:
run:
shell: bash
timeout-minutes: 30
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- name: 📦 Enable pnpm via corepack
# The Playwright image ships Node with corepack; use it instead of setup-node/setup-pnpm,
# both of which are noisy inside containers and add ~15-20s.
run: |
corepack enable
corepack prepare pnpm@11.21.0 --activate
pnpm --version
- name: 📦 Install Frontend Dependencies
run: |
pnpm install --frozen-lockfile
- name: 🗂️ Set up Turbo Cache
uses: ./.github/actions/setup-turbo-cache
- name: 🔨 Build Frontend Packages
working-directory: frontend
run: |
pnpm build:packages
- name: 🧪 Run Tests for Frontend Packages with Coverage
working-directory: frontend
run: |
pnpm test:packages:coverage
# Each package writes its own coverage/lcov.info with repo-relative paths, so the
# whole set is uploaded under one flag rather than one flag per package.
- name: 📤 Upload packages coverage artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: packages-coverage
path: frontend/packages/*/coverage/lcov.info
if-no-files-found: error
test-frontend-gate-app:
name: 🧪 Gate App Tests with Coverage
needs: [preflight]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Node.js and pnpm
uses: ./.github/actions/setup-pnpm
with:
node-version: ${{ env.NODE_VERSION }}
- name: 📦 Install Frontend Dependencies
run: |
pnpm install --frozen-lockfile
- name: 🗂️ Set up Turbo Cache
uses: ./.github/actions/setup-turbo-cache
- name: 🔨 Build Frontend
run: |
pnpm build:frontend
- name: 🧪 Run Gate Tests with Coverage
run: |
cd frontend/apps/gate
pnpm test:coverage
# Strip branch data (BRDA/BRF/BRH) from frontend LCOV reports before uploading.
# React Compiler (babel-plugin-react-compiler) generates phantom branch points in compiled
# output that inflate the partial-line count in Codecov's coverage calculation.
# This is a known upstream issue: https://github.com/facebook/react/issues/32950
# Line and function coverage remain unaffected and accurately reflect test quality.
- name: 🧹 Strip branch data from gate LCOV report
run: |
if [ -f "frontend/apps/gate/coverage/lcov.info" ]; then
sed -i '/^BRDA:/d;/^BRF:/d;/^BRH:/d' "frontend/apps/gate/coverage/lcov.info"
fi
- name: 📦 Upload gate coverage artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: gate-coverage
path: frontend/apps/gate/coverage/lcov.info
if-no-files-found: error
# The console suite is the longest job in the pipeline (~12 min of vitest in a
# single run), so it is split across shards that execute concurrently. Each
# shard reports coverage for the whole app with only its own tests counted;
# test-frontend-console-app below merges the partial reports back into one
# LCOV file, so coverage consumers still see a single console-coverage
# artifact.
test-frontend-console-app-shards:
name: 🧪 Console App Tests (shard ${{ matrix.shard }})
needs: [preflight]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
# Report every failing shard, not just the first one, so a single run
# surfaces all breakages.
fail-fast: false
matrix:
shard: [1, 2, 3]
env:
SHARD_COUNT: 3
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Node.js and pnpm
uses: ./.github/actions/setup-pnpm
with:
node-version: ${{ env.NODE_VERSION }}
- name: 📦 Install Frontend Dependencies
run: |
pnpm install --frozen-lockfile
- name: 🗂️ Set up Turbo Cache
uses: ./.github/actions/setup-turbo-cache
- name: 🔨 Build Frontend
run: |
pnpm build:frontend
- name: 🧪 Run Console Tests with Coverage
working-directory: frontend/apps/console
run: |
pnpm exec vitest run --coverage --shard=${{ matrix.shard }}/${{ env.SHARD_COUNT }}
# Strip branch data (BRDA/BRF/BRH) from frontend LCOV reports before uploading.
# React Compiler (babel-plugin-react-compiler) generates phantom branch points in compiled
# output that inflate the partial-line count in Codecov's coverage calculation.
# This is a known upstream issue: https://github.com/facebook/react/issues/32950
# Line and function coverage remain unaffected and accurately reflect test quality.
- name: 🧹 Strip branch data from console LCOV report
run: |
if [ -f "frontend/apps/console/coverage/lcov.info" ]; then
sed -i '/^BRDA:/d;/^BRF:/d;/^BRH:/d' "frontend/apps/console/coverage/lcov.info"
fi
# Named without "coverage" so the patch coverage gate, which downloads
# every "*coverage*" artifact, only ever sees the merged report.
- name: 📦 Upload console shard LCOV report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: console-lcov-shard-${{ matrix.shard }}
path: frontend/apps/console/coverage/lcov.info
if-no-files-found: error
# Keeps the console suite reporting as one check and one coverage artifact
# regardless of how many shards run. Uses always() with an explicit result
# check so a failing shard fails this job too: a skipped required check counts
# as passing for branch protection, which would let a red shard through.
test-frontend-console-app:
name: 🧪 Console App Tests with Coverage
needs: [test-frontend-console-app-shards]
if: ${{ always() && (github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group') }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: ✅ Check shard results
env:
SHARDS_RESULT: ${{ needs.test-frontend-console-app-shards.result }}
run: |
if [ "$SHARDS_RESULT" != "success" ]; then
echo "❌ Console test shards did not pass (result: $SHARDS_RESULT)"
exit 1
fi
echo "✅ All console test shards passed"
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- name: 📥 Download console shard LCOV reports
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
pattern: console-lcov-shard-*
path: console-shards
- name: 🧩 Merge console shard LCOV reports
uses: ./.github/actions/merge-lcov
with:
reports-dir: console-shards
output-file: frontend/apps/console/coverage/lcov.info
- name: 📦 Upload console coverage artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: console-coverage
path: frontend/apps/console/coverage/lcov.info
if-no-files-found: error
upload-frontend-coverage:
name: 📊 Upload Frontend Coverage
needs: [test-frontend-gate-app, test-frontend-console-app, test-frontend-packages]
if: always() && (needs.test-frontend-gate-app.result == 'success' && needs.test-frontend-console-app.result == 'success' && needs.test-frontend-packages.result == 'success')
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
id-token: write
contents: read
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: 📥 Download console coverage artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: console-coverage
path: coverage/console
- name: 📥 Download gate coverage artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: gate-coverage
path: coverage/gate
- name: 📥 Download packages coverage artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: packages-coverage
path: coverage/packages
- name: 📊 Upload `@thunderid/console` Unit Test Coverage Report to Codecov
if: github.event_name != 'merge_group'
uses: codecov/codecov-action@v5
timeout-minutes: 5
continue-on-error: true
with:
use_oidc: true
files: coverage/console/lcov.info
disable_search: true
flags: frontend-apps-console-unit
name: Frontend Console App Unit Tests
fail_ci_if_error: false
- name: 📊 Upload `@thunderid/gate` Unit Test Coverage Report to Codecov
if: github.event_name != 'merge_group'
uses: codecov/codecov-action@v5
timeout-minutes: 5
continue-on-error: true
with:
use_oidc: true
files: coverage/gate/lcov.info
disable_search: true
flags: frontend-apps-gate-unit
name: Frontend Gate App Unit Tests
fail_ci_if_error: false
# One report per package, so search the downloaded tree instead of naming a single
# file. Without this every package under frontend/packages/ stays unmeasured, which
# is why moving console features into packages silently dropped them from coverage.
- name: 📊 Upload Frontend Packages Unit Test Coverage Report to Codecov
if: github.event_name != 'merge_group'
uses: codecov/codecov-action@v5
timeout-minutes: 5
continue-on-error: true
with:
use_oidc: true
directory: coverage/packages
flags: frontend-packages-unit
name: Frontend Packages Unit Tests
fail_ci_if_error: false
patch-coverage-gate:
name: 🛡️ Patch Coverage Gate
# Deterministic patch coverage check that always reports, unlike the external
# codecov/patch status which can hang at "Expected" (fork PRs, merge queue
# commits, Codecov processing stalls). The threshold and the ignored paths are
# read from codecov.yml, so this enforces the same rules as codecov/patch
# without a second copy of them here. The enforcement logic lives in
# .github/actions/patch-coverage-gate.
needs: [build, test-backend-unit, test-integration, test-frontend-console-app, test-frontend-gate-app, upload-frontend-coverage]
if: ${{ always() && (github.event_name == 'pull_request' || github.event_name == 'merge_group') && needs.build.result == 'success' && needs.test-backend-unit.result == 'success' && needs.test-integration.result == 'success' && needs.test-frontend-console-app.result == 'success' && needs.test-frontend-gate-app.result == 'success' && needs.upload-frontend-coverage.result == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
pull-requests: read
checks: read
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
persist-credentials: false
# Codecov never processes merge queue commits, so a queue entry is compared
# through the pull request it was created from: the queue commit carries
# that same diff rebased onto main. The pull request number is embedded in
# the queue ref, and its head commit already has a fully processed Codecov
# report from the pull request run. Leaving the outputs empty makes the gate
# compute patch coverage locally, which is what queue runs did before.
# On merge queue runs the commit under test is not the commit Codecov
# reported on, so the codecov/patch check run is read from the head of the
# pull request the queue entry was created from. The queue commit carries
# that same diff rebased onto main, which is the premise the
# codecov-merge-queue-status job already relies on.
- name: 🔢 Resolve the commit whose codecov/patch verdict applies
id: codecov-target
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
# refs/heads/gh-readonly-queue/<base>/pr-<number>-<base sha>
QUEUE_REF: ${{ github.event.merge_group.head_ref }}
run: |
set -euo pipefail
if [ "$EVENT_NAME" = "pull_request" ]; then
echo "pr-number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
echo "head-sha=$PR_HEAD_SHA" >> "$GITHUB_OUTPUT"
exit 0
fi
PR=$(printf '%s' "$QUEUE_REF" | sed -nE 's|.*/pr-([0-9]+)-[0-9a-f]+$|\1|p')
if [ -z "$PR" ]; then
echo "⚠️ No pull request number in '$QUEUE_REF'; computing patch coverage locally."
exit 0
fi
SHA=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR}" --jq '.head.sha' 2>/dev/null || true)
if [ -z "$SHA" ]; then
echo "⚠️ Could not resolve the head commit of PR #${PR}; computing patch coverage locally."
exit 0
fi
echo "Comparing through PR #${PR} (head ${SHA})"
echo "pr-number=$PR" >> "$GITHUB_OUTPUT"
echo "head-sha=$SHA" >> "$GITHUB_OUTPUT"
- name: 🛡️ Enforce Patch Coverage
uses: ./.github/actions/patch-coverage-gate
with:
github-token: ${{ github.token }}
pr-number: ${{ steps.codecov-target.outputs.pr-number }}
head-sha: ${{ steps.codecov-target.outputs.head-sha || github.sha }}
base-ref: ${{ github.event_name == 'merge_group' && github.event.merge_group.base_sha || format('origin/{0}', github.base_ref) }}
build_samples:
name: 🛠️ Build Sample Apps
needs: [preflight]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: ⚙️ Set up Node.js and pnpm
uses: ./.github/actions/setup-pnpm
with:
node-version: ${{ env.NODE_VERSION }}
- name: 📦 Package Sample Apps
run: |
make package_samples OS=$(go env GOOS) ARCH=$(go env GOARCH)
- name: 📦 Upload Built Sample App
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: sample-app-react-sdk
path: target/dist/sample-app-react-sdk-*.zip
# Kept separately from sample-app-react-sdk, which other workflows consume by name.
# The CLI installs this bundle for `try`, so cli-compatibility serves it with the product.
- name: 📦 Upload Wayfinder Sample
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: sample-app-wayfinder
path: target/dist/sample-app-wayfinder-*.zip
if-no-files-found: error
# Fast gate for the CLI: everything that needs neither the network nor a running server.
# Kept out of the `lint` job above because the CLI lints with its own golangci-lint, built
# against the toolchain in tools/cli/go.mod: a published prebuilt binary is compiled with an
# older Go than the CLI targets and refuses to run at all in that case.
cli-lint-unit:
name: 🔍 CLI Lint and Unit Tests
needs: [preflight]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- name: ⚙️ Set up Go Environment
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: tools/cli/go.mod
cache-dependency-path: tools/cli/go.sum
- name: 🧹 Lint CLI
run: make tools_lint_cli
- name: 🧪 Run CLI Unit Tests
run: make tools_test_cli
# Lane 1 of the CLI e2e strategy: does a CLI change break the CLI? Drives the npx wrapper
# against the currently published release, not the distribution built above: that pairing
# is cli-compatibility's job, below. Split from cli-lint-unit so a lint or unit failure
# reports without paying for this.
cli-e2e:
name: 🎭 CLI E2E (${{ matrix.os }})
needs: [cli-lint-unit]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
# global-setup.ts builds the CLI binary that the npx wrapper resolves.
- name: ⚙️ Set up Go Environment
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: tools/cli/go.mod
cache-dependency-path: tools/cli/go.sum
- name: ⚙️ Set up Node.js and pnpm
uses: ./.github/actions/setup-pnpm
with:
node-version: ${{ env.NODE_VERSION }}
- name: 📦 Set up CLI E2E Suite
uses: ./.github/actions/setup-cli-e2e
- name: 🔌 Verify Required Ports Are Free
uses: ./.github/actions/verify-cli-e2e-ports
- name: 🎭 Run E2E Tests
working-directory: tests/e2e-cli
run: pnpm test
- name: 📄 Upload Playwright Report on Failure
if: failure()
uses: ./.github/actions/upload-cli-e2e-report
with:
name: cli-e2e-report-${{ matrix.os }}
cli-compatibility:
name: 🔗 CLI Against This Build
needs: [preflight, build, build_samples]
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger-pr-builder') && (github.event.action != 'labeled' || github.event.label.name == 'trigger-pr-builder')) || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
# global-setup builds the CLI from this checkout; the product comes from the artifacts.
- name: ⚙️ Set up Go Environment
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: tools/cli/go.mod
cache-dependency-path: tools/cli/go.sum
- name: ⚙️ Set up Node.js and pnpm
uses: ./.github/actions/setup-pnpm
with:
node-version: ${{ env.NODE_VERSION }}
# Reusing what build-product and build-samples already produced, rather than building the
# distribution a second time.
- name: 📥 Download the Built Distribution
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: product-distribution
path: target/dist
- name: 📥 Download the Wayfinder Sample
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: sample-app-wayfinder
path: target/dist
- name: 🔍 Show What Will Be Served
run: ls -lh target/dist/
- name: 📦 Set up CLI E2E Suite
uses: ./.github/actions/setup-cli-e2e
# 8899 is the local release server this run serves target/dist through, on top of the
# suite's own fixed ports.
- name: 🔌 Verify Required Ports Are Free
uses: ./.github/actions/verify-cli-e2e-ports
with:
extra-ports: "8899"
# E2E_PRODUCT_DIST makes the suite serve target/dist with a generated manifest and point the
# CLI at it, so everything it installs was built by this pull request.
- name: 🎭 Run the CLI Against This Build
working-directory: tests/e2e-cli
env:
E2E_PRODUCT_DIST: ${{ github.workspace }}/target/dist
run: pnpm test
- name: 📄 Upload Playwright Report on Failure
if: failure()
uses: ./.github/actions/upload-cli-e2e-report
with:
name: cli-compatibility-report
test-integration:
name: 🧪 Integration Tests (${{ matrix.database }})
needs: [build, build_samples]
if: ${{ always() && needs.build.result == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
id-token: write
contents: read
strategy:
matrix:
database: [sqlite, postgres, redis]
fail-fast: false
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: dbuser
POSTGRES_PASSWORD: dbpassword
POSTGRES_DB: postgredb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:latest
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: 🗄️ Cache Go Modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
id: cache-go-modules
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-modules-
- name: 📦 Install Dependencies
run: |
cd backend
go mod download
cd ../tests/integration
go mod download
- name: 📝 Configure Test Database
run: |
chmod +x tests/integration/resources/scripts/setup-test-config.sh
./tests/integration/resources/scripts/setup-test-config.sh
env:
DB_TYPE: ${{ matrix.database }}
- name: 🧪 Run Integration Tests (${{ matrix.database }})
uses: ./.github/actions/run-integration-tests
with:
database-type: ${{ matrix.database }}
coverage-enabled: true
- name: 📦 Archive Integration Coverage Report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: integration-coverage-${{ matrix.database }}
path: target/coverage_integration.out
if-no-files-found: error
- name: 📊 Upload Integration Test Coverage Report to Codecov
if: github.event_name != 'merge_group'
uses: codecov/codecov-action@v5
timeout-minutes: 5
continue-on-error: true
with:
use_oidc: true
files: target/coverage_integration.out
disable_search: true
flags: backend-integration-${{ matrix.database }}
name: Backend Integration Tests (${{ matrix.database }})
fail_ci_if_error: false
# - name: 🧩 Generate Combined Coverage Report
# run: ./build.sh merge_coverage
# - name: 📊 Upload Combined Coverage Report to Codecov
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: target/coverage_combined.out
# disable_search: true
# flags: backend-combined-${{ matrix.database }}
# name: Backend-combined Coverage (${{ matrix.database }})
# fail_ci_if_error: false