fix(tooling): harden changed checks for sparse worktrees

This commit is contained in:
Vincent Koc
2026-04-25 00:48:18 -07:00
parent 1ca029e888
commit 73d72204a0
5 changed files with 180 additions and 3 deletions

View File

@@ -370,6 +370,8 @@ describe("scripts/changed-lanes", () => {
PATH: "/usr/bin",
OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS: CHANGED_CHECK_VITEST_NO_OUTPUT_TIMEOUT_MS,
OPENCLAW_VITEST_NO_OUTPUT_RETRY: "0",
OPENCLAW_TEST_PROJECTS_SERIAL: "1",
OPENCLAW_VITEST_MAX_WORKERS: "1",
});
expect(
@@ -382,4 +384,16 @@ describe("scripts/changed-lanes", () => {
OPENCLAW_VITEST_NO_OUTPUT_RETRY: "1",
});
});
it("does not force serial changed-check tests in CI or when workers are explicit", () => {
expect(createChangedCheckVitestEnv({ CI: "true" })).not.toHaveProperty(
"OPENCLAW_VITEST_MAX_WORKERS",
);
expect(createChangedCheckVitestEnv({ OPENCLAW_VITEST_MAX_WORKERS: "4" })).toMatchObject({
OPENCLAW_VITEST_MAX_WORKERS: "4",
});
expect(
createChangedCheckVitestEnv({ OPENCLAW_TEST_PROJECTS_PARALLEL: "4" }),
).not.toHaveProperty("OPENCLAW_TEST_PROJECTS_SERIAL");
});
});

View File

@@ -1,6 +1,9 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { shouldPrepareExtensionPackageBoundaryArtifacts } from "../../scripts/run-oxlint.mjs";
import {
filterSparseMissingOxlintTargets,
shouldPrepareExtensionPackageBoundaryArtifacts,
} from "../../scripts/run-oxlint.mjs";
describe("run-oxlint", () => {
it("prepares extension package boundary artifacts for normal lint runs", () => {
@@ -30,4 +33,36 @@ describe("run-oxlint", () => {
expect(shardedLintRunner).toContain("prepare-extension-package-boundary-artifacts.mjs");
expect(shardedLintRunner).toContain('OPENCLAW_OXLINT_SKIP_PREPARE: "1"');
});
it("filters tracked targets missing from sparse checkouts", () => {
const result = filterSparseMissingOxlintTargets(
["--tsconfig", "tsconfig.oxlint.core.json", "src", "ui", "packages", "--threads=1"],
{
fileExists: (target: string) => target.endsWith("/src"),
isSparseCheckoutEnabled: () => true,
isTrackedPath: ({ target }: { target: string }) => target === "ui" || target === "packages",
},
);
expect(result).toEqual({
args: ["--tsconfig", "tsconfig.oxlint.core.json", "src", "--threads=1"],
hadExplicitTargets: true,
remainingExplicitTargets: 1,
skippedTargets: ["ui", "packages"],
});
});
it("keeps missing untracked oxlint targets so typos still fail", () => {
const result = filterSparseMissingOxlintTargets(["src", "typo"], {
fileExists: (target: string) => target.endsWith("/src"),
isSparseCheckoutEnabled: () => true,
isTrackedPath: () => false,
});
expect(result).toMatchObject({
args: ["src", "typo"],
remainingExplicitTargets: 2,
skippedTargets: [],
});
});
});