-
Notifications
You must be signed in to change notification settings - Fork 5
873 lines (766 loc) Β· 39.6 KB
/
Copy pathunit-testing.yml
File metadata and controls
873 lines (766 loc) Β· 39.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
name: Unit Tests
on: [ pull_request, workflow_dispatch ]
concurrency:
group: unit-tests-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# NOTE: Standalone QAAtlas and AccessLint jobs have been consolidated into
# the Ledger Analysis workflow (ledger.yml) which now integrates both tools.
# See: https://github.com/mauricecarrier7/ledger-dist
build-and-test:
runs-on: macos-15
permissions:
contents: write
pull-requests: write
pages: write
id-token: write
steps:
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest-stable'
- name: Verify Xcode Version
run: xcodebuild -version
- name: Checkout main repo and submodules
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.CI_GITHUB_ACCESS_TOKEN }}
- name: Cache Swift packages
uses: actions/cache@v4
with:
path: |
.build
SourcePackages
~/Library/Developer/Xcode/DerivedData/**/SourcePackages
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Cache Xcode DerivedData
uses: actions/cache@v4
with:
path: ~/Library/Developer/Xcode/DerivedData
# Key on the branch name + run number so each run has a unique key
# (always saves) but restores from the latest cache for this branch.
# We deliberately do NOT key on pbxproj β every file-add edit
# invalidated the entire cache, forcing ~50min cold rebuilds that
# blew the job timeout before tests could even start.
key: ${{ runner.os }}-deriveddata-${{ github.head_ref || github.ref_name }}-${{ github.run_number }}
restore-keys: |
${{ runner.os }}-deriveddata-${{ github.head_ref || github.ref_name }}-
${{ runner.os }}-deriveddata-develop-
${{ runner.os }}-deriveddata-
- name: Cache Test History
uses: actions/cache@v4
with:
path: .test-history
key: test-history-${{ github.head_ref || github.ref_name }}-${{ github.run_number }}
restore-keys: |
test-history-${{ github.head_ref || github.ref_name }}-
test-history-develop-
test-history-
- name: Checkout Certificates
uses: actions/checkout@v3
with:
repository: ThePalaceProject/mobile-certificates
token: ${{ secrets.CI_GITHUB_ACCESS_TOKEN }}
path: ./mobile-certificates
- name: Checkout Adobe RMSDK
uses: ./.github/actions/checkout-adobe
with:
token: ${{ secrets.CI_GITHUB_ACCESS_TOKEN }}
- name: Setup repo with DRM
run: ./scripts/setup-repo-drm.sh
env:
BUILD_CONTEXT: ci
- name: Build non-Carthage 3rd party dependencies
run: ./scripts/build-3rd-party-dependencies.sh
env:
BUILD_CONTEXT: ci
- name: List available simulators for debugging
run: xcrun simctl list devices available | grep iPhone | head -10
- name: Run Palace unit tests
id: tests
timeout-minutes: 60
run: ./scripts/xcode-test-optimized.sh
env:
BUILD_CONTEXT: ci
continue-on-error: true
- name: Find Test Results
if: always()
id: find_results
run: |
echo "Looking for xcresult bundles..."
echo "Current directory: $(pwd)"
echo "Directory contents:"
ls -la | head -20
# Check current directory
if [ -d "TestResults.xcresult" ]; then
echo "β
Found: ./TestResults.xcresult"
echo "xcresult size: $(du -sh TestResults.xcresult)"
echo "path=TestResults.xcresult" >> $GITHUB_OUTPUT
echo "found=true" >> $GITHUB_OUTPUT
# Quick check of what's inside
echo "=== Quick xcresult summary ==="
xcrun xcresulttool get test-results summary --path TestResults.xcresult 2>&1 | head -30 || echo "Could not get summary"
exit 0
fi
# Search in common locations
echo "Searching for xcresult in current directory tree..."
FOUND=$(find . -name "*.xcresult" -type d 2>/dev/null | head -1)
if [ -n "$FOUND" ]; then
echo "β
Found: $FOUND"
echo "path=$FOUND" >> $GITHUB_OUTPUT
echo "found=true" >> $GITHUB_OUTPUT
exit 0
fi
# Search in DerivedData
echo "Searching in DerivedData..."
FOUND=$(find ~/Library/Developer/Xcode/DerivedData -name "*.xcresult" -type d 2>/dev/null | head -1)
if [ -n "$FOUND" ]; then
echo "β
Found in DerivedData: $FOUND"
cp -r "$FOUND" ./TestResults.xcresult
echo "path=TestResults.xcresult" >> $GITHUB_OUTPUT
echo "found=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "β No xcresult found anywhere!"
echo "found=false" >> $GITHUB_OUTPUT
- name: Parse Test Results
if: always()
id: parse_results
run: |
RESULT_PATH="${{ steps.find_results.outputs.path }}"
# Initialize defaults
echo "tests=0" >> $GITHUB_OUTPUT
echo "passed=0" >> $GITHUB_OUTPUT
echo "failed=0" >> $GITHUB_OUTPUT
echo "skipped=0" >> $GITHUB_OUTPUT
echo "duration=unknown" >> $GITHUB_OUTPUT
echo "pass_rate=N/A" >> $GITHUB_OUTPUT
if [ "${{ steps.find_results.outputs.found }}" != "true" ] || [ ! -d "$RESULT_PATH" ]; then
echo "No results to parse"
exit 0
fi
echo "Parsing test results from: $RESULT_PATH"
# Debug: Show raw xcresulttool output structure
echo "=== xcresulttool version ==="
xcrun xcresulttool version 2>/dev/null || echo "version command not available"
echo "=== Raw test-results summary (first 2000 chars) ==="
xcrun xcresulttool get test-results summary --path "$RESULT_PATH" 2>/dev/null | head -c 2000 || echo "summary command failed"
echo ""
echo "=== Raw test-results tests structure (first 3000 chars) ==="
xcrun xcresulttool get test-results tests --path "$RESULT_PATH" 2>/dev/null | head -c 3000 || echo "tests command failed"
echo ""
echo "=== Parsing with Python script ==="
# Use the enhanced Python parser - outputs to GITHUB_OUTPUT and test-data.json
python3 scripts/parse-xcresult.py "$RESULT_PATH" --json test-data.json || true
# Debug: Show parsed values
echo "=== Parsed Test Results ==="
cat test-data.json | python3 -c "import json,sys; d=json.load(sys.stdin); s=d.get('summary',{}); print(f\"Tests: {s.get('tests',0)}, Passed: {s.get('passed',0)}, Failed: {s.get('failed',0)}\")" 2>/dev/null || echo "Could not read test-data.json"
- name: Compare with History
if: always()
id: history
run: |
if [ -f "test-data.json" ] && [ -d ".test-history" ]; then
echo "Comparing with test history..."
python3 scripts/test-history.py compare test-data.json .test-history || true
else
echo "No history available for comparison"
echo "has_history=false" >> $GITHUB_OUTPUT
fi
- name: Save to History
if: always()
run: |
if [ -f "test-data.json" ]; then
python3 scripts/test-history.py save test-data.json .test-history || true
fi
- name: Parse Code Coverage
if: always()
id: coverage
run: |
RESULT_PATH="${{ steps.find_results.outputs.path }}"
# Initialize defaults
echo "coverage=0" >> $GITHUB_OUTPUT
echo "coverage_formatted=N/A" >> $GITHUB_OUTPUT
if [ "${{ steps.find_results.outputs.found }}" != "true" ] || [ ! -d "$RESULT_PATH" ]; then
echo "No results for coverage"
exit 0
fi
echo "Extracting code coverage..."
# Validate xcresult bundle integrity before processing β a corrupt
# bundle (e.g. from a timeout kill) causes xccov to fail with 0%
# coverage, which then trips the coverage floor gate.
if ! xcrun xcresulttool get test-results summary --path "$RESULT_PATH" &>/dev/null; then
echo "β οΈ xcresult bundle is incomplete or corrupted β skipping coverage"
echo "coverage=N/A" >> $GITHUB_OUTPUT
echo "coverage_formatted=N/A" >> $GITHUB_OUTPUT
exit 0
fi
python3 scripts/coverage-report.py "$RESULT_PATH" --json coverage-data.json || true
# Coverage floor gate. Runs in WARN mode (continue-on-error: true) on day one;
# flip to blocking by removing continue-on-error after the floors are trusted.
- name: Enforce Coverage Floors
if: always() && steps.find_results.outputs.found == 'true' && steps.coverage.outputs.coverage != 'N/A'
id: coverage_gate
continue-on-error: true
run: python3 scripts/enforce_coverage_floors.py coverage-data.json --floors scripts/coverage-floors.json
- name: Collect Snapshot Failures
if: always()
id: snapshots
run: |
mkdir -p snapshot-failures
echo "Searching for snapshot failures..."
# Search multiple locations
find /Users/runner/Library/Developer/CoreSimulator -name "*.png" -path "*tmp*" -type f 2>/dev/null | head -50 | while read -r file; do
cp "$file" snapshot-failures/ 2>/dev/null || true
done
find ~/Library/Developer/Xcode/DerivedData -name "*.png" -path "*Failures*" -type f 2>/dev/null | head -50 | while read -r file; do
cp "$file" snapshot-failures/ 2>/dev/null || true
done
# Count what we found
COUNT=$(ls -1 snapshot-failures/*.png 2>/dev/null | wc -l | tr -d ' ')
echo "Total snapshot files found: $COUNT"
if [ "$COUNT" -gt "0" ]; then
echo "found=true" >> $GITHUB_OUTPUT
echo "count=$COUNT" >> $GITHUB_OUTPUT
# Process snapshots to generate viewer and comparisons
python3 scripts/process-snapshots.py snapshot-failures || true
else
echo "found=false" >> $GITHUB_OUTPUT
echo "count=0" >> $GITHUB_OUTPUT
fi
- name: Generate Test Reports
if: always()
run: |
mkdir -p test-report
# Generate Markdown report
python3 scripts/generate-test-report.py test-data.json test-report/TEST_RESULTS.md \
--commit "${{ github.sha }}" \
--branch "${{ github.head_ref || github.ref_name }}" \
--snapshot-count "${{ steps.snapshots.outputs.count }}" || true
# Generate HTML report
python3 scripts/generate-html-report.py test-data.json test-report/test-report.html \
--coverage coverage-data.json \
--commit "${{ github.sha }}" \
--branch "${{ github.head_ref || github.ref_name }}" || true
# Fallback if scripts fail
if [ ! -f "test-report/TEST_RESULTS.md" ]; then
echo "# Test Results" > test-report/TEST_RESULTS.md
echo "" >> test-report/TEST_RESULTS.md
echo "Tests: ${{ steps.parse_results.outputs.tests }}" >> test-report/TEST_RESULTS.md
echo "Passed: ${{ steps.parse_results.outputs.passed }}" >> test-report/TEST_RESULTS.md
echo "Failed: ${{ steps.parse_results.outputs.failed }}" >> test-report/TEST_RESULTS.md
fi
echo "Generated reports:"
ls -la test-report/
- name: Generate GitHub Step Summary
if: always()
run: |
TESTS="${{ steps.parse_results.outputs.tests }}"
PASSED="${{ steps.parse_results.outputs.passed }}"
FAILED="${{ steps.parse_results.outputs.failed }}"
SKIPPED="${{ steps.parse_results.outputs.skipped }}"
DURATION="${{ steps.parse_results.outputs.duration }}"
PASS_RATE="${{ steps.parse_results.outputs.pass_rate }}"
CLASS_SUMMARY="${{ steps.parse_results.outputs.class_summary }}"
COVERAGE="${{ steps.coverage.outputs.coverage_formatted }}"
TOTAL_COVERAGE="${{ steps.coverage.outputs.total_coverage_formatted }}"
EXCLUDED_FILES="${{ steps.coverage.outputs.excluded_file_count }}"
COVERAGE_TARGETS="${{ steps.coverage.outputs.coverage_targets }}"
NEW_FAILURES="${{ steps.history.outputs.new_failures }}"
FIXED_TESTS="${{ steps.history.outputs.fixed_tests }}"
FLAKY_TESTS="${{ steps.history.outputs.flaky_tests }}"
TEST_COUNT_CHANGE="${{ steps.history.outputs.test_count_change }}"
BUILD_STATUS="${{ steps.parse_results.outputs.build_status }}"
BUILD_ERRORS="${{ steps.parse_results.outputs.build_errors }}"
echo "## π§ͺ Palace Unit Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Check for build failure first
if [ "$BUILD_STATUS" = "failed" ]; then
echo "### π΄ BUILD FAILED" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The build failed before tests could run." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -n "$BUILD_ERRORS" ]; then
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary><strong>Build Errors</strong></summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$BUILD_ERRORS" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
elif [ "$TESTS" != "0" ] && [ "$TESTS" != "" ]; then
# Header with counts
if [ "$FAILED" = "0" ]; then
echo "### β
ALL TESTS PASSED" >> $GITHUB_STEP_SUMMARY
else
echo "### β $FAILED TEST(S) FAILED" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
# Quick stats line
COVERAGE_DISPLAY=""
if [ "$COVERAGE" != "N/A" ] && [ -n "$COVERAGE" ]; then
COVERAGE_DISPLAY=" | π $COVERAGE coverage"
fi
echo "**$TESTS tests** | **$PASSED passed** | **$FAILED failed** | **$SKIPPED skipped** | β±οΈ $DURATION | π $PASS_RATE$COVERAGE_DISPLAY" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Class breakdown table β collapsed by default. Auto-expand
# if any class had failures (so triage detail is visible
# without an extra click on red runs).
if [ -n "$CLASS_SUMMARY" ]; then
CLASS_COUNT=$(echo "$CLASS_SUMMARY" | wc -l | tr -d ' ')
FAILED_CLASS_COUNT=$(echo "$CLASS_SUMMARY" | awk -F'|' '$4 != "0" { c++ } END { print c+0 }')
if [ "$FAILED_CLASS_COUNT" -gt 0 ]; then
SUMMARY_LABEL="<strong>Tests by Class</strong> β $CLASS_COUNT classes, <strong>$FAILED_CLASS_COUNT with failures</strong>"
DETAILS_OPEN=" open"
else
SUMMARY_LABEL="<strong>Tests by Class</strong> β $CLASS_COUNT classes (click to expand)"
DETAILS_OPEN=""
fi
echo "<details${DETAILS_OPEN}>" >> $GITHUB_STEP_SUMMARY
echo "<summary>$SUMMARY_LABEL</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Class | Tests | Passed | Failed | Duration |" >> $GITHUB_STEP_SUMMARY
echo "|-------|-------|--------|--------|----------|" >> $GITHUB_STEP_SUMMARY
echo "$CLASS_SUMMARY" | while IFS='|' read -r class total passed failed duration; do
if [ "$failed" = "0" ]; then
echo "| β
$class | $total | $passed | $failed | $duration |" >> $GITHUB_STEP_SUMMARY
else
echo "| β $class | $total | $passed | **$failed** | $duration |" >> $GITHUB_STEP_SUMMARY
fi
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
else
# 0 tests - check why
if [ "${{ steps.tests.outcome }}" = "success" ]; then
echo "### β
ALL TESTS PASSED" >> $GITHUB_STEP_SUMMARY
elif [ "$BUILD_STATUS" = "failed" ] || [ -n "$BUILD_ERRORS" ]; then
echo "### π΄ BUILD FAILED - No tests ran" >> $GITHUB_STEP_SUMMARY
if [ -n "$BUILD_ERRORS" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary><strong>Build Errors</strong></summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$BUILD_ERRORS" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
else
echo "### β TESTS FAILED" >> $GITHUB_STEP_SUMMARY
fi
fi
# Failed tests
FAILED_TESTS="${{ steps.parse_results.outputs.failed_tests }}"
if [ -n "$FAILED_TESTS" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary><strong>Failed Tests</strong></summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$FAILED_TESTS" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
# Testing Coverage Breakdown
echo "" >> $GITHUB_STEP_SUMMARY
echo "### π Testing Coverage Breakdown" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Unit test line coverage β testable = denominator excludes UI/lifecycle
# files listed in scripts/coverage-exclude.json; total = every executable
# line. We gate on testable; total is shown for continuity.
if [ "$COVERAGE" != "N/A" ] && [ -n "$COVERAGE" ]; then
echo "**Unit Test Line Coverage (testable surfaces): $COVERAGE**" >> $GITHUB_STEP_SUMMARY
if [ -n "$TOTAL_COVERAGE" ] && [ "$TOTAL_COVERAGE" != "N/A" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "_Total coverage incl. UI/lifecycle: $TOTAL_COVERAGE ($EXCLUDED_FILES files excluded from testable denominator β see \`scripts/coverage-exclude.json\`)_" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
if [ -n "$COVERAGE_TARGETS" ]; then
echo "| Target | Lines Covered |" >> $GITHUB_STEP_SUMMARY
echo "|--------|---------------|" >> $GITHUB_STEP_SUMMARY
echo "$COVERAGE_TARGETS" | while IFS='|' read -r name cov covered total; do
if [ -n "$name" ]; then
echo "| $name | $cov |" >> $GITHUB_STEP_SUMMARY
fi
done
echo "" >> $GITHUB_STEP_SUMMARY
fi
fi
# E2E journey coverage moved to chaos-replay-on-pr.yml (simdrive). See docs/architecture/.
# Coverage context note
echo "" >> $GITHUB_STEP_SUMMARY
echo "> **Why two coverage numbers?** Testable coverage subtracts files that " >> $GITHUB_STEP_SUMMARY
echo "> can't be exercised from xcodebuild β SwiftUI views, UIKit VCs, AppDelegate/SceneDelegate " >> $GITHUB_STEP_SUMMARY
echo "> lifecycle (see \`scripts/coverage-exclude.json\`) β so raising it means more _testable_ " >> $GITHUB_STEP_SUMMARY
echo "> logic is tested, not that we shipped less UI. Total coverage is kept for continuity. " >> $GITHUB_STEP_SUMMARY
echo "> The excluded paths are covered by simdrive E2E journeys (see \`chaos-replay-on-pr.yml\`)." >> $GITHUB_STEP_SUMMARY
# History/Trends
if [ -n "$NEW_FAILURES" ] || [ -n "$FIXED_TESTS" ] || [ -n "$FLAKY_TESTS" ] || [ -n "$TEST_COUNT_CHANGE" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "### π Trends" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -n "$TEST_COUNT_CHANGE" ]; then
echo "Test count change: **$TEST_COUNT_CHANGE**" >> $GITHUB_STEP_SUMMARY
fi
if [ -n "$NEW_FAILURES" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary>β οΈ <strong>New Failures</strong></summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$NEW_FAILURES" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
if [ -n "$FIXED_TESTS" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary>β
<strong>Fixed Tests</strong></summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$FIXED_TESTS" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
if [ -n "$FLAKY_TESTS" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary>β‘ <strong>Flaky Tests Detected</strong></summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$FLAKY_TESTS" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
fi
# Snapshots
SNAPSHOT_COUNT="${{ steps.snapshots.outputs.count }}"
if [ "$SNAPSHOT_COUNT" != "0" ] && [ -n "$SNAPSHOT_COUNT" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "### πΈ Snapshot Failures: $SNAPSHOT_COUNT" >> $GITHUB_STEP_SUMMARY
echo "Download **snapshot-failures** artifact to view diff images" >> $GITHUB_STEP_SUMMARY
fi
# Report Link and Artifacts
echo "" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
REPORT_URL="${{ steps.deploy_report.outputs.report_url }}"
if [ -n "$REPORT_URL" ]; then
echo "### π [View Interactive Report]($REPORT_URL)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
echo "### π¦ Artifacts" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Artifact | Description |" >> $GITHUB_STEP_SUMMARY
echo "|----------|-------------|" >> $GITHUB_STEP_SUMMARY
echo "| **test-report** | π Markdown + HTML report |" >> $GITHUB_STEP_SUMMARY
echo "| **test-data** | π JSON data files |" >> $GITHUB_STEP_SUMMARY
echo "| **test-results** | π Full xcresult (open in Xcode) |" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.snapshots.outputs.found }}" = "true" ]; then
echo "| **snapshot-failures** | πΌοΈ Visual diff images |" >> $GITHUB_STEP_SUMMARY
fi
- name: Upload Test Report
if: always()
uses: actions/upload-artifact@v4
with:
name: test-report
path: test-report/
retention-days: 14
if-no-files-found: ignore
- name: Upload Test Data JSON
if: always()
uses: actions/upload-artifact@v4
with:
name: test-data
path: |
test-data.json
coverage-data.json
retention-days: 14
if-no-files-found: ignore
- name: Upload Snapshot Failures
if: steps.snapshots.outputs.found == 'true'
uses: actions/upload-artifact@v4
with:
name: snapshot-failures
path: snapshot-failures/
retention-days: 14
if-no-files-found: ignore
- name: Upload Test Results
if: steps.find_results.outputs.found == 'true'
uses: actions/upload-artifact@v4
with:
name: test-results
path: ${{ steps.find_results.outputs.path }}
retention-days: 14
if-no-files-found: ignore
- name: Deploy Report to GitHub Pages
if: always()
id: deploy_report
run: |
# Create report directory structure
REPORT_DIR="test-reports/${{ github.run_number }}"
mkdir -p "$REPORT_DIR"
# Copy reports
cp test-report/test-report.html "$REPORT_DIR/" 2>/dev/null || true
cp test-report/TEST_RESULTS.md "$REPORT_DIR/" 2>/dev/null || true
cp test-data.json "$REPORT_DIR/" 2>/dev/null || true
cp coverage-data.json "$REPORT_DIR/" 2>/dev/null || true
# Copy snapshot viewer if exists
if [ -f "snapshot-failures/snapshot-viewer.html" ]; then
cp snapshot-failures/snapshot-viewer.html "$REPORT_DIR/"
cp snapshot-failures/*.png "$REPORT_DIR/" 2>/dev/null || true
fi
# Create index.html that redirects to the report
cat > "$REPORT_DIR/index.html" << 'INDEXEOF'
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=test-report.html">
<title>Redirecting to Test Report</title>
</head>
<body>
<p>Redirecting to <a href="test-report.html">Test Report</a>...</p>
</body>
</html>
INDEXEOF
# Create root index listing recent reports
mkdir -p test-reports
cat > test-reports/index.html << 'ROOTINDEXEOF'
<!DOCTYPE html>
<html>
<head>
<title>Palace iOS Test Reports</title>
<style>
body { font-family: -apple-system, sans-serif; max-width: 800px; margin: 50px auto; padding: 20px; background: #0d1117; color: #f0f6fc; }
h1 { color: #58a6ff; }
a { color: #58a6ff; }
.report-link { display: block; padding: 10px; margin: 5px 0; background: #161b22; border-radius: 6px; text-decoration: none; }
.report-link:hover { background: #21262d; }
</style>
</head>
<body>
<h1>π§ͺ Palace iOS Test Reports</h1>
<p>Recent test reports from CI runs:</p>
<div id="reports"></div>
<script>
// This will be populated by the actual report links
document.getElementById('reports').innerHTML = '<p>Browse to a specific run number: <code>/test-reports/{run-number}/</code></p>';
</script>
</body>
</html>
ROOTINDEXEOF
# Output the report URL
REPO_NAME="${GITHUB_REPOSITORY#*/}"
REPO_OWNER="${GITHUB_REPOSITORY%/*}"
REPORT_URL="https://${REPO_OWNER}.github.io/${REPO_NAME}/test-reports/${{ github.run_number }}/"
echo "report_url=$REPORT_URL" >> $GITHUB_OUTPUT
echo "Report will be available at: $REPORT_URL"
- name: Publish to GitHub Pages
if: always()
continue-on-error: true
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./test-reports
destination_dir: test-reports
keep_files: true
- name: Post PR Comment with Results
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const tests = '${{ steps.parse_results.outputs.tests }}';
const passed = '${{ steps.parse_results.outputs.passed }}';
const failed = '${{ steps.parse_results.outputs.failed }}';
const skipped = '${{ steps.parse_results.outputs.skipped }}';
const duration = '${{ steps.parse_results.outputs.duration }}';
const passRate = '${{ steps.parse_results.outputs.pass_rate }}';
const testOutcome = '${{ steps.tests.outcome }}';
const failedTests = `${{ steps.parse_results.outputs.failed_tests }}`;
const classSummary = `${{ steps.parse_results.outputs.class_summary }}`;
const snapshotCount = '${{ steps.snapshots.outputs.count }}';
const coverage = '${{ steps.coverage.outputs.coverage_formatted }}';
const totalCoverage = '${{ steps.coverage.outputs.total_coverage_formatted }}';
const excludedFiles = '${{ steps.coverage.outputs.excluded_file_count }}';
const coverageTargets = `${{ steps.coverage.outputs.coverage_targets }}`;
const newFailures = `${{ steps.history.outputs.new_failures }}`;
const fixedTests = `${{ steps.history.outputs.fixed_tests }}`;
const flakyTests = `${{ steps.history.outputs.flaky_tests }}`;
const testCountChange = '${{ steps.history.outputs.test_count_change }}';
const buildStatus = '${{ steps.parse_results.outputs.build_status }}';
const buildErrors = `${{ steps.parse_results.outputs.build_errors }}`;
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const reportUrl = '${{ steps.deploy_report.outputs.report_url }}';
let body = '## π§ͺ Unit Test Results\n\n';
// Add clickable report link at the top
if (reportUrl) {
body += `π **[View Full Interactive Report](${reportUrl})**\n\n`;
}
// Check for build failure first
if (buildStatus === 'failed') {
body += `### π΄ BUILD FAILED\n\n`;
body += `The build failed before tests could run.\n\n`;
if (buildErrors && buildErrors.trim()) {
body += `<details>\n<summary><strong>Build Errors</strong></summary>\n\n`;
body += '```\n' + buildErrors.trim() + '\n```\n';
body += `</details>\n\n`;
}
} else if (tests !== '0' && tests !== '') {
// Status header
if (failed === '0') {
body += `### β
ALL TESTS PASSED\n\n`;
} else {
body += `### β ${failed} TEST${failed === '1' ? '' : 'S'} FAILED\n\n`;
}
// Quick stats
let coverageDisplay = '';
if (coverage && coverage !== 'N/A' && coverage !== '') {
coverageDisplay = ` | π ${coverage} coverage`;
}
body += `**${tests} tests** | **${passed} passed** | **${failed} failed** | **${skipped} skipped** | β±οΈ ${duration} | π ${passRate}${coverageDisplay}\n\n`;
// Class breakdown table β collapsed by default. Per-class
// rows are valuable when triaging a failure but noise on a
// green PR. Reviewers click through to expand.
if (classSummary && classSummary.trim()) {
const classLines = classSummary.trim().split('\n').filter(l => l.split('|')[0]);
const failedClasses = classLines.filter(l => l.split('|')[3] !== '0').length;
const summaryLabel = failedClasses > 0
? `<strong>Tests by Class</strong> β ${classLines.length} classes, <strong>${failedClasses} with failures</strong>`
: `<strong>Tests by Class</strong> β ${classLines.length} classes (click to expand)`;
body += `<details${failedClasses > 0 ? ' open' : ''}>\n<summary>${summaryLabel}</summary>\n\n`;
body += `| Class | Tests | Passed | Failed | Duration |\n`;
body += `|-------|-------|--------|--------|----------|\n`;
classLines.forEach(line => {
const [cls, total, pass, fail, dur] = line.split('|');
const icon = fail === '0' ? 'β
' : 'β';
const failCell = fail === '0' ? fail : `**${fail}**`;
body += `| ${icon} ${cls} | ${total} | ${pass} | ${failCell} | ${dur} |\n`;
});
body += `\n</details>\n\n`;
}
} else {
if (testOutcome === 'success') {
body += `### β
ALL TESTS PASSED\n\n`;
} else if (buildErrors && buildErrors.trim()) {
body += `### π΄ BUILD FAILED - No tests ran\n\n`;
body += `<details>\n<summary><strong>Build Errors</strong></summary>\n\n`;
body += '```\n' + buildErrors.trim() + '\n```\n';
body += `</details>\n\n`;
} else {
body += `### β TESTS FAILED\n\n`;
}
}
// Failed tests details
if (failedTests && failedTests.trim()) {
body += `<details>\n<summary><strong>Failed Tests (click to expand)</strong></summary>\n\n`;
body += '```\n' + failedTests.trim() + '\n```\n';
body += `</details>\n\n`;
}
// Testing Coverage Breakdown
body += `### π Testing Coverage Breakdown\n\n`;
// Unit test line coverage β testable excludes UI/lifecycle per
// scripts/coverage-exclude.json; we gate on testable.
if (coverage && coverage !== 'N/A' && coverage !== '') {
body += `**Unit Test Line Coverage (testable surfaces): ${coverage}**\n\n`;
if (totalCoverage && totalCoverage !== 'N/A' && totalCoverage !== '') {
body += `_Total coverage incl. UI/lifecycle: ${totalCoverage} (${excludedFiles} files excluded from testable denominator β see \`scripts/coverage-exclude.json\`)_\n\n`;
}
if (coverageTargets && coverageTargets.trim()) {
body += `| Target | Lines Covered |\n`;
body += `|--------|---------------|\n`;
coverageTargets.trim().split('\n').forEach(line => {
const [name, cov] = line.split('|');
if (name) {
body += `| ${name} | ${cov} |\n`;
}
});
body += '\n';
}
}
// E2E journey coverage moved to chaos-replay-on-pr.yml (simdrive). See docs/architecture/.
body += `> **Why two coverage numbers?** Testable coverage subtracts files that `;
body += `can't be exercised from xcodebuild β SwiftUI views, UIKit VCs, lifecycle `;
body += `(see \`scripts/coverage-exclude.json\`) β so raising it means more _testable_ logic is tested, `;
body += `not that we shipped less UI. Total coverage is kept for continuity. `;
body += `The excluded paths are covered by simdrive E2E journeys (see \`chaos-replay-on-pr.yml\`).\n\n`;
// Trends
if (newFailures || fixedTests || flakyTests || testCountChange) {
body += `### π Trends\n\n`;
if (testCountChange) {
body += `Test count change: **${testCountChange}**\n\n`;
}
if (newFailures && newFailures.trim()) {
body += `<details>\n<summary>β οΈ <strong>New Failures</strong></summary>\n\n`;
body += '```\n' + newFailures.trim() + '\n```\n';
body += `</details>\n\n`;
}
if (fixedTests && fixedTests.trim()) {
body += `<details>\n<summary>β
<strong>Fixed Tests</strong></summary>\n\n`;
body += '```\n' + fixedTests.trim() + '\n```\n';
body += `</details>\n\n`;
}
if (flakyTests && flakyTests.trim()) {
body += `<details>\n<summary>β‘ <strong>Flaky Tests Detected</strong></summary>\n\n`;
body += '```\n' + flakyTests.trim() + '\n```\n';
body += `</details>\n\n`;
}
}
// Snapshot failures
if (snapshotCount && snapshotCount !== '0') {
body += `### πΈ Snapshot Failures: ${snapshotCount}\n`;
body += `Download the **snapshot-failures** artifact to view visual differences.\n\n`;
}
// Links section
body += `---\n`;
if (reportUrl) {
body += `π **[Interactive HTML Report](${reportUrl})** | `;
}
body += `**[CI Run Details](${runUrl})**\n\n`;
// Artifacts table
body += `<details>\n<summary>π¦ <strong>Downloadable Artifacts</strong></summary>\n\n`;
body += `| Artifact | Description |\n`;
body += `|----------|-------------|\n`;
body += `| test-report | π Markdown + HTML reports |\n`;
body += `| test-data | π JSON data for tooling |\n`;
body += `| test-results | π Full xcresult (open in Xcode) |\n`;
if (snapshotCount && snapshotCount !== '0') {
body += `| snapshot-failures | πΌοΈ Visual diff images |\n`;
}
body += `\n</details>`;
// Find and update or create comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const botComment = comments.find(c =>
c.user.type === 'Bot' &&
c.body.includes('π§ͺ Unit Test Results')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
- name: Fail if tests failed
if: steps.tests.outcome == 'failure'
run: exit 1
# Note: The AccessLint GitHub Action handles PR comments and artifact upload automatically
# This combined-report job is no longer needed since AccessLint posts its own comment