Skip to content

Commit 6ddd598

Browse files
authored
fix(ci): run Windows checks for declared native test changes (#133208)
1 parent d04a96c commit 6ddd598

4 files changed

Lines changed: 77 additions & 42 deletions

File tree

‎docs/ci.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Separate iOS and macOS Periphery workflows enforce a zero-findings dead-code pol
221221
- **SQLite session lifecycle** runs the built-CLI migration, restart, compaction, cleanup, and session RPC proof only when the diff touches its direct storage/session owners or a reachable session path in the embedded runner. The dedicated `check-sqlite-session-lifecycle` job downloads the exact runtime produced by `build-artifacts`; manual and release dispatches always select it when the target contains the proof.
222222
- **CI routing-only edits, the small set of core-test fixtures the fast task runs directly, and narrow plugin contract helper edits** use a fast Node-only manifest path: `preflight`, `security-fast`, and only the fast lanes the change touches — a single `checks-fast-core` CI-routing task, the two plugin contract shards, or both. That path skips build artifacts, Node 22 compatibility, channel contracts, full core shards, bundled-plugin shards, and additional guard matrices.
223223
- **QA Smoke on pull requests** runs only when the diff touches a QA-owned surface: the qa-lab harness, `qa/` scenario data, the matrix/telegram channels the smoke profile drives, the docker packaging scripts, or the gate's own orchestration. Broad runtime changes (src, ui, packages, dependency manifests) no longer select the six-part smoke matrix per PR; every canonical `main` push and release validation still runs the full profile set, so runtime regressions surface one push after merge instead of taxing every PR with roughly five extra hosted-runner minutes.
224-
- **Windows Node checks** are scoped to Windows-specific process/path wrappers, npm/pnpm/UI runner helpers, package manager config, and the CI workflow surfaces that execute that lane; unrelated source, plugin, install-smoke, and test-only changes stay on the Linux Node lanes.
224+
- **Windows Node checks** are scoped to Windows-specific process/path wrappers, npm/pnpm/UI runner helpers, package manager config, and the CI workflow surfaces that execute that lane; unrelated source, plugin, install-smoke, and test-only changes stay on the Linux Node lanes. Test-only changes to any explicit target in `test:windows:ci:1` or `test:windows:ci:2` also select the existing Windows lane; these package scripts own its test inventory.
225225

226226
The slowest Node test families are split or balanced so each job stays small without over-reserving runners:
227227

‎scripts/ci-changed-scope.mjs‎

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ const WINDOWS_SQLITE_SCOPE_RE = /^src\/(?:state\/|.*sqlite.*\.ts$)/;
6767
const WINDOWS_FILE_URL_SCOPE_RE =
6868
/^(?:src\/agents\/tools\/(?:media-tool-file-url\.windows\.test|media-tool-shared(?:\.test)?|pdf-tool(?:\.test)?)|src\/auto-reply\/(?:reply\/stage-sandbox-media|reply\.triggers\.trigger-handling\.stages-inbound-media-into-sandbox-workspace\.test)|src\/media\/(?:local-media-path(?:\.windows\.test)?|local-roots(?:\.test)?|web-media(?:\.file-url\.windows\.test)?)|src\/channels\/inbound-event\/media(?:\.test)?|src\/gateway\/managed-image-attachments(?:\.test)?|extensions\/msteams\/src\/(?:media-helpers|messenger)(?:\.test)?)\.ts$/;
6969
const WINDOWS_SCOPE_RE =
70-
/^(extensions\/mxc\/|src\/agents\/(?:bash-tools\.exec-script-(?:preflight|target)|bash-tools\.exec\.script-preflight\.test)\.ts$|src\/config\/sessions\/(?:session-accessor\.sqlite-archive(?:\.worker(?:\.test)?)?|store\.session-lifecycle-mutation\.test)\.ts$|src\/process\/|src\/infra\/(?:(?:advertised-lan-host|exec-allowlist-pattern|fs-safe-remove)(?:\.windows)?(?:\.test)?|ports(?:-inspect|\.test)|ssh-client(?:\.windows\.test)?|update-managed-service-handoff(?:-(?:command|lifecycle)\.test)?|windows-install-roots)\.ts$|src\/shared\/(?:import-specifier|runtime-import)(?:\.test)?\.ts$|src\/test-utils\/openclaw-test-state(?:\.test)?\.ts$|scripts\/(?:android-(?:app-i18n|pin-version)\.ts|ci-run-timings\.mjs|e2e\/lib\/package-compat\.mjs|generate-bundled-channel-config-metadata\.ts|install\.ps1|openclaw-cross-os-release-checks\.ts|plan-release-workflow-matrix\.mjs|run-additional-boundary-checks\.mts|verify-docker-attestations\.mjs|github\/run-openclaw-cross-os-release-checks\.sh|tsx\.mjs|(?:npm-runner|pnpm-runner|ui|vitest-process-group)\.(?:mjs|mts|js)|lib\/(?:direct-run\.(?:mjs|mts)|format-generated-module\.mts|tsx-cli-shim\.mjs|cross-os-release-checks\/[^/]+\.ts))$|test\/scripts\/(?:direct-run-entrypoints|format-generated-module|install-ps1|npm-runner|openclaw-cross-os-release-workflow|pnpm-runner|ui|vitest-process-group)\.test\.ts$|package\.json$|pnpm-lock\.yaml$|pnpm-workspace\.yaml$|\.github\/workflows\/(?:ci|openclaw-cross-os-release-checks-reusable)\.yml$|\.github\/actions\/setup-node-env\/action\.yml$|\.github\/actions\/setup-pnpm-store-cache\/action\.yml$)/;
71-
const WINDOWS_TEST_SCOPE_RE =
72-
/^(extensions\/mxc\/test\/(?:mxc-backend|sandbox-policy-loader)\.test\.ts$|src\/agents\/bash-tools\.exec\.script-preflight\.test\.ts$|src\/config\/sessions\/(?:session-accessor\.sqlite-archive\.worker|store\.session-lifecycle-mutation)\.test\.ts$|src\/process\/(?:exec\.windows|supervisor\/supervisor\.anchored-shell\.real|terminal-pty|windows-command)\.test\.ts$|src\/infra\/(?:advertised-lan-host(?:\.windows)?|exec-allowlist-pattern|fs-safe-remove|ports|ssh-client\.windows|update-managed-service-handoff-(?:command|lifecycle)|windows-install-roots)\.test\.ts$|src\/shared\/runtime-import\.test\.ts$|src\/state\/openclaw-database-paths\.windows\.test\.ts$|src\/test-utils\/openclaw-test-state\.test\.ts$|test\/scripts\/(?:direct-run-entrypoints|format-generated-module|install-ps1|npm-runner|openclaw-cross-os-release-workflow|pnpm-runner|ui|vitest-process-group)\.test\.ts$)/;
70+
/^(extensions\/mxc\/|src\/agents\/(?:bash-tools\.exec-script-(?:preflight|target)|bash-tools\.exec\.script-preflight\.test)\.ts$|src\/config\/sessions\/(?:session-accessor\.sqlite-archive(?:\.worker(?:\.test)?)?|store\.session-lifecycle-mutation\.test)\.ts$|src\/process\/|src\/infra\/(?:(?:exec-allowlist-pattern|fs-safe-remove)(?:\.windows)?(?:\.test)?|ports(?:-inspect|\.test)|ssh-client(?:\.windows\.test)?|update-managed-service-handoff(?:-(?:command|lifecycle)\.test)?|windows-install-roots)\.ts$|src\/shared\/(?:import-specifier|runtime-import)(?:\.test)?\.ts$|src\/test-utils\/openclaw-test-state(?:\.test)?\.ts$|scripts\/(?:android-(?:app-i18n|pin-version)\.ts|ci-run-timings\.mjs|e2e\/lib\/package-compat\.mjs|generate-bundled-channel-config-metadata\.ts|install\.ps1|openclaw-cross-os-release-checks\.ts|plan-release-workflow-matrix\.mjs|run-additional-boundary-checks\.mts|verify-docker-attestations\.mjs|github\/run-openclaw-cross-os-release-checks\.sh|tsx\.mjs|(?:npm-runner|pnpm-runner|ui|vitest-process-group)\.(?:mjs|mts|js)|lib\/(?:direct-run\.(?:mjs|mts)|format-generated-module\.mts|tsx-cli-shim\.mjs|cross-os-release-checks\/[^/]+\.ts))$|test\/scripts\/(?:direct-run-entrypoints|format-generated-module|install-ps1|npm-runner|openclaw-cross-os-release-workflow|pnpm-runner|ui|vitest-process-group)\.test\.ts$|package\.json$|pnpm-lock\.yaml$|pnpm-workspace\.yaml$|\.github\/workflows\/(?:ci|openclaw-cross-os-release-checks-reusable)\.yml$|\.github\/actions\/setup-node-env\/action\.yml$|\.github\/actions\/setup-pnpm-store-cache\/action\.yml$)/;
71+
const WINDOWS_LAN_ADVERTISEMENT_SCOPE_RE =
72+
/^src\/infra\/advertised-lan-host(?:\.windows)?(?:\.test)?\.ts$/;
7373
const WINDOWS_SECRETREF_SCOPE_RE =
7474
/^(?:src\/commands\/doctor-gateway-auth-token(?:\.windows\.test)?\.ts|src\/flows\/(?:doctor-core-checks|doctor-health-contributions)\.ts|src\/gateway\/(?:auth-token-resolution|resolve-configured-secret-input-string)\.ts|src\/infra\/(?:fs-safe|fs-safe-defaults|permissions)\.ts|src\/secrets\/(?:resolve|resolve-errors)\.ts|src\/security\/audit-fs\.ts)$/;
75-
const WINDOWS_SECRETREF_TEST_SCOPE_RE =
76-
/^src\/commands\/doctor-gateway-auth-token\.windows\.test\.ts$/;
7775
const WINDOWS_DAEMON_SCOPE_RE =
7876
/^src\/daemon\/(?:schtasks(?:[-.][^/]+)?|runtime-hints\.windows-paths(?:\.test)?|test-helpers\/schtasks-(?:base-mocks|fixtures))\.ts$/;
7977
const WINDOWS_USAGE_TEMPLATE_SCOPE_RE =
@@ -149,6 +147,20 @@ export function detectChangedScope(changedPaths) {
149147
return { ...FULL_SCOPE };
150148
}
151149

150+
// The package scripts own the native test inventory; a second whitelist drifts.
151+
const scripts = JSON.parse(
152+
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
153+
).scripts;
154+
const windowsCiTests = new Set(
155+
[1, 2].flatMap((part) => {
156+
const targets = scripts[`test:windows:ci:${part}`].match(/[^\s"']+\.test\.ts/g);
157+
if (!targets) {
158+
throw new Error(`Windows CI part ${part} must declare explicit test paths`);
159+
}
160+
return targets;
161+
}),
162+
);
163+
152164
let runNode = false;
153165
let runMacos = false;
154166
let hasGitOwnerChanges = false;
@@ -210,38 +222,25 @@ export function detectChangedScope(changedPaths) {
210222
}
211223

212224
if (
213-
(WINDOWS_SCOPE_RE.test(path) ||
214-
WINDOWS_SQLITE_SCOPE_RE.test(path) ||
215-
WINDOWS_FILE_URL_SCOPE_RE.test(path) ||
216-
WINDOWS_SECRETREF_SCOPE_RE.test(path) ||
217-
WINDOWS_DAEMON_SCOPE_RE.test(path) ||
218-
WINDOWS_USAGE_TEMPLATE_SCOPE_RE.test(path) ||
219-
WINDOWS_MEDIA_UNDERSTANDING_FILE_URL_SCOPE_RE.test(path) ||
220-
WINDOWS_HOME_DISPLAY_SCOPE_RE.test(path) ||
221-
WINDOWS_AGENT_HOME_PATH_SCOPE_RE.test(path) ||
222-
WINDOWS_CHILD_ENV_SCOPE_RE.test(path) ||
223-
WINDOWS_SOURCE_CLI_SCOPE_RE.test(path) ||
224-
WINDOWS_NODE_HOST_EXECUTABLE_SCOPE_RE.test(path) ||
225-
WINDOWS_MEMORY_EXTRA_FILE_SCOPE_RE.test(path) ||
226-
WINDOWS_WORKSPACE_QUIESCENCE_SCOPE_RE.test(path) ||
227-
WINDOWS_WORKER_BUNDLE_SCOPE_RE.test(path) ||
228-
WINDOWS_WORKER_WORKSPACE_SCOPE_RE.test(path)) &&
229-
(!facts.isTestOnly ||
230-
WINDOWS_TEST_SCOPE_RE.test(path) ||
231-
WINDOWS_FILE_URL_SCOPE_RE.test(path) ||
232-
WINDOWS_SECRETREF_TEST_SCOPE_RE.test(path) ||
233-
WINDOWS_DAEMON_SCOPE_RE.test(path) ||
234-
WINDOWS_USAGE_TEMPLATE_SCOPE_RE.test(path) ||
235-
WINDOWS_MEDIA_UNDERSTANDING_FILE_URL_SCOPE_RE.test(path) ||
236-
WINDOWS_HOME_DISPLAY_SCOPE_RE.test(path) ||
237-
WINDOWS_AGENT_HOME_PATH_SCOPE_RE.test(path) ||
238-
WINDOWS_CHILD_ENV_SCOPE_RE.test(path) ||
239-
WINDOWS_SOURCE_CLI_SCOPE_RE.test(path) ||
240-
WINDOWS_NODE_HOST_EXECUTABLE_SCOPE_RE.test(path) ||
241-
WINDOWS_MEMORY_EXTRA_FILE_SCOPE_RE.test(path) ||
242-
WINDOWS_WORKSPACE_QUIESCENCE_SCOPE_RE.test(path) ||
243-
WINDOWS_WORKER_BUNDLE_SCOPE_RE.test(path) ||
244-
WINDOWS_WORKER_WORKSPACE_SCOPE_RE.test(path))
225+
windowsCiTests.has(path) ||
226+
WINDOWS_LAN_ADVERTISEMENT_SCOPE_RE.test(path) ||
227+
WINDOWS_FILE_URL_SCOPE_RE.test(path) ||
228+
WINDOWS_DAEMON_SCOPE_RE.test(path) ||
229+
WINDOWS_USAGE_TEMPLATE_SCOPE_RE.test(path) ||
230+
WINDOWS_MEDIA_UNDERSTANDING_FILE_URL_SCOPE_RE.test(path) ||
231+
WINDOWS_HOME_DISPLAY_SCOPE_RE.test(path) ||
232+
WINDOWS_AGENT_HOME_PATH_SCOPE_RE.test(path) ||
233+
WINDOWS_CHILD_ENV_SCOPE_RE.test(path) ||
234+
WINDOWS_SOURCE_CLI_SCOPE_RE.test(path) ||
235+
WINDOWS_NODE_HOST_EXECUTABLE_SCOPE_RE.test(path) ||
236+
WINDOWS_MEMORY_EXTRA_FILE_SCOPE_RE.test(path) ||
237+
WINDOWS_WORKSPACE_QUIESCENCE_SCOPE_RE.test(path) ||
238+
WINDOWS_WORKER_BUNDLE_SCOPE_RE.test(path) ||
239+
WINDOWS_WORKER_WORKSPACE_SCOPE_RE.test(path) ||
240+
(!facts.isTestOnly &&
241+
(WINDOWS_SCOPE_RE.test(path) ||
242+
WINDOWS_SQLITE_SCOPE_RE.test(path) ||
243+
WINDOWS_SECRETREF_SCOPE_RE.test(path)))
245244
) {
246245
runWindows = true;
247246
}

‎src/scripts/ci-changed-scope.test.ts‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,14 @@ describe("detectChangedScope", () => {
971971
expect(parseGitHubOutput(fs.readFileSync(outputPath, "utf8")).changed_paths_json).toBe("null");
972972
});
973973

974-
it("loads from a zero-install tree and keeps empty diffs as no-op scope", () => {
974+
it.each([
975+
["empty diff without a manifest", "", "missing", false],
976+
["declared native test", "src/process/exec.windows.integration.test.ts", "valid", false],
977+
["unrelated process test", "src/process/exec.test.ts", "valid", false],
978+
["missing manifest", "src/process/exec.test.ts", "missing", true],
979+
["invalid manifest", "src/process/exec.test.ts", "invalid", true],
980+
["empty native inventory", "src/process/exec.test.ts", "empty", true],
981+
])("runs zero-install scope detection for %s", (_label, changedPath, manifest, failSafe) => {
975982
const repoDir = fs.realpathSync(
976983
fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-ci-scope-empty-")),
977984
);
@@ -995,8 +1002,23 @@ describe("detectChangedScope", () => {
9951002
execFileSync("git", ["add", "README.md"], { cwd: repoDir });
9961003
execFileSync("git", ["commit", "-m", "test"], { cwd: repoDir });
9971004

1005+
if (manifest !== "missing") {
1006+
const contents =
1007+
manifest === "valid"
1008+
? fs.readFileSync("package.json", "utf8")
1009+
: manifest === "invalid"
1010+
? "{"
1011+
: JSON.stringify({ scripts: { "test:windows:ci:1": "" } });
1012+
writeRepoFile(repoDir, "package.json", contents);
1013+
}
1014+
if (changedPath) {
1015+
writeRepoFile(repoDir, changedPath, "export {};\n");
1016+
git(repoDir, ["add", changedPath]);
1017+
git(repoDir, ["commit", "-m", "changed test"]);
1018+
}
1019+
const base = changedPath ? "HEAD^" : "HEAD";
9981020
expect(fs.existsSync(path.join(repoDir, "node_modules"))).toBe(false);
999-
execFileSync(process.execPath, [scriptPath, "--base", "HEAD", "--head", "HEAD"], {
1021+
execFileSync(process.execPath, [scriptPath, "--base", base, "--head", "HEAD"], {
10001022
cwd: repoDir,
10011023
env: { ...process.env, GITHUB_OUTPUT: outputPath },
10021024
});
@@ -1007,10 +1029,16 @@ describe("detectChangedScope", () => {
10071029
" ",
10081030
),
10091031
);
1010-
expect(output.changed_paths_json).toBe("[]");
1032+
expect(output.changed_paths_json).toBe(
1033+
failSafe ? "null" : JSON.stringify(changedPath ? [changedPath] : []),
1034+
);
10111035
for (const [key, value] of Object.entries(output)) {
10121036
if (key !== "changed_paths_json") {
1013-
expect(value, key).toBe("false");
1037+
const selected =
1038+
(failSafe && !key.startsWith("run_node_fast")) ||
1039+
(key === "run_node" && Boolean(changedPath)) ||
1040+
(key === "run_windows" && changedPath === "src/process/exec.windows.integration.test.ts");
1041+
expect(value, key).toBe(String(selected));
10141042
}
10151043
}
10161044
});

‎test/package-scripts.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import fs from "node:fs";
33
import { expectDefined } from "@openclaw/normalization-core";
44
import { describe, expect, it } from "vitest";
5+
import { detectChangedScope } from "../scripts/ci-changed-scope.mjs";
56

67
type RootPackageJson = {
78
scripts: Record<string, string>;
@@ -226,6 +227,13 @@ describe("package scripts", () => {
226227
expect(scripts["android:test"]).toContain(":wear:testDebugUnitTest");
227228
});
228229

230+
it("routes every declared Windows CI test to its native lane", () => {
231+
const missedTargets = readWindowsCiPartScripts()
232+
.flatMap(readWindowsCiTargets)
233+
.filter((target) => !detectChangedScope([target]).runWindows);
234+
expect(missedTargets).toEqual([]);
235+
});
236+
229237
it("partitions Windows CI coverage into two disjoint explicit test lists", () => {
230238
const scripts = readPackageJson().scripts;
231239
const partScripts = readWindowsCiPartScripts();

0 commit comments

Comments
 (0)