Repository navigation
778 lines (762 loc) · 40.8 KB
/
Copy pathci.yml
File metadata and controls
778 lines (762 loc) · 40.8 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
name: CI
on:
pull_request:
push:
branches:
- main
merge_group:
workflow_dispatch:
permissions:
contents: read
# A new PR push cancels the PR's older run. Each main push gets a group of its
# own, so its run starts at once and is never cancelled or replaced: main runs
# used to queue one at a time, and a push waited up to 14 min for the previous
# run's First Agent Smoke before its lanes started. Overlapping main runs share
# no state: image builds only restore the BuildKit cache (ci-image-cache.yml is
# its one writer), pnpm store cache entries are immutable, and artifacts belong
# to their run. Merge queue and manual runs keep their ref's group.
concurrency:
group: ${{ github.event_name == 'push' && format('ci-push-{0}', github.sha) || format('ci-{0}', github.event.pull_request.number || github.ref) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CI: "1"
NODE_VERSION: "24.22.1"
# Metadata gates use the same patched runtime as the other CI lanes.
GATE_NODE_VERSION: "24.22.1"
jobs:
impact:
name: CI Impact
runs-on: ubuntu-22.04
outputs:
mode: ${{ steps.select.outputs.mode }}
lanes: ${{ steps.select.outputs.lanes }}
matrix: ${{ steps.matrix.outputs.matrix }}
image-matrix: ${{ steps.matrix.outputs.image-matrix }}
has-matrix: ${{ steps.matrix.outputs.has-matrix }}
has-images: ${{ steps.matrix.outputs.has-images }}
fixture: ${{ steps.matrix.outputs.fixture }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 2
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: ${{ env.GATE_NODE_VERSION }}
- id: select
env:
IMPACT_ACTION: select
run: |
# The workflow itself is PR-controlled; independent required-workflow
# enforcement is needed to protect this bootstrap from workflow edits.
policy=$(mktemp "$RUNNER_TEMP/ci-impact-policy.XXXXXX.ts")
trap 'rm -f "$policy"' EXIT
trusted_policy() {
reason=bootstrap_non_pr_event
if [ "${GITHUB_EVENT_NAME:-}" = push ]; then
[ "${GITHUB_REPOSITORY:-}" = openclaw/openclaw-enterprise ] && [ "${GITHUB_REF:-}" = refs/heads/main ] || return 1
reason=bootstrap_event_unavailable
base=$(jq -er '.before | select(type == "string")' "$GITHUB_EVENT_PATH") || return 1
head=$(jq -er '.after | select(type == "string")' "$GITHUB_EVENT_PATH") || return 1
else
[ "${GITHUB_EVENT_NAME:-}" = pull_request ] || return 1
reason=bootstrap_event_unavailable
base=$(jq -er '.pull_request.base.sha | select(type == "string")' "$GITHUB_EVENT_PATH") || return 1
head=$(jq -er '.pull_request.head.sha | select(type == "string")' "$GITHUB_EVENT_PATH") || return 1
fi
reason=bootstrap_invalid_identity
oid='^([0-9a-f]{40}|[0-9a-f]{64})$'
[[ $base =~ $oid && $head =~ $oid && ${GITHUB_SHA:-} =~ $oid ]] || return 1
reason=bootstrap_git_inspection_failed
actual=$(git rev-parse --verify 'HEAD^{commit}') || return 1
reason=bootstrap_checkout_mismatch
[ "$actual" = "$GITHUB_SHA" ] || return 1
reason=bootstrap_git_inspection_failed
if [ "${GITHUB_EVENT_NAME:-}" = push ]; then
reason=bootstrap_checkout_mismatch
[ "$head" = "$GITHUB_SHA" ] || return 1
git cat-file -e "$base^{commit}" && git merge-base --is-ancestor "$base" "$head" || return 1
merge_base=$base
else
parents=$(git show -s --format=%P "$GITHUB_SHA") || return 1
reason=bootstrap_checkout_mismatch
[[ $parents =~ ^([0-9a-f]{40}|[0-9a-f]{64})\ ([0-9a-f]{40}|[0-9a-f]{64})$ ]] || return 1
[ "${BASH_REMATCH[2]}" = "$head" ] || return 1
merge_base=${BASH_REMATCH[1]}
reason=bootstrap_git_inspection_failed
git cat-file -e "$merge_base^{commit}" && git cat-file -e "$head^{commit}" || return 1
# GitHub merges onto the base tip at merge time; base.sha lags it
# when the base moved after the push and is then not fetched.
reason=bootstrap_checkout_mismatch
if [ "$base" != "$merge_base" ] && git cat-file -e "$base^{commit}" 2>/dev/null; then
git merge-base --is-ancestor "$base" "$merge_base" || return 1
fi
fi
reason=bootstrap_git_inspection_failed
entry=$(git ls-tree "$merge_base" -- scripts/ci/impact.ts) || return 1
reason=bootstrap_policy_unavailable
[[ $entry =~ ^100644\ blob\ ([0-9a-f]{40}|[0-9a-f]{64})[[:space:]]scripts/ci/impact\.ts$ ]] || return 1
reason=bootstrap_git_inspection_failed
git cat-file blob "${BASH_REMATCH[1]}" > "$policy" || return 1
reason=bootstrap_policy_unavailable
[ -s "$policy" ]
}
if trusted_policy; then
if [ "$IMPACT_ACTION" = select ]; then
node "$policy" --github-output "$GITHUB_OUTPUT"
elif [ "$EXPECTED_MODE" = tests ]; then
node "$policy" --verify-mode tests --lanes "$EXPECTED_LANES"
else
node "$policy" --verify-mode "$EXPECTED_MODE"
fi
elif [ "$IMPACT_ACTION" = select ]; then
printf 'CI impact: full (trusted base policy unavailable)\n'
printf 'mode=full\nreason=%s\n' "$reason" >> "$GITHUB_OUTPUT"
else
[ "$EXPECTED_MODE" = full ] || exit 1
printf 'CI impact: full (trusted base policy unavailable)\n'
fi
# One row per pr-safe lane (runtime-image-fixture is its own job). Full
# mode runs every row; tests mode runs the rows the policy selected.
# The baseline tests are split in two, balanced by measured file
# durations; only part 1 runs the type and Go CLI checks (Static Checks
# runs lint, format, OpenAPI and docs beside the lanes).
# Image Runtime Startup is split from Images and Packaging, which it
# would otherwise lengthen by about five minutes. The runtime image
# startup tests are split in three, balanced by measured case durations;
# only part 1 runs the Codex sandbox, so only it needs the k3d tools for
# the seccomp profile. Part 3 runs Docker-only files from part 1: two
# that ran beside its startup file, and the native listener cases split
# from that file, whose cases run one after another and set part 1's
# length. Part 3 also runs the CPU-contended model probe case beside
# them; it waits out the 110 s probe cap at 500m on any runner and sets
# part 3's length (it was a job of its own, Image Model Probes).
# Runner labels now expose their named CPU capacity. Restore the
# measured pre-November 3 allocations without changing lane concurrency.
# k3d keeps Blacksmith's kernel for NetworkPolicy checks. Runtime image lanes
# retain 8 CPUs / 30.4 GiB for their measured 15-20 GiB peaks. Browser
# lanes use 8 CPUs with their existing eight-file concurrency.
# Ordinary Conformance 1 uses 4 CPUs; Full Integration keeps 8 for its
# additional static checks. The test runner caps files to available CPUs.
- id: matrix
name: Build lane matrix
env:
SELECT_MODE: ${{ steps.select.outputs.mode }}
SELECT_LANES: ${{ steps.select.outputs.lanes }}
LANE_TABLE: |
[
{"lane": "checks-baseline-1", "title": "Checks and Conformance 1", "profile": "baseline", "timeout": 25, "runner": "blacksmith-4vcpu-ubuntu-2404"},
{"lane": "checks-baseline-2", "title": "Checks and Conformance 2", "profile": "baseline", "timeout": 25, "runner": "blacksmith-8vcpu-ubuntu-2404"},
{"lane": "checks-browser", "title": "Console Browser", "profile": "baseline", "timeout": 25, "runner": "blacksmith-8vcpu-ubuntu-2404"},
{"lane": "checks-browser-2", "title": "Console Browser 2", "profile": "baseline", "timeout": 25, "runner": "blacksmith-8vcpu-ubuntu-2404"},
{"lane": "postgres", "title": "PostgreSQL Migrations", "profile": "postgres", "timeout": 25, "runner": "blacksmith-4vcpu-ubuntu-2404"},
{"lane": "postgres-application", "title": "PostgreSQL Application", "profile": "postgres", "timeout": 25, "runner": "blacksmith-8vcpu-ubuntu-2404"},
{"lane": "postgres-auth", "title": "PostgreSQL Authentication", "profile": "postgres", "timeout": 25, "runner": "blacksmith-4vcpu-ubuntu-2404"},
{"lane": "postgres-platform", "title": "PostgreSQL Platform", "profile": "postgres", "timeout": 25, "runner": "blacksmith-4vcpu-ubuntu-2404"},
{"lane": "images-packaging", "title": "Images and Packaging", "profile": "full", "timeout": 45, "runner": "blacksmith-4vcpu-ubuntu-2404"},
{"lane": "images-runtime-startup", "title": "Image Runtime Startup", "profile": "full", "timeout": 30, "runner": "blacksmith-8vcpu-ubuntu-2404"},
{"lane": "images-runtime-startup-2", "title": "Image Runtime Startup 2", "profile": "docker-only", "timeout": 30, "runner": "blacksmith-8vcpu-ubuntu-2404"},
{"lane": "images-runtime-startup-3", "title": "Image Runtime Startup 3", "profile": "images", "timeout": 30, "runner": "blacksmith-8vcpu-ubuntu-2404"},
{"lane": "k3d-fixture-configuration", "title": "k3d Fixture and Configuration", "profile": "k3d", "timeout": 45, "runner": "blacksmith-4vcpu-ubuntu-2404"},
{"lane": "k3d-fixture-state", "title": "k3d State and Lifecycle", "profile": "k3d", "timeout": 45, "runner": "blacksmith-4vcpu-ubuntu-2404"},
{"lane": "k3d-fixture-network", "title": "k3d Network Isolation", "profile": "k3d", "timeout": 45, "runner": "blacksmith-2vcpu-ubuntu-2404"},
{"lane": "k3d-fixture-plugins", "title": "k3d Plugin Status", "profile": "k3d", "timeout": 45, "runner": "blacksmith-2vcpu-ubuntu-2404"},
{"lane": "k3d-observability", "title": "Production Observability", "profile": "k3d", "timeout": 45, "runner": "blacksmith-2vcpu-ubuntu-2404"},
{"lane": "logging-collector", "title": "Logging Collector", "profile": "baseline", "timeout": 30, "runner": "blacksmith-2vcpu-ubuntu-2404"},
{"lane": "repository-credentials-container", "title": "Repository Credentials", "profile": "images", "timeout": 40, "runner": "blacksmith-4vcpu-ubuntu-2404"},
{"lane": "keycloak-oidc", "title": "Keycloak OIDC", "profile": "postgres", "timeout": 25, "runner": "blacksmith-4vcpu-ubuntu-2404"}
]
run: |
table=$(jq -ce 'if type == "array" and length > 0 then . else error("invalid lane table") end' <<<"$LANE_TABLE")
if [ "$SELECT_MODE" = tests ]; then
lanes=$(jq -ce 'if type == "array" and length > 0 and all(.[]; type == "string") then . else error("invalid lanes") end' <<<"$SELECT_LANES")
# Every selected lane needs a runner; CI Required checks each one's results.
jq -e --argjson table "$table" 'all(.[]; . as $lane | $lane == "runtime-image-fixture" or ($table | any(.[]; .lane == $lane)))' <<<"$lanes" >/dev/null
matrix=$(jq -ce --argjson lanes "$lanes" '[.[] | select(.lane as $lane | $lanes | any(.[]; . == $lane))] | if length > 0 then . else error("no matrix lanes") end' <<<"$table")
fixture=$(jq -r 'if any(.[]; . == "runtime-image-fixture") then "true" else "false" end' <<<"$lanes")
else
matrix=$table
fixture=true
fi
images=$(jq -c '[.[] | select(.lane | startswith("images-"))]' <<<"$matrix")
matrix=$(jq -c '[.[] | select(.lane | startswith("images-") | not)]' <<<"$matrix")
printf 'matrix=%s\nimage-matrix=%s\nfixture=%s\nhas-matrix=%s\nhas-images=%s\n' "$matrix" "$images" "$fixture" "$(jq 'length > 0' <<<"$matrix")" "$(jq 'length > 0' <<<"$images")" >> "$GITHUB_OUTPUT"
- name: Report main test advisory
if: ${{ !cancelled() && github.event_name == 'push' }}
continue-on-error: true
env:
GIT_NO_LAZY_FETCH: "1"
SELECTION: ${{ steps.select.outcome }}-${{ steps.select.outputs.mode }}-${{ steps.select.outputs.reason }}
MATRIX_OUTCOME: ${{ steps.matrix.outcome }}
MATRIX: ${{ steps.matrix.outputs.matrix }}
IMAGES: ${{ steps.matrix.outputs.image-matrix }}
run: |
# Both selection results follow the before-policy push identity and ancestry checks.
# Report the same event's endpoints only while that policy is unchanged.
predict() (
[ "$GITHUB_EVENT_NAME" = push ] && [ "$MATRIX_OUTCOME" = success ] || return 1
case "$SELECTION" in success-full-ineligible_change|success-docs-docs_only) ;; *) return 1 ;; esac
before=$(jq -er --arg after "$GITHUB_SHA" 'select(.after == $after) | .before' "$GITHUB_EVENT_PATH") || return 1
oid='^[0-9a-f]{40}$'
[[ $before =~ $oid && $GITHUB_SHA =~ $oid && $before != "$GITHUB_SHA" ]] || return 1
git diff --quiet "$before" "$GITHUB_SHA" -- scripts/ci/impact.ts || return 1
lanes='[]'
if [ "$SELECTION" = success-full-ineligible_change ]; then
policy=$(mktemp "$RUNNER_TEMP/ci-main-test.XXXXXX.ts") || return 1
trap 'rm -f "$policy"' EXIT
git cat-file blob "$before:scripts/ci/impact.ts" > "$policy" || return 1
lanes=$(timeout -k 2s 20s env -u GITHUB_OUTPUT node "$policy" --main-test-advisory) || return 1
fi
jq -cen --arg before "$before" --arg after "$GITHUB_SHA" --argjson lanes "$lanes" --argjson matrix "$MATRIX" --argjson images "$IMAGES" '
(($matrix + $images | map(.lane)) + ["runtime-image-fixture"]) as $allowed |
$lanes | select(type == "array" and . == unique and
(length == 0 or length < ($allowed | length)) and
all(.[]; . as $lane | test("^[a-z0-9-]+$") and ($allowed | index($lane) != null))) |
{prediction:(if length == 0 then "broad" else "one_modified_test" end),lanes:.,before:$before,after:$after}'
)
if ! prediction=$(predict 2>/dev/null); then prediction='{"prediction":"broad","lanes":[]}'; fi
printf '::notice title=CI main test advisory v2::%s\n' "$prediction"
- name: Summarize impact selection
if: ${{ always() }}
env:
SELECT_OUTCOME: ${{ steps.select.outcome }}
SELECT_MODE: ${{ steps.select.outputs.mode }}
SELECT_REASON: ${{ steps.select.outputs.reason }}
SELECT_LANES: ${{ steps.select.outputs.lanes }}
MATRIX_OUTCOME: ${{ steps.matrix.outcome }}
run: |
# Output only fixed literals, even when workflow inputs are untrusted.
mode=unavailable
reason=unavailable
if [ "$SELECT_OUTCOME" = success ]; then
case "$SELECT_MODE" in
docs|full|tests) mode="$SELECT_MODE" ;;
esac
case "$mode:$SELECT_REASON" in
docs:docs_only) reason=docs_only ;;
tests:tests_only) reason=tests_only ;;
full:non_pr_event) reason=non_pr_event ;;
full:bootstrap_non_pr_event) reason=bootstrap_non_pr_event ;;
full:invalid_event) reason=invalid_event ;;
full:invalid_identity) reason=invalid_identity ;;
full:event_unavailable) reason=event_unavailable ;;
full:bootstrap_event_unavailable) reason=bootstrap_event_unavailable ;;
full:bootstrap_invalid_identity) reason=bootstrap_invalid_identity ;;
full:checkout_mismatch) reason=checkout_mismatch ;;
full:bootstrap_checkout_mismatch) reason=bootstrap_checkout_mismatch ;;
full:git_inspection_failed) reason=git_inspection_failed ;;
full:bootstrap_git_inspection_failed) reason=bootstrap_git_inspection_failed ;;
full:bootstrap_policy_unavailable) reason=bootstrap_policy_unavailable ;;
full:malformed_diff) reason=malformed_diff ;;
full:empty_diff) reason=empty_diff ;;
full:unsupported_change) reason=unsupported_change ;;
full:filename_not_utf8) reason=filename_not_utf8 ;;
full:ineligible_change) reason=ineligible_change ;;
full:manifest_change) reason=manifest_change ;;
full:manifest_unavailable) reason=manifest_unavailable ;;
full:unmapped_test) reason=unmapped_test ;;
full:referenced_test) reason=referenced_test ;;
esac
fi
lanes=
if [ "$mode:$reason" = tests:tests_only ]; then
lanes=unavailable
# Only lane names the matrix step accepted; never raw selector output.
if [ "$MATRIX_OUTCOME" = success ] && [[ $SELECT_LANES =~ ^\[\"[a-z0-9-]+\"(,\"[a-z0-9-]+\")*\]$ ]]; then
lanes=$(jq -r 'join(", ")' <<<"$SELECT_LANES")
fi
fi
{
printf '### CI impact selection (advisory)\n\n'
printf 'Mode: %s\n\n' "$mode"
printf 'Reason category: %s\n\n' "$reason"
if [ -n "$lanes" ]; then
printf 'Selected lanes: %s\n\n' "$lanes"
fi
printf 'This PR-controlled workflow is not trusted enforcement.\n'
} >> "$GITHUB_STEP_SUMMARY"
native-images:
name: Native Container Verification
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: ./.github/workflows/container-check.yml
with:
source_sha: ${{ github.sha }}
ci_run_id: ${{ github.run_id }}
ci_attempt: ${{ github.run_attempt }}
node_base_image: ${{ vars.CONTAINER_NODE_BASE_IMAGE }}
static-checks:
name: Suite Audit and Static Checks
# Both run in every mode. Start beside CI Impact, audit the workflow and
# suite first, then reuse this checkout, Node and runner for static checks.
# The measured 3.2 GiB peak fits the 4-CPU / 15.2 GiB runner.
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Verify checkout source
run: test "$(git rev-parse --verify 'HEAD^{commit}')" = "$GITHUB_SHA"
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Set up workflow tools
run: bash scripts/ci/setup-tools.sh workflows
- name: Lint workflow definitions
run: actionlint .github/workflows/*.yml
- name: Audit suite manifest and workflows
run: node scripts/ci/run-tests.ts audit
- name: Audit the Full Integration OpenShell view
run: OCC_CI_SUITE_VIEW=full-integration node scripts/ci/run-tests.ts audit
- uses: ./.github/actions/setup-pnpm-store-cache
with:
node-version: ${{ env.NODE_VERSION }}
# The root workspace cache is saved by the test lanes.
cache-mode: restore
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Run workspace boundary check
run: pnpm check:workspace
- name: Run lint check
run: pnpm lint --concurrency 2
- name: Set up formatter
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
with:
bun-version-file: .bun-version
- name: Check formatting
run: pnpm format:check
- name: Run OpenAPI check
run: pnpm openapi:check
- name: Restore documentation dependencies
id: docs-store
uses: ./.github/actions/setup-pnpm-store-cache
with:
node-version: ${{ env.NODE_VERSION }}
package-manager-file: scripts/docs-site/package.json
lockfile-path: scripts/docs-site/pnpm-lock.yaml
cache-mode: read-write
- name: Install documentation dependencies
run: pnpm docs:install
- name: Lint the OpenAPI specification
run: pnpm openapi:lint
- name: Type-check documentation scripts
run: pnpm exec tsc --project scripts/docs-site/tsconfig.json --pretty false
- name: Check documentation length
run: pnpm docs:check-length
- name: Check specifications
run: node scripts/check-specs.mjs
- name: Build documentation
run: pnpm docs:build
- name: Save documentation dependencies
# This job owns the docs cache. The build must run Pagefind successfully
# before saving: installation can succeed without its optional binary.
if: success() && steps.docs-store.outputs.store-cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
with:
path: ${{ steps.docs-store.outputs.store-path }}
key: ${{ steps.docs-store.outputs.store-cache-primary-key }}
affected-packages:
name: Affected Packages (advisory)
needs: impact
if: ${{ github.event_name == 'pull_request' && needs.impact.outputs.mode == 'full' }}
runs-on: ubuntu-22.04
timeout-minutes: 3
continue-on-error: true
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 2
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: ./.github/actions/setup-pnpm-store-cache
with:
node-version: ${{ env.NODE_VERSION }}
cache-mode: "off"
- name: Report affected workspace packages
env:
SHADOW_WORKFLOW_SHA: ${{ github.workflow_sha }}
if: ${{ always() }}
run: |
# Print to the log too: step summaries are not readable through the API.
report=$(node scripts/ci/pnpm-impact.ts --summary "$RUNNER_TEMP/affected-lanes.json") || report='Affected workspace packages: unavailable.'
printf '%s\n' "$report"
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
printf '%s\n' "$report" >> "$GITHUB_STEP_SUMMARY" || true
fi
- name: Upload shadow lane prediction
if: ${{ always() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: affected-lanes-${{ github.run_attempt }}
path: ${{ runner.temp }}/affected-lanes.json
if-no-files-found: ignore
retention-days: 14
pr-safe:
name: ${{ matrix.title }}
needs: impact
if: ${{ (needs.impact.outputs.mode == 'full' || needs.impact.outputs.mode == 'tests') && needs.impact.outputs.has-matrix == 'true' }}
# Each CI Impact lane-table row names its runner.
runs-on: ${{ matrix.runner }}
timeout-minutes: ${{ matrix.timeout }}
strategy:
fail-fast: false
matrix:
# Lane rows live in the CI Impact "Build lane matrix" step.
include: ${{ fromJSON(needs.impact.outputs.matrix) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
# Sign-in profile tests compare real historical controller/catalog inputs.
fetch-depth: ${{ matrix.lane == 'checks-baseline-2' && '0' || '1' }}
persist-credentials: false
- uses: ./.github/actions/run-ci-lane
with:
lane: ${{ matrix.lane }}
profile: ${{ matrix.profile }}
node-version: ${{ env.NODE_VERSION }}
artifact-prefix: ci-results
job-timeout-minutes: ${{ matrix.timeout }}
# Static Checks runs them in this workflow.
static-checks: "false"
- name: Upload repository credential image identities
if: always() && matrix.lane == 'repository-credentials-container'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ci-repository-credentials-images
path: ${{ runner.temp }}/state/repository-credentials-images.json
if-no-files-found: error
retention-days: 7
runtime-artifact:
name: Shared Runtime Image
needs: impact
if: ${{ needs.impact.outputs.mode == 'full' || (needs.impact.outputs.mode == 'tests' && needs.impact.outputs.has-images == 'true') }}
uses: ./.github/workflows/ci-runtime-artifact.yml
image-lanes:
permissions:
contents: read
actions: read
name: ${{ matrix.title }}
needs: [impact, runtime-artifact]
if: ${{ (needs.impact.outputs.mode == 'full' || needs.impact.outputs.mode == 'tests') && needs.impact.outputs.has-images == 'true' }}
# Each CI Impact lane-table row names its runner.
runs-on: ${{ matrix.runner }}
timeout-minutes: ${{ matrix.timeout }}
strategy:
fail-fast: false
matrix:
# Lane rows live in the CI Impact "Build lane matrix" step.
include: ${{ fromJSON(needs.impact.outputs.image-matrix) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: ./.github/actions/run-ci-lane
with:
lane: ${{ matrix.lane }}
profile: ${{ matrix.profile }}
node-version: ${{ env.NODE_VERSION }}
artifact-prefix: ci-results
job-timeout-minutes: ${{ matrix.timeout }}
# Static Checks runs them in this workflow.
static-checks: "false"
runtime-artifact-id: ${{ needs.runtime-artifact.outputs.artifact-id }}
runtime-artifact-sha256: ${{ needs.runtime-artifact.outputs.archive-sha256 }}
runtime-artifact-source-sha: ${{ needs.runtime-artifact.outputs.source-sha }}
runtime-artifact-run-id: ${{ needs.runtime-artifact.outputs.run-id }}
runtime-artifact-attempt: ${{ needs.runtime-artifact.outputs.producer-attempt }}
runtime-image-fixture:
name: Runtime Image Fixture
needs: impact
if: ${{ needs.impact.outputs.mode == 'full' || (needs.impact.outputs.mode == 'tests' && needs.impact.outputs.fixture == 'true') }}
# GitHub-hosted jobs receive a fresh VM and the job's existing Docker engine.
# Only this lane writes fixture tags; its process awaits each Docker command.
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
# The fixture builds FROM a Docker Hub base image on the Engine's own
# builder; pull it through mirror.gcr.io without the runner's Docker Hub
# sign-in (finding 977).
- name: Pull Docker Hub images through a mirror
run: bash scripts/ci/docker-hub-mirror.sh setup
- uses: ./.github/actions/run-ci-lane
with:
lane: runtime-image-fixture
profile: postgres
node-version: ${{ env.NODE_VERSION }}
artifact-prefix: ci-results
job-timeout-minutes: 60
- name: Show Docker Hub pull endpoints
if: ${{ !cancelled() }}
run: bash scripts/ci/docker-hub-mirror.sh report
# Real Local Setup install on every PR and merge, with a stand-in model
# provider and no secrets. Deliberately not a CI Required dependency yet.
first-agent-smoke:
permissions:
contents: read
actions: read
name: First Agent Smoke
needs: [impact, runtime-artifact]
if: ${{ needs.impact.outputs.mode == 'full' }}
# Local Setup refuses gateway trust unless NetworkPolicies are enforced,
# which needs the bridge netfilter support of this runner kernel.
runs-on: ubuntu-22.04
timeout-minutes: 40
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: ${{ env.NODE_VERSION }}
# The runner starts with about 90 GB free; the smoke uses far less, so it
# skips the SDK removal the large image lanes need.
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- name: Set up CI tools
uses: ./.github/actions/setup-ci-tools
with:
profile: k3d
# Pull Docker Hub images through mirror.gcr.io without the runner's
# Docker Hub sign-in (finding 973). This restarts the Engine, so it runs
# before Buildx starts its builder container.
- name: Pull Docker Hub images through a mirror
run: bash scripts/ci/docker-hub-mirror.sh setup
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
with:
# GitHub-hosted runners are per-job VMs; removing the builder took 8-33 s,
# which a superseding run also waits for on cancellation.
cleanup: false
# The builder container pulls base images itself, not through the engine.
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Enable Kubernetes bridge packet filtering
run: |
if [[ ! -e /proc/sys/net/bridge/bridge-nf-call-iptables ]]; then
sudo modprobe br_netfilter
fi
sudo sysctl -w net.bridge.bridge-nf-call-iptables=1
- name: Build OCC CLI
run: go build -trimpath -o bin/occ ./cmd/occ
- name: Expose image cache credentials
id: image-cache
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const token = process.env.ACTIONS_RUNTIME_TOKEN;
const url = process.env.ACTIONS_RESULTS_URL;
if (!token || !url) {
throw new Error('GitHub Actions cache credentials are unavailable');
}
core.setSecret(token);
core.setOutput('token', token);
core.setOutput('url', url);
- name: Download shared runtime image
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
artifact-ids: ${{ needs.runtime-artifact.outputs.artifact-id }}
github-token: ${{ github.token }}
repository: ${{ github.repository }}
run-id: ${{ needs.runtime-artifact.outputs.run-id }}
path: ${{ runner.temp }}/runtime-artifact
merge-multiple: true
- name: Build checkout images
env:
OCC_CI_RUNTIME_ARTIFACT_DIRECTORY: ${{ runner.temp }}/runtime-artifact
OCC_CI_RUNTIME_ARTIFACT_SHA256: ${{ needs.runtime-artifact.outputs.archive-sha256 }}
OCC_CI_RUNTIME_ARTIFACT_SOURCE_SHA: ${{ needs.runtime-artifact.outputs.source-sha }}
OCC_CI_RUNTIME_ARTIFACT_RUN_ID: ${{ needs.runtime-artifact.outputs.run-id }}
OCC_CI_RUNTIME_ARTIFACT_ATTEMPT: ${{ needs.runtime-artifact.outputs.producer-attempt }}
ACTIONS_RUNTIME_TOKEN: ${{ steps.image-cache.outputs.token }}
ACTIONS_RESULTS_URL: ${{ steps.image-cache.outputs.url }}
run: node scripts/ci/first-agent-smoke.ts images
- name: Install, deploy, chat, stop and start
id: smoke
run: node scripts/ci/first-agent-smoke.ts run
- name: Verify First Agent Smoke retirement notices
if: ${{ !cancelled() && (steps.smoke.outcome == 'success' || steps.smoke.outcome == 'failure') }}
continue-on-error: true
env:
SMOKE_OUTCOME: ${{ steps.smoke.outcome }}
RETIREMENT_NOTICES: ${{ steps.smoke.outputs.retirement-notices }}
run: |
expected='["held-sockets","peer-withdrawal","old-harness-pod-termination","retired-sockets-closed","successor-deploy","selected-control-after-unselected-probe"]'
if [[ ${#RETIREMENT_NOTICES} -gt 1024 ]] ||
! jq -es --arg smoke "$SMOKE_OUTCOME" --argjson expected "$expected" '
length == 1 and (.[0] |
.rows as $rows |
keys == ["completed", "rows", "status"] and
(.rows | type == "array" and length <= ($expected | length)) and
.completed == ($rows | length) and
all($rows[]; keys == ["durationMs", "outcome", "stage"] and
(.durationMs | type == "number" and . >= 0 and . <= 9007199254740991 and . == floor) and
(.outcome == "ok" or .outcome == "failed")) and
[$rows[].stage] == $expected[:($rows | length)] and
all($rows[:-1][]; .outcome == "ok") and
(if .status == "ok" then
($rows | length) == ($expected | length) and all($rows[]; .outcome == "ok")
elif $smoke == "failure" and .status == "failed" then true
else $smoke == "failure" and .status == "unreached" and $rows == []
end))
' <<< "$RETIREMENT_NOTICES" >/dev/null 2>&1; then
echo "::warning title=First Agent Smoke retirement notices::Retirement notice sequence or outcome is incomplete or invalid"
exit 1
fi
- name: Show Docker Hub pull endpoints
if: ${{ !cancelled() }}
run: bash scripts/ci/docker-hub-mirror.sh report
- name: Upload First Agent Smoke timings
if: ${{ !cancelled() && (steps.smoke.outcome == 'success' || steps.smoke.outcome == 'failure') }}
continue-on-error: true
timeout-minutes: 1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: first-agent-smoke-timing-v2-${{ github.run_attempt }}
path: ${{ runner.temp }}/first-agent-smoke-timing-v2.json
if-no-files-found: ignore
retention-days: 7
ci-required:
name: CI Required
runs-on: ubuntu-22.04
needs:
- impact
- static-checks
- pr-safe
- image-lanes
- runtime-artifact
- runtime-image-fixture
# always(): a failed or skipped dependency must still produce a failed
# CI Required, never a skipped (passing) one.
if: always()
steps:
# A PR push that supersedes this run waits until this run has finished
# cancelling. cancelled() is false in a job that starts after the
# cancellation, so test the dependencies: fail at once instead of checking
# out and verifying jobs that never finished. Later steps then skip.
- name: Fail when a required job was cancelled
if: contains(needs.*.result, 'cancelled')
env:
NEEDS_JSON: ${{ toJson(needs) }}
run: |
jq -r 'to_entries[] | select(.value.result == "cancelled") | "::error::\(.key) was cancelled (superseded run, manual cancel, or timeout-minutes exceeded; see that job)."' <<<"$NEEDS_JSON"
exit 1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 2
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: ${{ env.GATE_NODE_VERSION }}
- name: Verify selected mode
env:
IMPACT_ACTION: verify
EXPECTED_MODE: ${{ needs.impact.outputs.mode }}
EXPECTED_LANES: ${{ needs.impact.outputs.lanes }}
run: |
# The workflow itself is PR-controlled; independent required-workflow
# enforcement is needed to protect this bootstrap from workflow edits.
policy=$(mktemp "$RUNNER_TEMP/ci-impact-policy.XXXXXX.ts")
trap 'rm -f "$policy"' EXIT
trusted_policy() {
reason=bootstrap_non_pr_event
if [ "${GITHUB_EVENT_NAME:-}" = push ]; then
[ "${GITHUB_REPOSITORY:-}" = openclaw/openclaw-enterprise ] && [ "${GITHUB_REF:-}" = refs/heads/main ] || return 1
reason=bootstrap_event_unavailable
base=$(jq -er '.before | select(type == "string")' "$GITHUB_EVENT_PATH") || return 1
head=$(jq -er '.after | select(type == "string")' "$GITHUB_EVENT_PATH") || return 1
else
[ "${GITHUB_EVENT_NAME:-}" = pull_request ] || return 1
reason=bootstrap_event_unavailable
base=$(jq -er '.pull_request.base.sha | select(type == "string")' "$GITHUB_EVENT_PATH") || return 1
head=$(jq -er '.pull_request.head.sha | select(type == "string")' "$GITHUB_EVENT_PATH") || return 1
fi
reason=bootstrap_invalid_identity
oid='^([0-9a-f]{40}|[0-9a-f]{64})$'
[[ $base =~ $oid && $head =~ $oid && ${GITHUB_SHA:-} =~ $oid ]] || return 1
reason=bootstrap_git_inspection_failed
actual=$(git rev-parse --verify 'HEAD^{commit}') || return 1
reason=bootstrap_checkout_mismatch
[ "$actual" = "$GITHUB_SHA" ] || return 1
reason=bootstrap_git_inspection_failed
if [ "${GITHUB_EVENT_NAME:-}" = push ]; then
reason=bootstrap_checkout_mismatch
[ "$head" = "$GITHUB_SHA" ] || return 1
git cat-file -e "$base^{commit}" && git merge-base --is-ancestor "$base" "$head" || return 1
merge_base=$base
else
parents=$(git show -s --format=%P "$GITHUB_SHA") || return 1
reason=bootstrap_checkout_mismatch
[[ $parents =~ ^([0-9a-f]{40}|[0-9a-f]{64})\ ([0-9a-f]{40}|[0-9a-f]{64})$ ]] || return 1
[ "${BASH_REMATCH[2]}" = "$head" ] || return 1
merge_base=${BASH_REMATCH[1]}
reason=bootstrap_git_inspection_failed
git cat-file -e "$merge_base^{commit}" && git cat-file -e "$head^{commit}" || return 1
# GitHub merges onto the base tip at merge time; base.sha lags it
# when the base moved after the push and is then not fetched.
reason=bootstrap_checkout_mismatch
if [ "$base" != "$merge_base" ] && git cat-file -e "$base^{commit}" 2>/dev/null; then
git merge-base --is-ancestor "$base" "$merge_base" || return 1
fi
fi
reason=bootstrap_git_inspection_failed
entry=$(git ls-tree "$merge_base" -- scripts/ci/impact.ts) || return 1
reason=bootstrap_policy_unavailable
[[ $entry =~ ^100644\ blob\ ([0-9a-f]{40}|[0-9a-f]{64})[[:space:]]scripts/ci/impact\.ts$ ]] || return 1
reason=bootstrap_git_inspection_failed
git cat-file blob "${BASH_REMATCH[1]}" > "$policy" || return 1
reason=bootstrap_policy_unavailable
[ -s "$policy" ]
}
if trusted_policy; then
if [ "$IMPACT_ACTION" = select ]; then
node "$policy" --github-output "$GITHUB_OUTPUT"
elif [ "$EXPECTED_MODE" = tests ]; then
node "$policy" --verify-mode tests --lanes "$EXPECTED_LANES"
else
node "$policy" --verify-mode "$EXPECTED_MODE"
fi
elif [ "$IMPACT_ACTION" = select ]; then
printf 'CI impact: full (trusted base policy unavailable)\n'
printf 'mode=full\nreason=%s\n' "$reason" >> "$GITHUB_OUTPUT"
else
[ "$EXPECTED_MODE" = full ] || exit 1
printf 'CI impact: full (trusted base policy unavailable)\n'
fi
- name: Validate selected job state
if: ${{ !cancelled() && !contains(needs.*.result, 'cancelled') }}
env:
NEEDS_JSON: ${{ toJson(needs) }}
EXPECTED_MODE: ${{ needs.impact.outputs.mode }}
EXPECTED_LANES: ${{ needs.impact.outputs.lanes }}
run: |
printf '%s' "$NEEDS_JSON" > "$RUNNER_TEMP/raw-needs.json"
if [ "$EXPECTED_MODE" = tests ]; then
node scripts/ci/impact-gate.ts --needs "$RUNNER_TEMP/raw-needs.json" --mode tests --output "$RUNNER_TEMP/needs.json" --lanes "$EXPECTED_LANES"
else
node scripts/ci/impact-gate.ts --needs "$RUNNER_TEMP/raw-needs.json" --mode "$EXPECTED_MODE" --output "$RUNNER_TEMP/needs.json"
fi
# The action retries after a pause and says why.
- name: Download CI results
uses: ./.github/actions/download-results
if: ${{ !cancelled() && !contains(needs.*.result, 'cancelled') && (needs.impact.outputs.mode == 'full' || needs.impact.outputs.mode == 'tests') }}
with:
pattern: ci-results-*
path: ${{ runner.temp }}/results
- name: Aggregate CI results
if: ${{ !cancelled() && !contains(needs.*.result, 'cancelled') && (needs.impact.outputs.mode == 'full' || needs.impact.outputs.mode == 'tests') }}
env:
EXPECTED_MODE: ${{ needs.impact.outputs.mode }}
EXPECTED_LANES: ${{ needs.impact.outputs.lanes }}
run: |
if [ "$EXPECTED_MODE" = tests ]; then
node scripts/ci/run-tests.ts aggregate ci --results-dir "$RUNNER_TEMP/results" --needs "$RUNNER_TEMP/needs.json" --lanes "$EXPECTED_LANES"
else
node scripts/ci/run-tests.ts aggregate ci --results-dir "$RUNNER_TEMP/results" --needs "$RUNNER_TEMP/needs.json"
fi