-
Notifications
You must be signed in to change notification settings - Fork 3
590 lines (543 loc) · 24.4 KB
/
Copy pathci.yml
File metadata and controls
590 lines (543 loc) · 24.4 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
name: CI
on:
push:
branches:
- main
paths:
- 'Sources/**'
- 'Tests/**'
- 'UITests/**'
- 'Apps/VoidDisplay/**'
- 'VoidDisplay.xcodeproj/**'
- 'Tools/VoidDisplayRelay/**'
- 'Package.swift'
- 'Package.resolved'
- '**/Package.resolved'
- 'mise.toml'
- 'mise.lock'
- 'Brewfile'
- '.swiftformat'
- '.swiftlint.yml'
- 'scripts/**'
- '.github/workflows/**'
- '.github/actions/**'
- '.github/dependabot.yml'
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
classify_changes:
name: classify-changes
runs-on: macos-26
timeout-minutes: 5
permissions:
contents: read
pull-requests: read
outputs:
code_relevant: ${{ steps.classify.outputs.code_relevant }}
ui_relevant: ${{ steps.classify.outputs.ui_relevant }}
script_relevant: ${{ steps.classify.outputs.script_relevant }}
change_scope: ${{ steps.classify.outputs.change_scope }}
product_code_relevant: ${{ steps.classify.outputs.product_code_relevant }}
test_code_relevant: ${{ steps.classify.outputs.test_code_relevant }}
ci_config_relevant: ${{ steps.classify.outputs.ci_config_relevant }}
release_relevant: ${{ steps.classify.outputs.release_relevant }}
dependency_manifest_relevant: ${{ steps.classify.outputs.dependency_manifest_relevant }}
tooling_config_relevant: ${{ steps.classify.outputs.tooling_config_relevant }}
docs_only: ${{ steps.classify.outputs.docs_only }}
unknown_relevant: ${{ steps.classify.outputs.unknown_relevant }}
requires_static: ${{ steps.classify.outputs.requires_static }}
requires_dependency_review: ${{ steps.classify.outputs.requires_dependency_review }}
requires_unit: ${{ steps.classify.outputs.requires_unit }}
requires_xcode_build: ${{ steps.classify.outputs.requires_xcode_build }}
requires_ui_smoke: ${{ steps.classify.outputs.requires_ui_smoke }}
ui_selectors_json: ${{ steps.classify.outputs.ui_selectors_json }}
requires_release_smoke: ${{ steps.classify.outputs.requires_release_smoke }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
persist-credentials: false
- name: Classify changed files
id: classify
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/ci/classify.sh" \
--base "$BASE_SHA" \
--head "$HEAD_SHA" \
--github-output "$GITHUB_OUTPUT" \
--summary .ai-tmp/classify/classify-summary.json
- name: Upload classify artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: classify
path: .ai-tmp/classify
if-no-files-found: warn
retention-days: 7
dependency_review:
name: dependency-review
needs:
- classify_changes
if: ${{ github.event_name == 'pull_request' && needs.classify_changes.outputs.requires_dependency_review == 'true' }}
runs-on: macos-26
timeout-minutes: 10
permissions:
contents: read
pull-requests: read
steps:
- name: Dependency review
uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0
with:
fail-on-severity: high
comment-summary-in-pr: never
script_static_checks:
name: script-static-checks
needs:
- classify_changes
if: ${{ needs.classify_changes.outputs.requires_static == 'true' }}
runs-on: macos-26
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Bootstrap static tools
shell: bash
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/dev/bootstrap.sh" --profile static
- name: Validate static gates
shell: bash
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/ci/static.sh"
unit_tests:
name: unit-tests
needs:
- classify_changes
- script_static_checks
if: ${{ needs.classify_changes.outputs.requires_unit == 'true' }}
uses: ./.github/workflows/_reusable-unit-tests.yml
with:
artifact_retention_days: 7
xcode_build:
name: xcode-build
needs:
- classify_changes
- script_static_checks
if: ${{ needs.classify_changes.outputs.requires_xcode_build == 'true' }}
runs-on: macos-26
timeout-minutes: 25
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Select Xcode
uses: ./.github/actions/xcode-select
- name: Bootstrap tools
shell: bash
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/dev/bootstrap.sh" --profile xcode
- name: Run doctor checks
shell: bash
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/dev/doctor.sh" \
--out-dir .ai-tmp/xcode-build/doctor
- name: Xcode Debug build
shell: bash
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/ci/xcode.sh" \
--action build \
--configuration Debug \
--out-dir .ai-tmp/xcode-build
- name: Upload Xcode build artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: xcode-build
path: |
.ai-tmp/xcode-build
!.ai-tmp/xcode-build/DerivedData
if-no-files-found: warn
retention-days: 7
ui_smoke_tests:
name: ui-smoke-tests
needs:
- classify_changes
- script_static_checks
if: ${{ needs.classify_changes.outputs.requires_ui_smoke == 'true' }}
uses: ./.github/workflows/_reusable-ui-smoke-tests.yml
with:
only_testing_json: ${{ needs.classify_changes.outputs.ui_selectors_json }}
artifact_retention_days: 7
artifact_name_suffix: pr
enforce_failure: true
release_build_check_arm64:
name: release-build-check (arm64)
needs:
- classify_changes
- script_static_checks
if: ${{ needs.classify_changes.outputs.requires_release_smoke == 'true' }}
runs-on: macos-26
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Bootstrap tools
shell: bash
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/dev/bootstrap.sh" --profile release-smoke
- name: Release smoke
shell: bash
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/ci/release_smoke.sh" \
--arch arm64 \
--label arm64 \
--out-dir .ai-tmp/release-check-arm64
- name: Upload release smoke artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: release-smoke-arm64
path: |
.ai-tmp/release-check-arm64
!.ai-tmp/release-check-arm64/DerivedData
if-no-files-found: warn
retention-days: 7
release_build_check_intel64:
name: release-build-check (intel64)
needs:
- classify_changes
- script_static_checks
if: ${{ github.event_name == 'push' && needs.classify_changes.outputs.requires_release_smoke == 'true' }}
runs-on: macos-26-intel
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Bootstrap tools
shell: bash
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/dev/bootstrap.sh" --profile release-smoke
- name: Release smoke
shell: bash
run: |
set -euo pipefail
tool_root="$GITHUB_WORKSPACE"
ROOT_DIR="$GITHUB_WORKSPACE" TOOL_ROOT="$tool_root" "$tool_root/scripts/ci/release_smoke.sh" \
--arch x86_64 \
--label intel64 \
--out-dir .ai-tmp/release-check-intel64
- name: Upload release smoke artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: release-smoke-intel64
path: |
.ai-tmp/release-check-intel64
!.ai-tmp/release-check-intel64/DerivedData
if-no-files-found: warn
retention-days: 7
ci_gate:
name: ci-gate
if: always()
needs:
- classify_changes
- dependency_review
- script_static_checks
- unit_tests
- xcode_build
- ui_smoke_tests
- release_build_check_arm64
- release_build_check_intel64
runs-on: macos-26
timeout-minutes: 5
permissions:
contents: read
steps:
- name: Enforce CI gate
env:
CLASSIFY_RESULT: ${{ needs.classify_changes.result }}
EVENT_NAME: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
CHANGE_SCOPE: ${{ needs.classify_changes.outputs.change_scope }}
CODE_RELEVANT: ${{ needs.classify_changes.outputs.code_relevant }}
UI_RELEVANT: ${{ needs.classify_changes.outputs.ui_relevant }}
SCRIPT_RELEVANT: ${{ needs.classify_changes.outputs.script_relevant }}
PRODUCT_CODE_RELEVANT: ${{ needs.classify_changes.outputs.product_code_relevant }}
TEST_CODE_RELEVANT: ${{ needs.classify_changes.outputs.test_code_relevant }}
CI_CONFIG_RELEVANT: ${{ needs.classify_changes.outputs.ci_config_relevant }}
RELEASE_RELEVANT: ${{ needs.classify_changes.outputs.release_relevant }}
DEPENDENCY_MANIFEST_RELEVANT: ${{ needs.classify_changes.outputs.dependency_manifest_relevant }}
TOOLING_CONFIG_RELEVANT: ${{ needs.classify_changes.outputs.tooling_config_relevant }}
DOCS_ONLY: ${{ needs.classify_changes.outputs.docs_only }}
UNKNOWN_RELEVANT: ${{ needs.classify_changes.outputs.unknown_relevant }}
REQUIRES_STATIC: ${{ needs.classify_changes.outputs.requires_static }}
REQUIRES_DEPENDENCY_REVIEW: ${{ needs.classify_changes.outputs.requires_dependency_review }}
REQUIRES_UNIT: ${{ needs.classify_changes.outputs.requires_unit }}
REQUIRES_XCODE_BUILD: ${{ needs.classify_changes.outputs.requires_xcode_build }}
REQUIRES_UI_SMOKE: ${{ needs.classify_changes.outputs.requires_ui_smoke }}
REQUIRES_RELEASE_SMOKE: ${{ needs.classify_changes.outputs.requires_release_smoke }}
DEPENDENCY_RESULT: ${{ needs.dependency_review.result }}
SCRIPT_RESULT: ${{ needs.script_static_checks.result }}
UNIT_RESULT: ${{ needs.unit_tests.result }}
XCODE_RESULT: ${{ needs.xcode_build.result }}
UI_RESULT: ${{ needs.ui_smoke_tests.result }}
RELEASE_ARM64_RESULT: ${{ needs.release_build_check_arm64.result }}
RELEASE_INTEL64_RESULT: ${{ needs.release_build_check_intel64.result }}
run: |
set -euo pipefail
echo "Classify result: ${CLASSIFY_RESULT}"
echo "Event: ${EVENT_NAME}"
echo "Base ref: ${BASE_REF:-n/a}"
echo "Change scope: ${CHANGE_SCOPE}"
echo "Relevant: code=${CODE_RELEVANT} ui=${UI_RELEVANT} script=${SCRIPT_RELEVANT} product=${PRODUCT_CODE_RELEVANT} test=${TEST_CODE_RELEVANT} ci=${CI_CONFIG_RELEVANT} release=${RELEASE_RELEVANT} dependency=${DEPENDENCY_MANIFEST_RELEVANT} tooling=${TOOLING_CONFIG_RELEVANT} docs_only=${DOCS_ONLY} unknown=${UNKNOWN_RELEVANT}"
echo "Required: static=${REQUIRES_STATIC} dependency=${REQUIRES_DEPENDENCY_REVIEW} unit=${REQUIRES_UNIT} xcode=${REQUIRES_XCODE_BUILD} ui=${REQUIRES_UI_SMOKE} release=${REQUIRES_RELEASE_SMOKE}"
echo "Dependency review: ${DEPENDENCY_RESULT}"
echo "Static: ${SCRIPT_RESULT}"
echo "Unit: ${UNIT_RESULT}"
echo "Xcode build: ${XCODE_RESULT}"
echo "UI smoke: ${UI_RESULT}"
echo "Release smoke arm64: ${RELEASE_ARM64_RESULT}"
echo "Release smoke intel64: ${RELEASE_INTEL64_RESULT}"
if [ "$CLASSIFY_RESULT" != "success" ]; then
echo "Gate failed because classify-changes result is ${CLASSIFY_RESULT}."
exit 1
fi
check_required() {
local requirement="$1"
local result="$2"
local label="$3"
if [ "$requirement" = "true" ] && [ "$result" != "success" ]; then
echo "Gate failed because ${label} is required but result is ${result}."
exit 1
fi
if [ "$requirement" = "true" ]; then
echo "Gate accepted ${label}: required and passed."
else
echo "Gate accepted ${label}: not required, result is ${result}."
fi
}
check_required "$REQUIRES_DEPENDENCY_REVIEW" "$DEPENDENCY_RESULT" "dependency-review"
check_required "$REQUIRES_STATIC" "$SCRIPT_RESULT" "script-static-checks"
check_required "$REQUIRES_UNIT" "$UNIT_RESULT" "unit-tests"
check_required "$REQUIRES_XCODE_BUILD" "$XCODE_RESULT" "xcode-build"
check_required "$REQUIRES_UI_SMOKE" "$UI_RESULT" "ui-smoke-tests"
check_required "$REQUIRES_RELEASE_SMOKE" "$RELEASE_ARM64_RESULT" "release-build-check-arm64"
if [ "$EVENT_NAME" = "push" ]; then
check_required "$REQUIRES_RELEASE_SMOKE" "$RELEASE_INTEL64_RESULT" "release-build-check-intel64"
else
check_required "false" "$RELEASE_INTEL64_RESULT" "release-build-check-intel64"
fi
exit 0
ci_summary:
name: ci-summary
if: always()
needs:
- classify_changes
- dependency_review
- script_static_checks
- unit_tests
- xcode_build
- ui_smoke_tests
- release_build_check_arm64
- release_build_check_intel64
- ci_gate
runs-on: macos-26
timeout-minutes: 5
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Render summary and update PR sticky comment
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
EVENT_NAME: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
CHANGE_SCOPE: ${{ needs.classify_changes.outputs.change_scope }}
CODE_RELEVANT: ${{ needs.classify_changes.outputs.code_relevant }}
UI_RELEVANT: ${{ needs.classify_changes.outputs.ui_relevant }}
SCRIPT_RELEVANT: ${{ needs.classify_changes.outputs.script_relevant }}
PRODUCT_CODE_RELEVANT: ${{ needs.classify_changes.outputs.product_code_relevant }}
TEST_CODE_RELEVANT: ${{ needs.classify_changes.outputs.test_code_relevant }}
CI_CONFIG_RELEVANT: ${{ needs.classify_changes.outputs.ci_config_relevant }}
RELEASE_RELEVANT: ${{ needs.classify_changes.outputs.release_relevant }}
DEPENDENCY_MANIFEST_RELEVANT: ${{ needs.classify_changes.outputs.dependency_manifest_relevant }}
TOOLING_CONFIG_RELEVANT: ${{ needs.classify_changes.outputs.tooling_config_relevant }}
DOCS_ONLY: ${{ needs.classify_changes.outputs.docs_only }}
UNKNOWN_RELEVANT: ${{ needs.classify_changes.outputs.unknown_relevant }}
REQUIRES_STATIC: ${{ needs.classify_changes.outputs.requires_static }}
REQUIRES_DEPENDENCY_REVIEW: ${{ needs.classify_changes.outputs.requires_dependency_review }}
REQUIRES_UNIT: ${{ needs.classify_changes.outputs.requires_unit }}
REQUIRES_XCODE_BUILD: ${{ needs.classify_changes.outputs.requires_xcode_build }}
REQUIRES_UI_SMOKE: ${{ needs.classify_changes.outputs.requires_ui_smoke }}
REQUIRES_RELEASE_SMOKE: ${{ needs.classify_changes.outputs.requires_release_smoke }}
DEPENDENCY_RESULT: ${{ needs.dependency_review.result }}
SCRIPT_RESULT: ${{ needs.script_static_checks.result }}
UNIT_RESULT: ${{ needs.unit_tests.result }}
UNIT_ARTIFACT: ${{ needs.unit_tests.outputs.artifact_name }}
UNIT_SWIFT_TEST_COUNT: ${{ needs.unit_tests.outputs.swift_test_count }}
UNIT_GO_PACKAGE_COUNT: ${{ needs.unit_tests.outputs.go_package_count }}
UNIT_REASON: ${{ needs.unit_tests.outputs.unit_reason }}
XCODE_RESULT: ${{ needs.xcode_build.result }}
UI_RESULT: ${{ needs.ui_smoke_tests.result }}
RELEASE_ARM64_RESULT: ${{ needs.release_build_check_arm64.result }}
RELEASE_INTEL64_RESULT: ${{ needs.release_build_check_intel64.result }}
GATE_RESULT: ${{ needs.ci_gate.result }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
script: |
const marker = '<!-- ci-summary-marker -->';
const runUrl = process.env.RUN_URL;
const artifactsUrl = `${runUrl}#artifacts`;
const value = (name, fallback = 'n/a') => {
const raw = process.env[name];
return raw && raw.trim().length > 0 ? raw : fallback;
};
const unitDetails = [
`Swift tests: ${value('UNIT_SWIFT_TEST_COUNT')}`,
`Go packages: ${value('UNIT_GO_PACKAGE_COUNT')}`,
`Reason: ${value('UNIT_REASON')}`,
`Artifact: ${value('UNIT_ARTIFACT')}`,
].join('<br>');
const uiDetails = [
'The PR UI job builds once, runs its selectors serially, and writes aggregate failure classification to ui-smoke-summary.json.',
'Artifact: ui-smoke-pr',
].join('<br>');
const releaseStatus = context.eventName === 'pull_request'
? value('RELEASE_ARM64_RESULT', 'unknown')
: `arm64=${value('RELEASE_ARM64_RESULT', 'unknown')}<br>intel64=${value('RELEASE_INTEL64_RESULT', 'unknown')}`;
const releaseDetails = [
`arm64=${value('RELEASE_ARM64_RESULT', 'unknown')}`,
`intel64=${value('RELEASE_INTEL64_RESULT', 'unknown')}`,
context.eventName === 'pull_request'
? 'PR release smoke requires arm64 only.'
: 'Push release smoke requires arm64 and intel64.',
context.eventName === 'pull_request'
? 'Artifacts: release-smoke-arm64'
: 'Artifacts: release-smoke-arm64, release-smoke-intel64',
'Release verify summaries are produced by release.yml before publishing.',
].join('<br>');
const classificationDetails = [
`code=${value('CODE_RELEVANT')}`,
`ui=${value('UI_RELEVANT')}`,
`script=${value('SCRIPT_RELEVANT')}`,
`product=${value('PRODUCT_CODE_RELEVANT')}`,
`test=${value('TEST_CODE_RELEVANT')}`,
`ci=${value('CI_CONFIG_RELEVANT')}`,
`release=${value('RELEASE_RELEVANT')}`,
`dependency=${value('DEPENDENCY_MANIFEST_RELEVANT')}`,
`tooling=${value('TOOLING_CONFIG_RELEVANT')}`,
`docs_only=${value('DOCS_ONLY')}`,
`unknown=${value('UNKNOWN_RELEVANT')}`,
].join('<br>');
const requirementDetails = [
`static=${value('REQUIRES_STATIC')}`,
`dependency=${value('REQUIRES_DEPENDENCY_REVIEW')}`,
`unit=${value('REQUIRES_UNIT')}`,
`xcode=${value('REQUIRES_XCODE_BUILD')}`,
`ui=${value('REQUIRES_UI_SMOKE')}`,
`release=${value('REQUIRES_RELEASE_SMOKE')}`,
'Static runs for every PR. Unit, Xcode, UI, and release gates follow the changed paths.',
].join('<br>');
const rows = [
['Change Scope', value('CHANGE_SCOPE', 'unknown'), classificationDetails],
['Required Gates', 'derived', requirementDetails],
['Dependency Review', value('DEPENDENCY_RESULT', 'unknown'), `required=${value('REQUIRES_DEPENDENCY_REVIEW')}<br>high and critical vulnerabilities block`],
['Static Checks', value('SCRIPT_RESULT', 'unknown'), `required=${value('REQUIRES_STATIC')}<br>actionlint, shellcheck, shfmt, SwiftFormat, SwiftLint, action pinning`],
['Unit Tests', value('UNIT_RESULT', 'unknown'), `required=${value('REQUIRES_UNIT')}<br>${unitDetails}`],
['Xcode Build', value('XCODE_RESULT', 'unknown'), `required=${value('REQUIRES_XCODE_BUILD')}<br>Debug build with zero warning scan<br>Artifact: xcode-build`],
['UI Smoke', value('UI_RESULT', 'unknown'), `required=${value('REQUIRES_UI_SMOKE')}<br>${uiDetails}`],
['Release Smoke', releaseStatus, `required=${value('REQUIRES_RELEASE_SMOKE')}<br>${releaseDetails}`],
['Artifacts', 'link', `[Open artifacts](${artifactsUrl})`],
['CI Gate', value('GATE_RESULT', 'unknown'), 'single branch protection check'],
];
const summaryLines = [
'## CI Summary',
'',
`Run: [Open](${process.env.RUN_URL})`,
'',
'| Check | Status | Details |',
'| --- | --- | --- |',
...rows.map(([check, status, details]) => `| ${check} | ${status} | ${details} |`),
];
const summaryBody = summaryLines.join('\n');
const commentBody = [marker, ...summaryLines].join('\n');
const shouldCreateComment = value('GATE_RESULT', 'unknown') !== 'success';
await core.summary.addRaw(summaryBody + '\n').write();
if (context.eventName !== 'pull_request') {
return;
}
const prNumber = context.payload.pull_request?.number;
if (!prNumber) {
return;
}
try {
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
per_page: 100,
});
const existing = [...comments].reverse().find((comment) =>
comment.user?.type === 'Bot' && typeof comment.body === 'string' && comment.body.includes(marker)
);
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: commentBody,
});
} else if (shouldCreateComment) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody,
});
}
} catch (error) {
core.warning(`Failed to update CI summary sticky comment: ${error.message}`);
}