-
Notifications
You must be signed in to change notification settings - Fork 282
806 lines (692 loc) · 30.1 KB
/
pr-builder.yml
File metadata and controls
806 lines (692 loc) · 30.1 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
# This workflow will build the project on pull requests with tests
# Uses:
# OS: ubuntu-latest
# Go: go 1.x
name: 👷🛠️ PR Builder
on:
pull_request:
merge_group:
workflow_dispatch:
# Avoid running multiple PR builders for the same PR on subsequent pushes.
concurrency:
group: pr-builder-${{ github.ref }}
cancel-in-progress: true
env:
GOFLAGS: "-mod=readonly"
jobs:
dependency-guard:
name: 🛡️ Dependency Guard
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
uses: ./.github/workflows/dependency-guard.yml
with:
detection-mode: pr
security-audit:
name: 🔒 Security Audit
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 'lts/*'
- name: 📦 Install pnpm
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
with:
version: 'latest'
run_install: false
- name: 🔍 Run pnpm audit (Frontend)
working-directory: frontend
run: |
echo "🔍 Running pnpm audit for frontend dependencies..."
IGNORE_ARGS=()
while IFS= read -r id; do
IGNORE_ARGS+=(--ignore "$id")
done < <(jq -r '.frontend[].id' "$GITHUB_WORKSPACE/.audit-ignore.json")
pnpm audit --audit-level=high "${IGNORE_ARGS[@]}"
- name: 🔍 Run npm audit (E2E Tests)
working-directory: tests/e2e
run: |
echo "🔍 Running npm audit for E2E test dependencies..."
IGNORED_GHSAS=$(jq '[(.common + .e2e)[].id]' "$GITHUB_WORKSPACE/.audit-ignore.json")
AUDIT_RESULT=$(npm audit --json --audit-level=high 2>&1) || true
REMAINING=$(echo "$AUDIT_RESULT" | jq --argjson ignored "$IGNORED_GHSAS" '
[.vulnerabilities[].via[] | select(type == "object")
| select(.severity == "high" or .severity == "critical")
| select(.url | test($ignored | join("|")) | not)
] | length
')
if [ "$REMAINING" -gt 0 ]; then
echo "❌ Found $REMAINING unignored high/critical advisories:"
echo "$AUDIT_RESULT" | jq --argjson ignored "$IGNORED_GHSAS" '
[.vulnerabilities[].via[] | select(type == "object")
| select(.severity == "high" or .severity == "critical")
| select(.url | test($ignored | join("|")) | not)
] | unique_by(.url) | .[] | "\(.severity): \(.name) - \(.url)"
'
exit 1
fi
echo "✅ All high/critical advisories are in the ignored list."
- name: 🔍 Run npm audit (Sample Apps)
run: |
echo "🔍 Running npm audit for sample app dependencies..."
IGNORED_GHSAS=$(jq '[(.common + ."sample-apps")[].id]' "$GITHUB_WORKSPACE/.audit-ignore.json")
for app in samples/apps/*/; do
if [ -f "${app}package-lock.json" ]; then
echo "Auditing $app..."
cd "$app"
AUDIT_RESULT=$(npm audit --json --audit-level=high 2>&1) || true
REMAINING=$(echo "$AUDIT_RESULT" | jq --argjson ignored "$IGNORED_GHSAS" '
[.vulnerabilities[].via[] | select(type == "object")
| select(.severity == "high" or .severity == "critical")
| select(.url | test($ignored | join("|")) | not)
] | length
')
if [ "$REMAINING" -gt 0 ]; then
echo "❌ Found $REMAINING unignored high/critical advisories in $app:"
echo "$AUDIT_RESULT" | jq --argjson ignored "$IGNORED_GHSAS" '
[.vulnerabilities[].via[] | select(type == "object")
| select(.severity == "high" or .severity == "critical")
| select(.url | test($ignored | join("|")) | not)
] | unique_by(.url) | .[] | "\(.severity): \(.name) - \(.url)"
'
exit 1
fi
echo "✅ $app - All high/critical advisories are in the ignored list."
cd - > /dev/null
fi
done
dependency-review:
name: 🔎 Dependency Review
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: 🔎 Dependency Review
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.merge_group.base_sha || github.event.pull_request.base.sha }}
head-ref: ${{ github.event.merge_group.head_sha || github.event.pull_request.head.sha }}
verify-mocks:
name: 🔍 Verify Mock Files
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
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: dependency-guard
if: ${{ always() && (needs.dependency-guard.result == 'success' || needs.dependency-guard.result == 'skipped') && (github.event_name == 'pull_request' || github.event_name == 'merge_group') }}
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- name: ⚙️ Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 'lts/*'
- name: 🔄 Fetch main branch for Nx affected base
run: git fetch origin main:main --update-head-ok || true
- name: 🐳 Set SHAs for Nx
id: set-shas
uses: nrwl/nx-set-shas@3e9ad7370203c1e93d109be57f3b72eb0eb511b1 # v4.4.0
with:
main-branch-name: "main"
- name: 📦 Install pnpm
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
with:
version: 'latest'
run_install: false
cache_dependency_path: frontend/pnpm-lock.yaml
- 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
- name: 🧩 Install Dependencies & Build Frontend
run: |
cd frontend
pnpm install --frozen-lockfile
pnpm build
- name: 🔍 Run Frontend Linter
run: |
cd frontend
pnpm nx affected --target=lint --parallel=3 --base=${{ steps.set-shas.outputs.base }} --head=${{ steps.set-shas.outputs.head }}
- name: 🎨 Check Frontend Formatting
run: |
cd frontend
pnpm format:check
build:
name: 🛠️ Build Product
needs: dependency-guard
if: ${{ always() && (needs.dependency-guard.result == 'success' || needs.dependency-guard.result == 'skipped') && (github.event.label.name == 'trigger-pr-builder' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'merge_group') }}
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: ⚙️ Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 'lts/*'
- name: 📦 Install pnpm
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
with:
version: 'latest'
run_install: false
cache_dependency_path: frontend/pnpm-lock.yaml
- 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: 📦 Install Frontend Dependencies
run: |
cd frontend
pnpm install --frozen-lockfile
- name: 🧹 Clean Previous Builds
run: |
set -e
make clean
- name: 🔨 Build Frontend
run: |
cd frontend
pnpm build
- name: 🔨 Build Product with Coverage
run: |
set -e
export LOG_LEVEL=debug
make build_with_coverage_only OS=$(go env GOOS) ARCH=$(go env GOARCH)
# Find the built distribution
DIST_PATH=$(find target/dist -name "thunder-*.zip" | head -1)
echo "Built distribution: $DIST_PATH"
- name: 📦 Upload Built Distribution
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: thunder-distribution
path: target/dist/*.zip
if-no-files-found: error
- name: 📊 Upload Unit Test Coverage Report to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
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:
name: 🧪 Frontend Tests (shard ${{ matrix.shard }}/4)
needs: dependency-guard
if: ${{ always() && (needs.dependency-guard.result == 'success' || needs.dependency-guard.result == 'skipped') && (github.event.label.name == 'trigger-pr-builder' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'merge_group') }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 'lts/*'
- name: 📦 Install pnpm
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
with:
version: 'latest'
run_install: false
cache_dependency_path: frontend/pnpm-lock.yaml
- name: 📦 Install Frontend Dependencies
run: |
cd frontend
pnpm install --frozen-lockfile
- name: 🔨 Build Frontend Packages
run: |
cd frontend
pnpm build:packages
- name: 🧪 Run Console Tests with Coverage
run: |
cd frontend/apps/thunder-console
pnpm vitest run --coverage --shard=${{ matrix.shard }}/4
- name: 🧪 Run Gate Tests with Coverage
if: matrix.shard == 1
run: |
cd frontend/apps/thunder-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 frontend LCOV reports
run: |
for lcov_file in frontend/apps/thunder-console/coverage/lcov.info frontend/apps/thunder-gate/coverage/lcov.info; do
if [ -f "$lcov_file" ]; then
sed -i '/^BRDA:/d;/^BRF:/d;/^BRH:/d' "$lcov_file"
fi
done
- name: 📦 Upload console coverage artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: console-coverage-shard-${{ matrix.shard }}
path: frontend/apps/thunder-console/coverage/lcov.info
if-no-files-found: error
- name: 📦 Upload gate coverage artifact
if: matrix.shard == 1
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: gate-coverage
path: frontend/apps/thunder-gate/coverage/lcov.info
if-no-files-found: error
upload-frontend-coverage:
name: 📊 Upload Frontend Coverage
needs: test-frontend
if: always() && needs.test-frontend.result == 'success'
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: 📥 Download all coverage artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
pattern: console-coverage-shard-*
path: coverage/console
- name: 📥 Download gate coverage artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: gate-coverage
path: coverage/gate
- name: 🔀 Merge console coverage from shards
run: |
cat coverage/console/console-coverage-shard-*/lcov.info > coverage/console-merged-lcov.info
- name: 📊 Upload `@thunder/console` Unit Test Coverage Report to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/console-merged-lcov.info
disable_search: true
flags: frontend-apps-console-unit
name: Frontend Console App Unit Tests
fail_ci_if_error: false
- name: 📊 Upload `@thunder/gate` Unit Test Coverage Report to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/gate/lcov.info
disable_search: true
flags: frontend-apps-gate-unit
name: Frontend Gate App Unit Tests
fail_ci_if_error: false
build_samples:
name: 🛠️ Build Sample Apps
needs: dependency-guard
if: ${{ always() && (needs.dependency-guard.result == 'success' || needs.dependency-guard.result == 'skipped') && (github.event.label.name == 'trigger-pr-builder' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'merge_group') }}
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: ⚙️ Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 'lts/*'
- name: 📦 Install pnpm
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
with:
version: 'latest'
run_install: false
cache_dependency_path: frontend/pnpm-lock.yaml
- name: 🧩 Build and Package Sample Apps
run: |
make build_samples
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
test-integration:
name: 🧪 Integration Tests (${{ matrix.database }})
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
database: [sqlite, postgres]
fail-fast: false
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: asgthunder
POSTGRES_PASSWORD: asgthunder
POSTGRES_DB: thunderdb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--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: 📥 Download Unit Coverage Report
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: unit-coverage-report
path: backend/
- 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: 📊 Upload Integration Test Coverage Report to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
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@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # 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
test-e2e:
name: 🎭 Playwright E2E Tests
needs: [build, build_samples]
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: ⚙️ Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 'lts/*'
- name: 📥 Download Built Distribution
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: thunder-distribution
path: target/dist/
- name: 📥 Download Built Sample App
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: sample-app-react-sdk
path: target/dist/
- name: 📂 Extract Server to E2E
run: |
mkdir -p tests/e2e/thunder-server
unzip target/dist/thunder-*.zip -d tests/e2e/thunder-server
cd tests/e2e/thunder-server
# Find the extracted folder (name includes version and arch) and move its contents to the root of tests/e2e/thunder-server
EXTRACTED_DIR=$(find . -maxdepth 1 -type d -name "thunder-*" | head -n 1)
if [ -n "$EXTRACTED_DIR" ]; then
mv "$EXTRACTED_DIR"/* .
rmdir "$EXTRACTED_DIR"
fi
chmod +x setup.sh start.sh
- name: 🚀 Start Thunder Server
run: |
cd tests/e2e/thunder-server
./setup.sh
THUNDER_SKIP_SECURITY=true ./start.sh &
THUNDER_PID=$!
echo "THUNDER_PID=$THUNDER_PID" >> $GITHUB_ENV
# Wait for server to be ready
echo "Waiting for server to be ready on https://localhost:8090..."
for i in {1..60}; do
if curl -s -k https://localhost:8090/health/liveness > /dev/null; then
echo "Server is UP!"
break
fi
echo "Still waiting ($i/60)..."
sleep 2
done
# Verify server is actually running
if ! curl -s -k https://localhost:8090/health/liveness > /dev/null; then
echo "Server failed to start within 2 minutes"
exit 1
fi
echo "Server started successfully!"
- name: 🔍 Extract Sample App ID
id: extract-app-id
run: |
echo "Fetching applications from Thunder..."
# Get applications list
APPS_RESPONSE=$(curl -s -k https://localhost:8090/applications)
# Extract Sample App ID using jq
SAMPLE_APP_ID=$(echo "$APPS_RESPONSE" | jq -r '.applications[] | select(.name == "Sample App") | .id')
if [ -z "$SAMPLE_APP_ID" ] || [ "$SAMPLE_APP_ID" == "null" ]; then
echo "⚠️ Warning: Sample App not found in applications list"
echo "Available applications:"
echo "$APPS_RESPONSE" | jq -r '.applications[] | " - \(.name) (\(.id))"'
echo "sample_app_id=" >> $GITHUB_OUTPUT
else
echo "✓ Sample App ID extracted: $SAMPLE_APP_ID"
echo "sample_app_id=$SAMPLE_APP_ID" >> $GITHUB_OUTPUT
fi
- name: 🔄 Restart Thunder Server with Security Enabled
run: |
cd tests/e2e/thunder-server
echo "Stopping Thunder server..."
# Kill the start.sh wrapper process
kill $THUNDER_PID 2>/dev/null || true
# Also kill any process still listening on port 8090
# (start.sh backgrounds the thunder binary, so killing start.sh
# may leave the thunder process running as an orphan)
sleep 2
if lsof -ti tcp:8090 >/dev/null 2>&1; then
echo "Port 8090 still in use, killing remaining processes..."
kill -9 $(lsof -ti tcp:8090) 2>/dev/null || true
fi
# Wait for port to be fully released
sleep 3
echo "Starting Thunder server with security enabled..."
./start.sh &
THUNDER_PID=$!
echo "THUNDER_PID=$THUNDER_PID" >> $GITHUB_ENV
# Wait for server to be ready
echo "Waiting for server to be ready on https://localhost:8090..."
for i in {1..60}; do
if curl -s -k https://localhost:8090/health/liveness > /dev/null; then
echo "Server is UP with security enabled!"
break
fi
echo "Still waiting ($i/60)..."
sleep 2
done
# Verify server is actually running
if ! curl -s -k https://localhost:8090/health/liveness > /dev/null; then
echo "Server failed to restart within 2 minutes"
exit 1
fi
echo "Server restarted successfully with security enabled!"
- name: 📱 Extract and Start Sample App
run: |
echo "Extracting Sample App..."
mkdir -p tests/e2e/sample-app
# Find the sample app zip file (platform-specific)
SAMPLE_APP_ZIP=$(find target/dist -name "sample-app-react-sdk-*.zip" | head -n 1)
if [ -z "$SAMPLE_APP_ZIP" ]; then
echo "⚠️ Warning: Sample app zip not found in target/dist"
echo "Available files:"
ls -la target/dist/
exit 1
fi
echo "Found sample app: $SAMPLE_APP_ZIP"
unzip -q "$SAMPLE_APP_ZIP" -d tests/e2e/sample-app
cd tests/e2e/sample-app
# Find the extracted folder and move its contents
EXTRACTED_DIR=$(find . -maxdepth 1 -type d -name "sample-app-*" | head -n 1)
if [ -n "$EXTRACTED_DIR" ]; then
mv "$EXTRACTED_DIR"/* .
rmdir "$EXTRACTED_DIR"
fi
# Make start script executable
chmod +x start.sh
echo "Starting Sample App..."
./start.sh &
# Wait for sample app to be ready
echo "Waiting for sample app to be ready on https://localhost:3000..."
for i in {1..60}; do
if curl -s -k https://localhost:3000 > /dev/null 2>&1; then
echo "Sample App is UP!"
break
fi
echo "Still waiting ($i/60)..."
sleep 2
done
# Verify sample app is running
if ! curl -s -k https://localhost:3000 > /dev/null 2>&1; then
echo "Sample app failed to start within 2 minutes"
exit 1
fi
echo "Sample App started successfully!"
- name: Install E2E dependencies
run: npm ci
working-directory: tests/e2e
- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: tests/e2e
- name: Run Playwright tests
run: npx playwright test
working-directory: tests/e2e
env:
# Configuration Priority: Secret > Variable > Hardcoded Default
BASE_URL: ${{ secrets.PLAYWRIGHT_BASE_URL || vars.PLAYWRIGHT_BASE_URL || 'https://localhost:8090' }}
ADMIN_USERNAME: ${{ secrets.PLAYWRIGHT_ADMIN_USERNAME || 'admin' }}
ADMIN_PASSWORD: ${{ secrets.PLAYWRIGHT_ADMIN_PASSWORD || 'admin' }}
TEST_USER_USERNAME: ${{ secrets.PLAYWRIGHT_TEST_USER_USERNAME || 'testuser' }}
TEST_USER_PASSWORD: ${{ secrets.PLAYWRIGHT_TEST_USER_PASSWORD || 'admin' }}
PLAYWRIGHT_WORKERS: ${{ vars.PLAYWRIGHT_WORKERS || 1 }}
DEBUG_AUTH: ${{ vars.PLAYWRIGHT_DEBUG_AUTH || 'false' }}
# MFA Test Configuration
SAMPLE_APP_ID: ${{ steps.extract-app-id.outputs.sample_app_id }}
SAMPLE_APP_URL: 'https://localhost:3000'
THUNDER_URL: 'https://localhost:8090'
AUTO_SETUP_MFA: ${{ vars.AUTO_SETUP_MFA || 'true' }}
MOCK_SMS_SERVER_PORT: ${{ vars.MOCK_SMS_SERVER_PORT || 8098 }}
SAMPLE_APP_USERNAME: ${{ secrets.SAMPLE_APP_USERNAME || 'e2e-test-user' }}
SAMPLE_APP_PASSWORD: ${{ secrets.SAMPLE_APP_PASSWORD || 'e2e-test-password' }}
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: tests/e2e/playwright-report/
retention-days: 30
detect-powershell-changes:
name: 🔍 Detect PowerShell Changes
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.filter.outputs.powershell }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- 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: |
powershell:
- '**.ps1'
- '.github/workflows/windows-powershell-validation.yml'
- name: ✅ PowerShell files detected
if: steps.filter.outputs.powershell == 'true'
run: echo "PowerShell files changed - validation will run"
- name: ⏭️ No PowerShell changes
if: steps.filter.outputs.powershell != 'true'
run: echo "No PowerShell changes - skipping validation"
validate-windows:
name: 🪟 Validate Windows PowerShell
needs: detect-powershell-changes
if: needs.detect-powershell-changes.outputs.should-run == 'true'
uses: ./.github/workflows/windows-powershell-validation.yml