Skip to content

Commit bba5730

Browse files
committed
perf(ci): fold built-runtime verifiers into the artifact-check wave
build-artifacts is the wall's pole in 4 of the last 5 main runs (171-186s, ~15-20s ahead of the next lane), so its serial steps are the wall. The Doctor plugin-index proof, singleton smoke, and startup-memory check ran as their own 13s step even though they are independent dist readers that the 47s artifact-check wave could absorb. They now run inside that wave: on Blacksmith all seven start together, so the verifiers cost the wave's max instead of 13s of serial time; hosted runners still serialize the three through run_verifier so the RSS ceiling measures an unloaded process. The step drops its selection gate because the verifiers always run -- each artifact check already self-gates on its own RUN_* flag, so a run with no checks selected still verifies. Proof: extracted the step body and ran it with stubbed pnpm/node. Both modes behave (Blacksmith 7 checks started, hosted-with-nothing-selected still runs the 3 verifiers), and a failing verifier exits 1 with its ::error annotation in both -- the wave cannot swallow it.
1 parent dbad5e3 commit bba5730

3 files changed

Lines changed: 84 additions & 76 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 59 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,78 +1340,18 @@ jobs:
13401340
# independent dist readers; Blacksmith runners have the cores to overlap
13411341
# them, while hosted 4-core runners keep the serial order so the RSS
13421342
# measurement stays unperturbed under its higher hosted ceiling.
1343-
- name: Verify built runtime artifacts
1344-
shell: bash
1343+
# Built-artifact verifiers and checks share one wave: the verifiers are
1344+
# independent dist readers, so overlapping them with the selected checks
1345+
# keeps them off this job's serial critical path. The step is
1346+
# unconditional because the verifiers always run; each check self-gates.
1347+
- name: Run built artifact checks
1348+
id: built_artifact_checks
13451349
env:
1350+
PARALLEL_GATEWAY_WATCH: ${{ runner.environment != 'github-hosted' && 'true' || 'false' }}
13461351
PARALLEL_BUILT_VERIFIERS: ${{ runner.environment != 'github-hosted' && 'true' || 'false' }}
13471352
# GitHub-hosted Linux reports a higher RSS baseline than Blacksmith for
13481353
# the same built CLI. Keep the tighter Blacksmith regression ceiling.
13491354
OPENCLAW_STARTUP_MEMORY_PLUGINS_LIST_MB: ${{ runner.environment == 'github-hosted' && '425' || '400' }}
1350-
run: |
1351-
set -uo pipefail
1352-
1353-
run_doctor_plugin_index() {
1354-
if [[ -f test/scripts/doctor-config-preflight-plugin-index.built-cli.e2e.test.ts ]]; then
1355-
# Cold hosted runners can spend over five minutes in E2E setup before
1356-
# this proof's own bounded test can report a result.
1357-
env OPENCLAW_E2E_USE_PREBUILT_DIST=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=660000 node scripts/run-vitest.mjs run \
1358-
--config test/vitest/vitest.e2e.config.ts \
1359-
test/scripts/doctor-config-preflight-plugin-index.built-cli.e2e.test.ts
1360-
else
1361-
echo "Selected target predates the built Doctor plugin index persistence proof."
1362-
fi
1363-
}
1364-
1365-
status=0
1366-
if [[ "$PARALLEL_BUILT_VERIFIERS" == "true" ]]; then
1367-
# A missing startup asset rebuild must finish before forking so the
1368-
# concurrent verifiers never read dist mid-write.
1369-
node --import tsx scripts/ensure-cli-startup-build.mts || status=1
1370-
log_dir=.artifacts/built-verifiers
1371-
mkdir -p "$log_dir"
1372-
run_doctor_plugin_index >"$log_dir/doctor-plugin-index.log" 2>&1 &
1373-
doctor_pid=$!
1374-
pnpm test:build:singleton >"$log_dir/plugin-singleton.log" 2>&1 &
1375-
singleton_pid=$!
1376-
node scripts/check-cli-startup-memory.mjs >"$log_dir/startup-memory.log" 2>&1 &
1377-
memory_pid=$!
1378-
for entry in \
1379-
"doctor-plugin-index:$doctor_pid" \
1380-
"plugin-singleton:$singleton_pid" \
1381-
"startup-memory:$memory_pid"; do
1382-
name="${entry%%:*}"
1383-
pid="${entry##*:}"
1384-
if ! wait "$pid"; then
1385-
status=1
1386-
echo "::error::built runtime verifier failed: $name"
1387-
fi
1388-
echo "== $name =="
1389-
cat "$log_dir/$name.log"
1390-
done
1391-
else
1392-
run_doctor_plugin_index || status=1
1393-
pnpm test:build:singleton || status=1
1394-
pnpm test:startup:memory || status=1
1395-
fi
1396-
if [[ -f .artifacts/startup-memory/summary.md ]]; then
1397-
cat .artifacts/startup-memory/summary.md >> "$GITHUB_STEP_SUMMARY"
1398-
fi
1399-
exit "$status"
1400-
1401-
- name: Upload startup memory report
1402-
if: always()
1403-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
1404-
with:
1405-
name: startup-memory
1406-
path: .artifacts/startup-memory/
1407-
if-no-files-found: ignore
1408-
retention-days: 7
1409-
1410-
- name: Run built artifact checks
1411-
id: built_artifact_checks
1412-
if: needs.preflight.outputs.run_checks == 'true' || needs.preflight.outputs.run_checks_node_core_dist == 'true' || needs.preflight.outputs.run_check_additional == 'true'
1413-
env:
1414-
PARALLEL_GATEWAY_WATCH: ${{ runner.environment != 'github-hosted' && 'true' || 'false' }}
14151355
RUN_CHANNELS: ${{ needs.preflight.outputs.run_checks }}
14161356
RUN_CORE_SUPPORT_BOUNDARY: ${{ needs.preflight.outputs.run_checks_node_core_dist }}
14171357
RUN_GATEWAY_WATCH: ${{ needs.preflight.outputs.run_check_additional }}
@@ -1426,7 +1366,10 @@ jobs:
14261366
declare -A results=(
14271367
["channels"]="skipped"
14281368
["core-support-boundary"]="skipped"
1369+
["doctor-plugin-index"]="skipped"
14291370
["gateway-watch"]="skipped"
1371+
["plugin-singleton"]="skipped"
1372+
["startup-memory"]="skipped"
14301373
["tui-pty"]="skipped"
14311374
)
14321375
@@ -1464,6 +1407,37 @@ jobs:
14641407
logs=()
14651408
}
14661409
1410+
run_doctor_plugin_index() {
1411+
if [[ -f test/scripts/doctor-config-preflight-plugin-index.built-cli.e2e.test.ts ]]; then
1412+
# Cold hosted runners can spend over five minutes in E2E setup before
1413+
# this proof's own bounded test can report a result.
1414+
env OPENCLAW_E2E_USE_PREBUILT_DIST=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=660000 node scripts/run-vitest.mjs run \
1415+
--config test/vitest/vitest.e2e.config.ts \
1416+
test/scripts/doctor-config-preflight-plugin-index.built-cli.e2e.test.ts
1417+
else
1418+
echo "Selected target predates the built Doctor plugin index persistence proof."
1419+
fi
1420+
}
1421+
1422+
# A missing startup asset rebuild must finish before any verifier forks
1423+
# so concurrent readers never observe dist mid-write.
1424+
startup_assets=success
1425+
node --import tsx scripts/ensure-cli-startup-build.mts || startup_assets=failure
1426+
1427+
# Hosted runners keep the verifiers serial: a concurrent verifier
1428+
# perturbs the RSS the startup-memory ceiling measures. Blacksmith
1429+
# leaves them running so they finish inside the checks wave below.
1430+
run_verifier() {
1431+
local name="$1"
1432+
shift
1433+
start_check "$name" "$@"
1434+
[ "$PARALLEL_BUILT_VERIFIERS" = "true" ] || wait_checks
1435+
}
1436+
1437+
run_verifier "doctor-plugin-index" run_doctor_plugin_index
1438+
run_verifier "plugin-singleton" pnpm test:build:singleton
1439+
run_verifier "startup-memory" node scripts/check-cli-startup-memory.mjs
1440+
14671441
if [ "$RUN_CHANNELS" = "true" ]; then
14681442
start_check "channels" env \
14691443
NODE_OPTIONS=--max-old-space-size=8192 \
@@ -1508,19 +1482,36 @@ jobs:
15081482
wait_checks
15091483
fi
15101484
1485+
if [[ -f .artifacts/startup-memory/summary.md ]]; then
1486+
cat .artifacts/startup-memory/summary.md >> "$GITHUB_STEP_SUMMARY"
1487+
fi
1488+
15111489
for name in channels core-support-boundary gateway-watch tui-pty; do
15121490
echo "${name}-result=${results[$name]}" >> "$GITHUB_OUTPUT"
15131491
done
15141492
15151493
failures=0
1516-
for name in channels core-support-boundary gateway-watch tui-pty; do
1494+
if [ "$startup_assets" = "failure" ]; then
1495+
echo "::error title=startup assets failed::cli startup asset build failed"
1496+
failures=1
1497+
fi
1498+
for name in channels core-support-boundary doctor-plugin-index gateway-watch plugin-singleton startup-memory tui-pty; do
15171499
if [ "${results[$name]}" = "failure" ]; then
15181500
echo "::error title=${name} failed::${name} failed"
15191501
failures=1
15201502
fi
15211503
done
15221504
exit "$failures"
15231505
1506+
- name: Upload startup memory report
1507+
if: always()
1508+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
1509+
with:
1510+
name: startup-memory
1511+
path: .artifacts/startup-memory/
1512+
if-no-files-found: ignore
1513+
retention-days: 7
1514+
15241515
- name: Save dist build cache
15251516
if: steps.dist_build_cache.outputs.cache-hit != 'true'
15261517
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5

‎docs/ci.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ that unchanged head during the freshness window.
7676

7777
The default-branch ruleset requires the GitHub Actions-owned `openclaw/ci-gate` check. Repository maintainers and admins have an audited break-glass bypass intended only for signed direct fast-forward landings; the organization ruleset still blocks deletion and non-fast-forward updates. Normal pull-request merges should continue to use the gate rather than bypass failed CI. The separate strict App-owned test-merge check still binds the head to current `main`.
7878

79-
GitHub may mark superseded pull-request jobs as `cancelled` when a newer head lands. Treat that as CI noise unless the newest run for the same PR is also failing. Canonical `main` runs are not canceled after admission; each of the two parity slots replaces only its older pending run with the newest tip. Matrix jobs use `fail-fast: false`, and `build-artifacts` reports embedded channel, core-support-boundary, and gateway-watch failures directly instead of queuing tiny verifier jobs. The canonical-main CI concurrency key is versioned (`CI-v8-*`) so GitHub-side zombies in the old group cannot block the two-slot pipeline; other automatic groups remain on `CI-v7-*`. Manual full-suite runs use `CI-manual-v1-*` and do not cancel in-progress runs. The plugin-list startup-memory guard keeps a 400 MiB ceiling on self-hosted Blacksmith Linux and allows 425 MiB on GitHub-hosted Linux, whose RSS baseline is higher for the same built CLI. Blacksmith runs overlap the Doctor plugin-index proof, singleton smoke, and startup-memory check in one step; hosted 4-core runners keep them serial so the RSS measurement stays unperturbed.
79+
GitHub may mark superseded pull-request jobs as `cancelled` when a newer head lands. Treat that as CI noise unless the newest run for the same PR is also failing. Canonical `main` runs are not canceled after admission; each of the two parity slots replaces only its older pending run with the newest tip. Matrix jobs use `fail-fast: false`, and `build-artifacts` reports embedded channel, core-support-boundary, and gateway-watch failures directly instead of queuing tiny verifier jobs. The canonical-main CI concurrency key is versioned (`CI-v8-*`) so GitHub-side zombies in the old group cannot block the two-slot pipeline; other automatic groups remain on `CI-v7-*`. Manual full-suite runs use `CI-manual-v1-*` and do not cancel in-progress runs. The plugin-list startup-memory guard keeps a 400 MiB ceiling on self-hosted Blacksmith Linux and allows 425 MiB on GitHub-hosted Linux, whose RSS baseline is higher for the same built CLI. The Doctor plugin-index proof, singleton smoke, and startup-memory check run inside the same wave as the selected artifact checks, so on Blacksmith they finish alongside them instead of adding a serial step; hosted 4-core runners serialize the three verifiers first so the RSS measurement stays unperturbed. That wave step is unconditional because the verifiers always run, while each artifact check keeps its own selection gate.
8080

8181
Use `pnpm ci:timings`, `pnpm ci:timings:recent`, or `node scripts/ci-run-timings.mjs <run-id>` to summarize wall time, start delay, slowest jobs, failures, and the `pnpm-store-warmup` fanout barrier from GitHub Actions. Use `pnpm ci:timings:trend` for a 72-hour baseline and a latest-12-hours versus prior-12-hours comparison. Trend mode includes every main push outcome, cancellation/pass rates, and successful-run wall time, then loads a balanced latest/prior sample of at most 100 successful runs by default. Its detailed sample separates workflow admission, job dependency/gate delay (`job.created_at` minus the first job's creation), runner queue/start latency (`job.started_at` minus `job.created_at`), and execution; it also reports critical-path ownership and the actual GitHub API request count. Reruns use attempt-specific jobs and are excluded from run-level wall/admission distributions because GitHub retains the original workflow creation time. Raise or lower the detailed-run selection cap with `--detail-runs` (a run with more than 100 jobs requires multiple requests), emit JSON to stdout with `--json`, or save the same report with `--output .artifacts/ci-timings/trend.json`; missing output directories are created automatically. The baseline must cover at least two comparison windows.
8282

‎test/scripts/ci-workflow-guards.test.ts‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6720,12 +6720,19 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
67206720
expect(parityStep.run).not.toContain("pnpm apple:i18n:check");
67216721
});
67226722

6723-
it("verifies built runtime artifacts with hosted-serial and Blacksmith-parallel modes", () => {
6723+
it("runs built runtime verifiers inside the artifact-check wave", () => {
67246724
const workflow = readCiWorkflow();
6725-
const verifierStep = workflow.jobs["build-artifacts"].steps.find(
6726-
(step: WorkflowStep) => step.name === "Verify built runtime artifacts",
6725+
const steps = workflow.jobs["build-artifacts"].steps;
6726+
const verifierStep = steps.find(
6727+
(step: WorkflowStep) => step.name === "Run built artifact checks",
67276728
);
67286729

6730+
// The verifiers always run, so the shared step cannot be gated on the
6731+
// selected checks; each check keeps its own RUN_* gate inside the body.
6732+
expect(verifierStep.if).toBeUndefined();
6733+
expect(steps.some((step: WorkflowStep) => step.name === "Verify built runtime artifacts")).toBe(
6734+
false,
6735+
);
67296736
// The hosted RSS allowance and the serial fallback keep the startup-memory
67306737
// measurement unperturbed on 4-core hosted runners.
67316738
expect(verifierStep.env.OPENCLAW_STARTUP_MEMORY_PLUGINS_LIST_MB).toBe(
@@ -6743,12 +6750,20 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
67436750
expect(verifierStep.run).toContain("--config test/vitest/vitest.e2e.config.ts");
67446751
expect(verifierStep.run).toContain("Selected target predates");
67456752
expect(verifierStep.run).toContain("pnpm test:build:singleton");
6746-
// The parallel branch must complete any startup asset rebuild before
6747-
// forking so concurrent verifiers never read dist mid-write.
6753+
// The startup asset rebuild must complete before any verifier forks so
6754+
// concurrent readers never observe dist mid-write.
67486755
expect(verifierStep.run).toContain("scripts/ensure-cli-startup-build.mts");
67496756
expect(verifierStep.run).toContain("scripts/check-cli-startup-memory.mjs");
6750-
expect(verifierStep.run).toContain("pnpm test:startup:memory");
67516757
expect(verifierStep.run).toContain(".artifacts/startup-memory/summary.md");
6758+
// Every verifier reports through the shared results map so a failure can
6759+
// never be swallowed by the wave.
6760+
for (const name of ["doctor-plugin-index", "plugin-singleton", "startup-memory"]) {
6761+
expect(verifierStep.run).toContain(`run_verifier "${name}"`);
6762+
expect(verifierStep.run).toContain(`["${name}"]="skipped"`);
6763+
}
6764+
expect(verifierStep.run).toContain(
6765+
"for name in channels core-support-boundary doctor-plugin-index gateway-watch plugin-singleton startup-memory tui-pty; do",
6766+
);
67526767
});
67536768

67546769
it("runs the scoped SQLite lifecycle proof against the exact built artifact", () => {
@@ -6889,7 +6904,9 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
68896904
"launches openclaw (chat as local mode|tui against a real Gateway) through a real PTY",
68906905
);
68916906
expect(run).toContain("wait_checks()");
6892-
expect(run.match(/wait_checks$/gmu)).toHaveLength(3);
6907+
// Three wave barriers plus the one inside run_verifier, which serializes
6908+
// the built-runtime verifiers on hosted runners only.
6909+
expect(run.match(/wait_checks$/gmu)).toHaveLength(4);
68936910
});
68946911

68956912
it("keeps docs i18n CI on the workflow-owned patched Go toolchain", () => {

0 commit comments

Comments
 (0)