Skip to content

Commit 4ee565c

Browse files
authored
perf(ci): remove repeated setup and balance complete test workloads (#134038)
* perf(ci): reduce Windows test setup and worker time * perf(anthropic): defer auth loading until hook execution * perf(test): narrow selected config startup work * fix(ci): bound compiler memory on constrained lint runners * test(ci): prepare media fixture input capabilities * perf(test): scope selected unit configuration discovery * fix(ci): release cancelled runs and route hybrid control jobs * fix(ci): resolve merge bases before Testbox preparation * fix(ci): align gateway recovery validation with runtime contracts * perf(ci): avoid rename blob fetches during docs classification * test(ci): consolidate Testbox base preparation coverage * perf(ci): account for tooling work and shared build prerequisites * fix(ci): declare serial plugin config worker ownership * perf(ci): overlap independent performance Git lifecycle fixtures * perf(ci): partition the complete plugin catch-all with native sharding * perf(ci): reuse compiled session workers * perf(test): compare complete SQLite snapshots natively * test(ci): reuse race-safe process cleanup in report fixtures * fix(ci): preserve the trusted PR helper closure * test(ci): derive PR fixtures from the trusted helper closure * perf(ci): reuse matching checkout for harness actions * fix(ci): replace retained harness files during index export * perf(ci): restore exact caches on hybrid runners * fix(ci): include pnpm metadata in dependency archives * test(ci): own direct compiler checkpoints in dist fixtures * perf(ci): balance Windows projects by selected test costs * perf(ci): seed UI transforms and scope tooling prerequisites Keep package timeout observations joined across PID discovery, and test planner measurements against stable fixtures while preserving actual runtime-build singleton costs. * docs(ci): drop the note for the already-landed Telegram type fix * perf(ci): reuse preflight checkout and route hybrid macOS * test(ci): wait for command readiness before timeout proof
1 parent 18087cf commit 4ee565c

74 files changed

Lines changed: 2983 additions & 1284 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/openclaw-ci-limits/SKILL.md‎

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,33 @@ These are intentionally guarded by `test/scripts/ci-workflow-guards.test.ts`:
173173

174174
- `CI` concurrency key version, PR cancellation, and canonical `main`'s two
175175
non-canceling parity slots, each with one coalesced pending tip.
176-
- `preflight` and hosted `security-fast` start immediately without a debounce
177-
or standalone admission job. On Node-relevant canonical main pushes and
178-
same-repo pull requests, preflight owns the sole immutable semantic
179-
dependency-cache write of workspace `node_modules` plus the local pnpm store
180-
before fanout; all Blacksmith Node jobs are restore-only consumers and exact
181-
misses fall back to the ordinary pnpm-store cache, while hosted/fork/manual
182-
paths use only that store cache.
176+
- `preflight` and `security-fast` start immediately without a debounce
177+
or standalone admission job. The protected `vitest-cache-warm` workflow
178+
publishes the immutable semantic dependency archive after setup succeeds,
179+
before build and transform warming. Preflight and downstream Node jobs are
180+
restore-only consumers on eligible self-hosted runners; exact misses and
181+
hosted/fork/manual paths use the ordinary pnpm-store cache.
182+
- Hybrid first attempts route `preflight`, `security-fast`, and `ci-gate` to
183+
the existing 4-vCPU Blacksmith runner after measured hosted queue delays.
184+
Contributor trust, manual/non-canonical fallbacks, hosted retries, and the
185+
`github` outage override remain intact. Budget all three registrations.
186+
The aggregate uses `!cancelled()` to report failed prerequisites without
187+
holding a superseded run open after workflow cancellation.
183188
- CI matrix caps: fast/check lanes at 12, Node test shards at 28 on Blacksmith
184-
and 96 with the GitHub or hybrid planner profile, Windows at 3, and Android
185-
at 2.
189+
and 96 with the GitHub or hybrid planner profile, Windows at 2, and Android
190+
at 2. The compact row budgets are 112 for hosted-only GitHub and 96 for
191+
hybrid; the higher hosted row budget does not increase concurrency.
192+
- Windows keeps two disjoint file inventories. Jobs requesting the existing
193+
Blacksmith class admit at most two project processes with one Vitest worker
194+
each; hosted fallbacks remain serial. Runtime preparation completes before
195+
project readers start. Native proof must cover available CPUs/RAM, concurrent
196+
fixture memory and cleanup. This adds no runner registrations.
186197
- Canonical PR Node tests use one precise changed-target job when possible;
187198
broad, deleted, unknown, or planner-failed changes fall back to the compact
188199
full-suite plan. Targeted plans retain the full built-artifact
189-
boundary gate. `main`, manual, and release runs stay full.
190-
- `build-artifacts` on `blacksmith-16vcpu-ubuntu-2404`.
200+
boundary gate. `main` uses compact integration; manual and release runs use
201+
full named shards.
202+
- `build-artifacts` on `blacksmith-32vcpu-ubuntu-2404`.
191203
- lower-weight Node/check shards on `blacksmith-4vcpu-ubuntu-2404`.
192204
- heavy retained Linux/Android shards on `blacksmith-8vcpu-ubuntu-2404`.
193205
- CodeQL Critical Quality on `ubuntu-24.04` with no `blacksmith-` labels.

‎.github/actions/detect-docs-changes/action.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ runs:
2828
run: |
2929
BASE="$BASE_SHA"
3030

31-
# Fail-safe: if we can't diff, assume non-docs (run everything)
32-
CHANGED=$(git diff --name-only "$BASE" HEAD 2>/dev/null || echo "UNKNOWN")
31+
# Keep both rename paths without fetching parent blobs; a failed diff runs everything.
32+
CHANGED=$(git diff --no-renames --name-only "$BASE" HEAD 2>/dev/null || echo "UNKNOWN")
3333
if [ "$CHANGED" = "UNKNOWN" ] || [ -z "$CHANGED" ]; then
3434
echo "docs_only=false" >> "$GITHUB_OUTPUT"
3535
echo "docs_changed=false" >> "$GITHUB_OUTPUT"

‎.github/actions/git-owner/owner.py‎

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,36 @@ def fetch_ref(value):
361361
run_git(workspace, "checkout", "--detach", "refs/remotes/origin/checkout")
362362

363363

364+
def checkout_harness(sha):
365+
action = ".github/actions/setup-node-env/action.yml"
366+
if kind == "linux-node" and not os.path.isfile(os.path.join(workspace, action)):
367+
raise GitFailure(1)
368+
harness = os.path.join(workspace, ".ci-harness")
369+
os.makedirs(harness, exist_ok=True)
370+
if sha == os.environ["WORKFLOW_SHA"]:
371+
# Export the workflow revision from the freshly populated index, replacing
372+
# retained platform files without updating the index or trusting later edits.
373+
paths = git_output(workspace, "ls-files", "-z", "--", ".github/actions").split("\0")[:-1]
374+
run_git(workspace, "checkout-index", "--force", f"--prefix={harness}/", "--", *paths)
375+
else:
376+
run_git(harness, "init", harness)
377+
run_git(harness, "remote", "add", "origin", remote)
378+
# The harness only supplies .github/actions, so narrow the fetch before it runs:
379+
# sparse first, then blob-less. A full snapshot here downloads a second copy of
380+
# the repository that the checkout below immediately discards, and every extra
381+
# byte is amplified by the shared runner egress.
382+
run_git(harness, "sparse-checkout", "set", ".github/actions")
383+
fetch(harness, f"+{os.environ['WORKFLOW_SHA']}:refs/remotes/origin/ci-harness",
384+
max_attempts=1, blobless=True)
385+
# Checkout now materializes the sparse blobs over the network, so it carries the
386+
# fetch deadline instead of running unbounded like a local checkout.
387+
run_git(harness, "checkout", "--force", "--detach", os.environ["WORKFLOW_SHA"],
388+
timeout=fetch_timeout_seconds)
389+
if not os.path.isfile(os.path.join(harness, action)):
390+
raise GitFailure(1)
391+
check_cancelled()
392+
393+
364394
def checkout():
365395
check_cancelled()
366396
prerequisites = json.loads(os.environ.get("CHECKOUT_GIT_COMMITS_JSON", "null")) if kind == "linux-node" else None
@@ -383,6 +413,8 @@ def checkout():
383413
run_git(workspace, "remote", "add", "origin", remote)
384414
if kind in ("preflight", "manual"):
385415
checkout_selected_ref()
416+
if kind == "preflight" and resolve_ref("HEAD") == os.environ["WORKFLOW_SHA"]:
417+
checkout_harness(os.environ["WORKFLOW_SHA"])
386418
return
387419
target = "refs/remotes/origin/ci-target" if kind in ("linux-node", "android") else "refs/remotes/origin/checkout"
388420
sha = "refs/heads/main" if kind == "clawhub" else os.environ["CHECKOUT_SHA"]
@@ -403,27 +435,7 @@ def checkout():
403435
return
404436
if kind in ("clawhub", "skills"):
405437
return
406-
action = ".github/actions/setup-node-env/action.yml"
407-
if kind == "linux-node" and not os.path.isfile(os.path.join(workspace, action)):
408-
raise GitFailure(1)
409-
harness = os.path.join(workspace, ".ci-harness")
410-
os.makedirs(harness, exist_ok=True)
411-
run_git(harness, "init", harness)
412-
run_git(harness, "remote", "add", "origin", remote)
413-
# The harness only supplies .github/actions, so narrow the fetch before it runs:
414-
# sparse first, then blob-less. A full snapshot here downloads a second copy of
415-
# the repository that the checkout below immediately discards, and every extra
416-
# byte is amplified by the shared runner egress.
417-
run_git(harness, "sparse-checkout", "set", ".github/actions")
418-
fetch(harness, f"+{os.environ['WORKFLOW_SHA']}:refs/remotes/origin/ci-harness",
419-
max_attempts=1, blobless=True)
420-
# Checkout now materializes the sparse blobs over the network, so it carries the
421-
# fetch deadline instead of running unbounded like a local checkout.
422-
run_git(harness, "checkout", "--force", "--detach", os.environ["WORKFLOW_SHA"],
423-
timeout=fetch_timeout_seconds)
424-
if not os.path.isfile(os.path.join(harness, action)):
425-
raise GitFailure(1)
426-
check_cancelled()
438+
checkout_harness(sha)
427439

428440

429441
def main():

‎.github/actions/prepare-testbox-shell/action.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Pin the checked-out base ref and expose the setup-node toolchain to
33

44
inputs:
55
base-ref:
6-
description: Commit or ref that Testbox should treat as origin/main; defaults to HEAD.
6+
description: Event base for pull requests, or ref to treat as origin/main for manual runs; defaults to HEAD.
77
required: false
88

99
runs:
@@ -17,6 +17,14 @@ runs:
1717
set -euo pipefail
1818

1919
base_ref="${TESTBOX_BASE_REF:-HEAD}"
20+
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
21+
# The checked-out merge can have a newer base than the event payload.
22+
base_ref="$(node scripts/lib/merge-head-diff-base.mjs \
23+
--base "$base_ref" --head HEAD --prefer-first-parent)"
24+
BASE_SHA="$base_ref" FETCH_REF="$GITHUB_BASE_REF" \
25+
python3 -I -S "$GITHUB_ACTION_PATH/../git-owner/owner.py" \
26+
--policy "$GITHUB_ACTION_PATH/../ensure-base-commit/policy.py"
27+
fi
2028
if ! base_sha="$(git rev-parse --verify "${base_ref}^{commit}")"; then
2129
echo "Testbox base commit is missing from the maintained checkout: $base_ref" >&2
2230
exit 1

‎.github/actions/setup-node-env/action.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ runs:
171171
set -euo pipefail
172172
# Keep both sides of pnpm's hard links below the workspace so one tar
173173
# archive preserves them without relying on runner-home path depth.
174+
# Pnpm also needs registry metadata for offline supply-chain checks.
174175
echo "PNPM_CONFIG_STORE_DIR=$GITHUB_WORKSPACE/.cache/openclaw-pnpm-store" >> "$GITHUB_ENV"
176+
echo "PNPM_CONFIG_CACHE_DIR=$GITHUB_WORKSPACE/.cache/openclaw-pnpm-store/cache" >> "$GITHUB_ENV"
175177

176178
- name: Resolve dependency cache key
177179
id: dependency-cache-key
@@ -183,7 +185,7 @@ runs:
183185
set -euo pipefail
184186
deps_input_fingerprint="$(node "$GITHUB_ACTION_PATH/dependency-fingerprint.mjs" \
185187
--workspace "$GITHUB_WORKSPACE" --frozen-lockfile "$FROZEN_LOCKFILE")"
186-
cache_key="${GITHUB_REPOSITORY:?}-node-deps-v2-os-${RUNNER_OS:?}-arch-${RUNNER_ARCH:?}-node-$(node --version)-${deps_input_fingerprint:?}"
188+
cache_key="${GITHUB_REPOSITORY:?}-node-deps-v3-os-${RUNNER_OS:?}-arch-${RUNNER_ARCH:?}-node-$(node --version)-${deps_input_fingerprint:?}"
187189
echo "key=$cache_key" >> "$GITHUB_OUTPUT"
188190

189191
- name: Prepare dependency cache restore
@@ -391,6 +393,7 @@ runs:
391393
install_args+=("--config.${option_name}=${value}")
392394
fi
393395
}
396+
append_pnpm_option_arg PNPM_CONFIG_CACHE_DIR cache-dir
394397
append_pnpm_option_arg PNPM_CONFIG_CHILD_CONCURRENCY child-concurrency
395398
append_pnpm_option_arg PNPM_CONFIG_MODULES_DIR modules-dir
396399
append_pnpm_option_arg PNPM_CONFIG_NETWORK_CONCURRENCY network-concurrency

‎.github/workflows/ci-build-artifacts-testbox.yml‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,10 @@ jobs:
155155
packages/*/dist/
156156
key: ${{ runner.os }}-dist-build-v2-${{ github.sha }}
157157

158-
- name: Resolve PR Testbox base
159-
if: github.event_name == 'pull_request'
160-
id: testbox-base
161-
shell: bash
162-
env:
163-
BASE_SHA: ${{ github.event.pull_request.base.sha }}
164-
run: |
165-
# The shallow merge checkout already contains its actual base parent.
166-
base="$(node scripts/lib/merge-head-diff-base.mjs --base "$BASE_SHA" --head HEAD --prefer-first-parent)"
167-
echo "sha=$base" >> "$GITHUB_OUTPUT"
168-
- name: Ensure Testbox base commit
169-
if: github.event_name == 'pull_request'
170-
uses: ./.github/actions/ensure-base-commit
171-
with:
172-
base-sha: ${{ steps.testbox-base.outputs.sha }}
173-
fetch-ref: ${{ github.event.pull_request.base.ref }}
174158
- name: Prepare Testbox shell
175159
uses: ./.github/actions/prepare-testbox-shell
176160
with:
177-
base-ref: ${{ steps.testbox-base.outputs.sha || 'refs/remotes/origin/main' }}
161+
base-ref: ${{ github.event.pull_request.base.sha || 'refs/remotes/origin/main' }}
178162

179163
- name: Hydrate Testbox provider env helper
180164
shell: bash

‎.github/workflows/ci-check-arm-testbox.yml‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,10 @@ jobs:
6262
cache-mode: restore
6363
install-bun: "false"
6464
install-trufflehog: "true"
65-
- name: Resolve PR Testbox base
66-
if: github.event_name == 'pull_request'
67-
id: testbox-base
68-
shell: bash
69-
env:
70-
BASE_SHA: ${{ github.event.pull_request.base.sha }}
71-
run: |
72-
# The shallow merge checkout already contains its actual base parent.
73-
base="$(node scripts/lib/merge-head-diff-base.mjs --base "$BASE_SHA" --head HEAD --prefer-first-parent)"
74-
echo "sha=$base" >> "$GITHUB_OUTPUT"
75-
- name: Ensure Testbox base commit
76-
if: github.event_name == 'pull_request'
77-
uses: ./.github/actions/ensure-base-commit
78-
with:
79-
base-sha: ${{ steps.testbox-base.outputs.sha }}
80-
fetch-ref: ${{ github.event.pull_request.base.ref }}
8165
- name: Prepare Testbox shell
8266
uses: ./.github/actions/prepare-testbox-shell
8367
with:
84-
base-ref: ${{ steps.testbox-base.outputs.sha || 'refs/remotes/origin/main' }}
68+
base-ref: ${{ github.event.pull_request.base.sha || 'refs/remotes/origin/main' }}
8569

8670
- name: Hydrate Testbox provider env helper
8771
shell: bash

‎.github/workflows/ci-check-testbox.yml‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,10 @@ jobs:
5757
install-trufflehog: "true"
5858
# Testbox hydration uses the ordinary pnpm store cache. Canonical CI
5959
# owns the exact dependency archive and never delegates here.
60-
- name: Resolve PR Testbox base
61-
if: github.event_name == 'pull_request'
62-
id: testbox-base
63-
shell: bash
64-
env:
65-
BASE_SHA: ${{ github.event.pull_request.base.sha }}
66-
run: |
67-
# The shallow merge checkout already contains its actual base parent.
68-
base="$(node scripts/lib/merge-head-diff-base.mjs --base "$BASE_SHA" --head HEAD --prefer-first-parent)"
69-
echo "sha=$base" >> "$GITHUB_OUTPUT"
70-
- name: Ensure Testbox base commit
71-
if: github.event_name == 'pull_request'
72-
uses: ./.github/actions/ensure-base-commit
73-
with:
74-
base-sha: ${{ steps.testbox-base.outputs.sha }}
75-
fetch-ref: ${{ github.event.pull_request.base.ref }}
7660
- name: Prepare Testbox shell
7761
uses: ./.github/actions/prepare-testbox-shell
7862
with:
79-
base-ref: ${{ steps.testbox-base.outputs.sha || 'HEAD' }}
63+
base-ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || 'HEAD' }}
8064

8165
- name: Hydrate Testbox provider env helper
8266
shell: bash

0 commit comments

Comments
 (0)