fix(ci): avoid unrelated Node shards for native inventory changes (#156991)

* fix(ci): run native inventory readers for app changes

Co-authored-by: IWhatsskill <284122573+IWhatsskill@users.noreply.github.com>

* fix(ci): scope policy owners and await maintenance starts

Co-authored-by: IWhatsskill <284122573+IWhatsskill@users.noreply.github.com>

---------

Co-authored-by: IWhatsskill <284122573+IWhatsskill@users.noreply.github.com>
This commit is contained in:
RoboClaw 2026-09-23 22:00:23 -07:00 • committed by GitHub
parent 7f4cf877ca
commit 0589c8360b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 80 additions and 7 deletions

View file

@ -894,6 +894,12 @@ export function createChangedNodeTestShards(
policyTargets.length > 0,
),
);
const policyTargets = [...new Set([...policyTargetsByPath.values()].flat())];
const completeOwnerTargets = new Set(
[...policyTargetsByPath.keys()].flatMap((changedPath) =>
resolvePolicyTestTargets([changedPath], { completeOwnersOnly: true }),
),
);
const regularPaths = resolutionPaths.filter(
(changedPath) =>
!documentationPaths.has(changedPath) &&
@ -1073,7 +1079,7 @@ export function createChangedNodeTestShards(
cwd,
documentationPaths,
[
...[...policyTargetsByPath.values()].flat(),
...policyTargets,
...dependencyConsumers.tests,
...resolveAffectedTestsFromImportGraph([...pluginMetadataPaths], cwd, {
tooling: true,
@ -1111,6 +1117,7 @@ export function createChangedNodeTestShards(
changedPaths.includes(target) ||
options.includeReleaseOnlyToolingShards !== false ||
changedPaths.some(isToolingTestOwnerPath) ||
completeOwnerTargets.has(target) ||
(!isReleaseOnlyToolingTestFile(target) &&
!plans.every((plan) => RELEASE_ONLY_TOOLING_CONFIGS.has(plan.config)))) &&
!plans.every(({ config }) =>

View file

@ -204,6 +204,14 @@ type PolicyTestWatch = {
// this inventory covers the remaining tests that changed targeting cannot
// discover from imports alone.
const policyTestWatches = [
...["test/scripts/android-app-i18n.test.ts", "test/scripts/apple-app-i18n.test.ts"].map(
(testFile): PolicyTestWatch => ({
// Both suites read this inventory by filename, not through the import graph.
testFile,
ownerGlobs: ["apps/.i18n/native-source.json"],
watchGlobs: ["apps/.i18n/native-source.json"],
}),
),
{
testFile: "test/scripts/tsgo-core-test-shards.test.ts",
watchGlobs: [
@ -288,12 +296,18 @@ const policyTestWatches = [
},
] satisfies readonly PolicyTestWatch[];
/** Resolve policy tests whose scanned source surface intersects this diff. */
export function resolvePolicyTestTargets(changedPaths: readonly string[]): string[] {
/** Resolve watched tests, optionally restricting to complete owners of the changed input. */
export function resolvePolicyTestTargets(
changedPaths: readonly string[],
options: { completeOwnersOnly?: boolean } = {},
): string[] {
return policyTestWatches
.filter(({ watchGlobs }) =>
changedPaths.some((changedPath) =>
watchGlobs.some((watchGlob) => matchesGlob(changedPath, watchGlob)),
.filter(({ watchGlobs, ownerGlobs }) =>
changedPaths.some(
(changedPath) =>
watchGlobs.some((watchGlob) => matchesGlob(changedPath, watchGlob)) &&
(!options.completeOwnersOnly ||
ownerGlobs?.some((ownerGlob) => matchesGlob(changedPath, ownerGlob))),
),
)
.map(({ testFile }) => testFile);

View file

@ -285,7 +285,12 @@ describe("durable accepted-turn maintenance handoff", () => {
expect(fixture.commitTurn).toHaveBeenCalledOnce();
expect(fixture.pendingTurn()).toBeUndefined();
// No second user turn or explicit scheduler invocation starts the work.
await vi.waitFor(() => expect(fixture.maintain).toHaveBeenCalledOnce());
const maintenanceResult = await Promise.race([
fixture.maintenanceStarted.promise.then(() => "started"),
waitForDeferredTurnMaintenanceForSession(fixture.facts.sessionKey).then(() => "settled"),
]);
expect(maintenanceResult).toBe("started");
expect(fixture.maintain).toHaveBeenCalledOnce();
expect(fixture.maintain.mock.calls[0]?.[0]).toMatchObject({
sessionId: fixture.facts.sessionIdUsed,
sessionKey: fixture.facts.sessionKey,

View file

@ -2094,6 +2094,53 @@ describe("CI changed Node test plan", () => {
}
});
it("routes the native source inventory to both readers in a mixed Android PR", () => {
const changedPaths = [
"apps/.i18n/native-source.json",
"apps/android/README.md",
"apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt",
"apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt",
"apps/android/app/src/main/java/ai/openclaw/app/ui/chat/ChatRealtimeTalk.kt",
"apps/android/app/src/main/java/ai/openclaw/app/ui/chat/ChatScreen.kt",
"apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt",
"apps/android/app/src/test/java/ai/openclaw/app/ui/chat/ChatComposerLayoutTest.kt",
"apps/android/app/src/test/java/ai/openclaw/app/voice/TalkModeManagerTest.kt",
];
const onFallback = vi.fn();
const dedicatedNativeChecks = { macos: false, ios: false, android: true };
const shards = createChangedNodeTestShards(changedPaths, {
dedicatedNativeChecks,
includeReleaseOnlyToolingShards: false,
onFallback,
});
expect(onFallback).not.toHaveBeenCalled();
expect(shards).not.toBeNull();
const files = selectedFiles(shards);
expect(files.filter((file) => file === "test/scripts/android-app-i18n.test.ts")).toHaveLength(
1,
);
expect(files.filter((file) => file === "test/scripts/apple-app-i18n.test.ts")).toHaveLength(1);
expect(files).toHaveLength(2);
expect(
createChangedNodeTestShards([...changedPaths, "apps/.i18n/unowned.json"], {
dedicatedNativeChecks,
}),
).toBeNull();
expect(
createChangedNodeTestShards(changedPaths, {
dedicatedNativeChecks: { ...dedicatedNativeChecks, android: false },
}),
).toBeNull();
});
it("keeps product-only policy watches out of deferred tooling", () => {
const shards = createChangedNodeTestShards(["src/auto-reply/reply/abort.test.ts"], {
includeReleaseOnlyToolingShards: false,
});
expect(shards).not.toBeNull();
expect(selectedFiles(shards)).not.toContain("test/scripts/tsgo-core-test-shards.test.ts");
});
it.each([
{
source: "packages/example/src/value.ts",