-
Notifications
You must be signed in to change notification settings - Fork 3k
563 lines (512 loc) · 21.1 KB
/
Copy pathpr.yaml
File metadata and controls
563 lines (512 loc) · 21.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
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: CI / Pull Request
run-name: "CI PR #${{ github.event.pull_request.number }} head ${{ github.event.pull_request.head.sha }} base ${{ github.event.pull_request.base.sha }} gate ${{ github.event.action != 'edited' || github.event.changes.base != null }}"
on:
pull_request:
types: [opened, synchronize, reopened, edited]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.action != 'edited' || github.event.changes.base != null }}
cancel-in-progress: true
jobs:
# Detect which files changed so we can skip expensive jobs for docs-only PRs.
changes:
if: ${{ github.event.action != 'edited' || github.event.changes.base != null }}
runs-on: ubuntu-latest
timeout-minutes: 2
permissions:
pull-requests: read
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Detect changed paths
id: filter
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
predicate-quantifier: every
filters: |
code:
- '**'
- '!**/*.md'
- '!docs/**'
docs-only-checks:
needs: changes
if: needs.changes.outputs.code != 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js for docs-only checks
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22"
cache: npm
- name: Install docs-only check dependencies
run: npm install --ignore-scripts
- name: Install hadolint
shell: bash
run: |
set -euo pipefail
HADOLINT_VERSION="v2.14.0"
HADOLINT_URL="https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-linux-x86_64"
HADOLINT_SHA256="6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47"
curl -fsSL -o /usr/local/bin/hadolint "$HADOLINT_URL"
ACTUAL=$(sha256sum /usr/local/bin/hadolint | awk '{print $1}')
[ "$HADOLINT_SHA256" = "$ACTUAL" ] || { echo "::error::hadolint checksum mismatch"; exit 1; }
chmod +x /usr/local/bin/hadolint
- name: Resolve checked-out merge base for docs-only checks
shell: bash
run: |
set -euo pipefail
DOCS_ONLY_FROM_REF="$(git merge-base HEAD "origin/${GITHUB_BASE_REF}")"
[ -n "$DOCS_ONLY_FROM_REF" ]
echo "DOCS_ONLY_FROM_REF=$DOCS_ONLY_FROM_REF" >> "$GITHUB_ENV"
- name: Run docs-only hook checks
run: npx prek run --from-ref "$DOCS_ONLY_FROM_REF" --to-ref HEAD
- name: Verify platform matrix is in sync
run: python3 scripts/generate-platform-docs.py --check
static-checks:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Checkout trusted CI actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .trusted-ci-actions
persist-credentials: false
sparse-checkout: |
.github/actions/ci-static-checks
.github/actions/ci-build-typecheck
.github/actions/ci-cli-coverage-shard
.github/actions/ci-cli-coverage-merge
.github/actions/ci-plugin-coverage
.github/actions/ci-installer-integration
.github/actions/ci-install-dependencies.sh
sparse-checkout-cone-mode: false
- name: Run static checks
uses: ./.trusted-ci-actions/.github/actions/ci-static-checks
build-typecheck:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Checkout trusted CI actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .trusted-ci-actions
persist-credentials: false
sparse-checkout: |
.github/actions/ci-static-checks
.github/actions/ci-build-typecheck
.github/actions/ci-cli-coverage-shard
.github/actions/ci-cli-coverage-merge
.github/actions/ci-plugin-coverage
.github/actions/ci-installer-integration
.github/actions/ci-install-dependencies.sh
sparse-checkout-cone-mode: false
- name: Run build and type checks
uses: ./.trusted-ci-actions/.github/actions/ci-build-typecheck
installer-integration:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Checkout trusted CI actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .trusted-ci-actions
persist-credentials: false
sparse-checkout: |
.github/actions/ci-installer-integration
.github/actions/ci-install-dependencies.sh
sparse-checkout-cone-mode: false
- name: Run installer integration tests
uses: ./.trusted-ci-actions/.github/actions/ci-installer-integration
wechat-runtime-audit:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Checkout trusted WeChat runtime audit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .trusted-wechat-audit
persist-credentials: false
sparse-checkout: |
.github/actions/ci-wechat-runtime-audit
.github/actions/ci-reviewed-npm-audit/verify-and-install-npm.sh
sparse-checkout-cone-mode: false
- name: Audit locked WeChat runtime graph
uses: ./.trusted-wechat-audit/.github/actions/ci-wechat-runtime-audit
with:
target-root: ${{ github.workspace }}
report-dir: artifacts/wechat-runtime-audit
- name: Upload WeChat runtime audit evidence
if: ${{ always() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wechat-runtime-audit-${{ github.run_id }}-${{ github.run_attempt }}
path: artifacts/wechat-runtime-audit
if-no-files-found: error
retention-days: 14
reviewed-npm-audit:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Checkout trusted reviewed npm audit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .trusted-reviewed-npm-audit
persist-credentials: false
sparse-checkout: |
.github/actions/ci-reviewed-npm-audit
ci/npm-audit-exceptions.json
ci/reviewed-npm-audit.json
scripts/audit-reviewed-npm-graph.mts
scripts/lib/openclaw-npm-remediation.mts
scripts/lib/reviewed-npm-archive.mts
scripts/lib/reviewed-npm-audit.mts
sparse-checkout-cone-mode: false
- name: Audit reviewed production npm graphs
uses: ./.trusted-reviewed-npm-audit/.github/actions/ci-reviewed-npm-audit
with:
target-root: ${{ github.workspace }}
report-dir: artifacts/reviewed-npm-audit
cli-test-shards:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Checkout trusted CI actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .trusted-ci-actions
persist-credentials: false
sparse-checkout: |
.github/actions/ci-static-checks
.github/actions/ci-build-typecheck
.github/actions/ci-cli-coverage-shard
.github/actions/ci-cli-coverage-merge
.github/actions/ci-plugin-coverage
.github/actions/ci-installer-integration
.github/actions/ci-install-dependencies.sh
sparse-checkout-cone-mode: false
- name: Run CLI coverage shard
uses: ./.trusted-ci-actions/.github/actions/ci-cli-coverage-shard
with:
shard: ${{ matrix.shard }}
shard-count: "12"
cli-tests:
needs:
- changes
- cli-test-shards
if: ${{ always() && needs.changes.outputs.code == 'true' }}
permissions:
actions: read
code-quality: write
contents: read
pull-requests: read
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Verify CLI shards completed
env:
CLI_SHARD_RESULT: ${{ needs['cli-test-shards'].result }}
GH_TOKEN: ${{ github.token }}
RUN_ATTEMPT: ${{ github.run_attempt }}
RUN_ID: ${{ github.run_id }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -u
if [ "$CLI_SHARD_RESULT" != "success" ]; then
details="$RUN_URL"
if jobs_json="$(gh api \
"repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/attempts/$RUN_ATTEMPT/jobs?per_page=100" \
2>/dev/null)"; then
if job_ids="$(jq -er '
if ((.total_count | type) != "number") or
(.total_count < 0) or
(.total_count > 100) or
((.total_count | floor) != .total_count) or
((.jobs | type) != "array") or
((.jobs | length) != .total_count)
then error("invalid workflow job listing")
else
[.jobs[] |
select((.name | type) == "string") |
select(.name | test("^cli-test-shards \\(([1-9]|1[0-2])\\)$")) |
select(.conclusion != "success")] as $failed |
if ($failed | length) == 0 or
($failed | length) > 12 or
(($failed | map(.name) | unique | length) != ($failed | length))
then error("invalid failed CLI shard listing")
else
$failed[] |
if ((.id | type) != "number") or
(.id < 1) or
(.id > 9007199254740991) or
((.id | floor) != .id) or
(.status != "completed") or
((.conclusion | type) != "string")
then error("invalid failed CLI shard")
else .id
end
end
end
' <<<"$jobs_json" 2>/dev/null)"; then
details=""
while IFS= read -r job_id; do
[ -n "$details" ] && details="${details}; "
details="${details}${RUN_URL}/job/${job_id}"
done <<<"$job_ids"
fi
fi
echo "::error title=CLI coverage shards failed::Expected success, got ${CLI_SHARD_RESULT}. Details: ${details}"
exit 1
fi
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Checkout trusted CI actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .trusted-ci-actions
persist-credentials: false
sparse-checkout: |
.github/actions/ci-static-checks
.github/actions/ci-build-typecheck
.github/actions/ci-cli-coverage-shard
.github/actions/ci-cli-coverage-merge
.github/actions/ci-plugin-coverage
.github/actions/ci-installer-integration
.github/actions/ci-install-dependencies.sh
sparse-checkout-cone-mode: false
- name: Merge CLI coverage
uses: ./.trusted-ci-actions/.github/actions/ci-cli-coverage-merge
with:
shard-count: "12"
plugin-tests:
needs: changes
if: needs.changes.outputs.code == 'true'
permissions:
code-quality: write
contents: read
pull-requests: read
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Checkout trusted CI actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .trusted-ci-actions
persist-credentials: false
sparse-checkout: |
.github/actions/ci-static-checks
.github/actions/ci-build-typecheck
.github/actions/ci-cli-coverage-shard
.github/actions/ci-cli-coverage-merge
.github/actions/ci-plugin-coverage
.github/actions/ci-installer-integration
.github/actions/ci-install-dependencies.sh
sparse-checkout-cone-mode: false
- name: Run plugin coverage
uses: ./.trusted-ci-actions/.github/actions/ci-plugin-coverage
checks:
needs:
- changes
- docs-only-checks
- static-checks
- build-typecheck
- installer-integration
- wechat-runtime-audit
- reviewed-npm-audit
- cli-tests
- plugin-tests
if: always()
permissions:
actions: read
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Verify required PR checks
env:
CI_REQUIRED: ${{ github.event.action != 'edited' || github.event.changes.base != null }}
CODE_CHANGED: ${{ needs.changes.outputs.code }}
CHANGES_RESULT: ${{ needs.changes.result }}
DOCS_ONLY_RESULT: ${{ needs['docs-only-checks'].result }}
STATIC_RESULT: ${{ needs['static-checks'].result }}
BUILD_TYPECHECK_RESULT: ${{ needs['build-typecheck'].result }}
INSTALLER_INTEGRATION_RESULT: ${{ needs['installer-integration'].result }}
WECHAT_RUNTIME_AUDIT_RESULT: ${{ needs['wechat-runtime-audit'].result }}
REVIEWED_NPM_AUDIT_RESULT: ${{ needs['reviewed-npm-audit'].result }}
CLI_TESTS_RESULT: ${{ needs['cli-tests'].result }}
GH_TOKEN: ${{ github.token }}
PLUGIN_TESTS_RESULT: ${{ needs['plugin-tests'].result }}
RUN_ATTEMPT: ${{ github.run_attempt }}
RUN_ID: ${{ github.run_id }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
if [ "$CI_REQUIRED" != "true" ]; then
echo "Metadata-only PR edit; the existing head and base CI results remain valid."
exit 0
fi
job_listing_state="uninitialized"
jobs_json=""
dependency_url="$RUN_URL"
failed=0
load_job_listing() {
if [ "$job_listing_state" != "uninitialized" ]; then
return
fi
if jobs_json="$(gh api \
"repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/attempts/$RUN_ATTEMPT/jobs?per_page=100" \
2>/dev/null)" && jq -e '
((.total_count | type) == "number") and
(.total_count >= 0) and
(.total_count <= 100) and
((.total_count | floor) == .total_count) and
((.jobs | type) == "array") and
((.jobs | length) == .total_count)
' <<<"$jobs_json" >/dev/null 2>&1; then
job_listing_state="ready"
else
job_listing_state="failed"
fi
}
resolve_dependency_url() {
local name="$1"
local result="$2"
local job_id=""
dependency_url="$RUN_URL"
case "$name" in
changes|docs-only-checks|static-checks|build-typecheck|installer-integration|wechat-runtime-audit|reviewed-npm-audit|cli-tests|plugin-tests) ;;
*) return ;;
esac
load_job_listing
if [ "$job_listing_state" = "ready" ] && job_id="$(jq -er \
--arg name "$name" \
--arg result "$result" '
[.jobs[] | select(.name == $name)] as $matching |
if ($matching | length) != 1
then error("missing or duplicate dependency job")
elif (($matching[0].id | type) != "number") or
($matching[0].id < 1) or
($matching[0].id > 9007199254740991) or
(($matching[0].id | floor) != $matching[0].id) or
($matching[0].status != "completed") or
(($matching[0].conclusion | type) != "string") or
($matching[0].conclusion != $result)
then error("invalid dependency job")
else $matching[0].id
end
' <<<"$jobs_json" 2>/dev/null)"; then
dependency_url="${RUN_URL}/job/${job_id}"
fi
}
require_success() {
local name="$1"
local result="$2"
if [ "$result" != "success" ]; then
resolve_dependency_url "$name" "$result"
echo "::error title=${name} failed::Expected success, got ${result}. Details: ${dependency_url}"
failed=1
fi
}
allow_success_or_skipped() {
local name="$1"
local result="$2"
case "$result" in
success|skipped) ;;
*)
resolve_dependency_url "$name" "$result"
echo "::error title=${name} failed::Expected success or skipped, got ${result}. Details: ${dependency_url}"
failed=1
;;
esac
}
require_success "changes" "$CHANGES_RESULT"
if [ "$CODE_CHANGED" = "true" ]; then
allow_success_or_skipped "docs-only-checks" "$DOCS_ONLY_RESULT"
require_success "static-checks" "$STATIC_RESULT"
require_success "build-typecheck" "$BUILD_TYPECHECK_RESULT"
require_success "installer-integration" "$INSTALLER_INTEGRATION_RESULT"
require_success "wechat-runtime-audit" "$WECHAT_RUNTIME_AUDIT_RESULT"
require_success "reviewed-npm-audit" "$REVIEWED_NPM_AUDIT_RESULT"
require_success "cli-tests" "$CLI_TESTS_RESULT"
require_success "plugin-tests" "$PLUGIN_TESTS_RESULT"
else
require_success "docs-only-checks" "$DOCS_ONLY_RESULT"
allow_success_or_skipped "static-checks" "$STATIC_RESULT"
allow_success_or_skipped "build-typecheck" "$BUILD_TYPECHECK_RESULT"
allow_success_or_skipped "installer-integration" "$INSTALLER_INTEGRATION_RESULT"
allow_success_or_skipped "wechat-runtime-audit" "$WECHAT_RUNTIME_AUDIT_RESULT"
allow_success_or_skipped "reviewed-npm-audit" "$REVIEWED_NPM_AUDIT_RESULT"
allow_success_or_skipped "cli-tests" "$CLI_TESTS_RESULT"
allow_success_or_skipped "plugin-tests" "$PLUGIN_TESTS_RESULT"
fi
[ "$failed" -eq 0 ]
# Sandbox image builds and E2E tests have moved to pr-self-hosted.yaml,
# which runs on NVIDIA self-hosted runners via copy-pr-bot.
# See: .github/workflows/pr-self-hosted.yaml