diff --git a/.github/workflows/openclaw-performance.yml b/.github/workflows/openclaw-performance.yml index 3aa65bfe6680..3906c4c440ed 100644 --- a/.github/workflows/openclaw-performance.yml +++ b/.github/workflows/openclaw-performance.yml @@ -683,7 +683,7 @@ jobs: fi mkdir -p "$SOURCE_PERF_DIR/mock-hello" - if ! node -e "const fs=require('node:fs'); const scripts=require('./package.json').scripts||{}; process.exit(scripts['test:gateway:cpu-scenarios'] && scripts['test:extensions:memory'] && scripts.openclaw && fs.existsSync('scripts/bench-cli-startup.ts') && fs.existsSync('scripts/profile-extension-memory.mjs') ? 0 : 1)"; then + if ! node -e "const fs=require('node:fs'); const scripts=require('./package.json').scripts||{}; process.exit(scripts['test:gateway:cpu-scenarios'] && scripts['test:extensions:memory'] && scripts.openclaw && fs.existsSync('openclaw.mjs') && fs.existsSync('scripts/profile-extension-memory.mjs') ? 0 : 1)"; then cat > "$SOURCE_PERF_DIR/index.md" <> "$GITHUB_STEP_SUMMARY" exit 0 @@ -849,7 +849,8 @@ jobs: done OPENCLAW_HOME="$gateway_home" OPENCLAW_STATE_DIR="$gateway_state" OPENCLAW_CONFIG_PATH="$gateway_config" OPENCLAW_GATEWAY_PORT="$gateway_port" \ - node --import tsx scripts/bench-cli-startup.ts \ + node --import tsx "$PERFORMANCE_HELPER_DIR/scripts/bench-cli-startup.ts" \ + --entry "$GITHUB_WORKSPACE/openclaw.mjs" \ --case gatewayHealthJsonConnected \ --case gatewayHealthJsonFirstDevice \ --case configGetGatewayPort \ diff --git a/scripts/bench-cli-startup.ts b/scripts/bench-cli-startup.ts index 47fe8c6a006b..3db050915f42 100644 --- a/scripts/bench-cli-startup.ts +++ b/scripts/bench-cli-startup.ts @@ -5,7 +5,6 @@ import os from "node:os"; import path from "node:path"; import { pathToFileURL } from "node:url"; import { expectDefined } from "../packages/normalization-core/src/expect.js"; -import { parseStrictIntegerOption } from "./lib/dev-tooling-safety.ts"; type CommandCase = { id: string; @@ -529,11 +528,33 @@ function validateCliArgs(argv: readonly string[] = process.argv.slice(2)): void } function parsePositiveInt(raw: string | undefined, fallback: number, label = "value"): number { - return parseStrictIntegerOption({ fallback, label, min: 1, raw }); + return parseIntegerOption(raw, fallback, label, 1); } function parseNonNegativeInt(raw: string | undefined, fallback: number, label = "value"): number { - return parseStrictIntegerOption({ fallback, label, min: 0, raw }); + return parseIntegerOption(raw, fallback, label, 0); +} + +// This runner is checked out from trusted main beside frozen candidates, whose +// root dependencies need not include current workspace packages. +function parseIntegerOption( + raw: string | undefined, + fallback: number, + label: string, + min: number, +): number { + const value = raw?.trim(); + if (!value) { + return fallback; + } + if (!/^\d+$/u.test(value)) { + throw new Error(`${label} must be an integer >= ${min}; got ${JSON.stringify(raw)}`); + } + const parsed = Number(value); + if (!Number.isSafeInteger(parsed) || parsed < min) { + throw new Error(`${label} must be an integer >= ${min}; got ${JSON.stringify(raw)}`); + } + return parsed; } function parseGatewayPortEnv(raw: string | undefined): number { diff --git a/test/scripts/openclaw-performance-workflow.test.ts b/test/scripts/openclaw-performance-workflow.test.ts index c0eedf012628..8b4105f1a875 100644 --- a/test/scripts/openclaw-performance-workflow.test.ts +++ b/test/scripts/openclaw-performance-workflow.test.ts @@ -247,7 +247,7 @@ describe("OpenClaw performance workflow", () => { " sleep 1", " fi", ].join("\n"); - const benchmark = "node --import tsx scripts/bench-cli-startup.ts \\"; + const benchmark = 'node --import tsx "$PERFORMANCE_HELPER_DIR/scripts/bench-cli-startup.ts" \\'; expect(run).toContain("gateway_ready_timeout_seconds=120"); expect(run).toContain("gateway_probe_timeout_seconds=5"); @@ -289,9 +289,11 @@ describe("OpenClaw performance workflow", () => { expect(run).toContain('rm -rf "$gateway_home" "$gateway_readiness_home"'); }); - it("measures warmed and first-device gateway health separately", () => { + it("runs trusted CLI performance cases against the frozen candidate entrypoint", () => { const run = findStep("Run OpenClaw source performance probes", "source_performance").run ?? ""; + expect(run).toContain('"$PERFORMANCE_HELPER_DIR/scripts/bench-cli-startup.ts"'); + expect(run).toContain('--entry "$GITHUB_WORKSPACE/openclaw.mjs"'); expect(run).toContain("--case gatewayHealthJsonConnected \\"); expect(run).toContain("--case gatewayHealthJsonFirstDevice \\"); });