perf: split extension channel vitest lane

This commit is contained in:
Peter Steinberger
2026-04-04 02:05:37 +01:00
parent e941d425ac
commit 1e90b3afcd
7 changed files with 67 additions and 10 deletions

View File

@@ -14,6 +14,7 @@ const CHANNEL_VITEST_CONFIG = "vitest.channels.config.ts";
const COMMANDS_VITEST_CONFIG = "vitest.commands.config.ts";
const CONTRACTS_VITEST_CONFIG = "vitest.contracts.config.ts";
const E2E_VITEST_CONFIG = "vitest.e2e.config.ts";
const EXTENSION_CHANNELS_VITEST_CONFIG = "vitest.extension-channels.config.ts";
const EXTENSIONS_VITEST_CONFIG = "vitest.extensions.config.ts";
const GATEWAY_VITEST_CONFIG = "vitest.gateway.config.ts";
const UI_VITEST_CONFIG = "vitest.ui.config.ts";
@@ -76,7 +77,7 @@ function classifyTarget(arg, cwd) {
return "e2e";
}
if (relative.startsWith("extensions/")) {
return isChannelSurfaceTestFile(relative) ? "channel" : "extension";
return isChannelSurfaceTestFile(relative) ? "extensionChannel" : "extension";
}
if (isChannelSurfaceTestFile(relative)) {
return "channel";
@@ -191,6 +192,7 @@ export function buildVitestRunPlans(args, cwd = process.cwd()) {
"agent",
"ui",
"e2e",
"extensionChannel",
"channel",
"extension",
];
@@ -221,11 +223,13 @@ export function buildVitestRunPlans(args, cwd = process.cwd()) {
? UI_VITEST_CONFIG
: kind === "e2e"
? E2E_VITEST_CONFIG
: kind === "channel"
? CHANNEL_VITEST_CONFIG
: kind === "extension"
? EXTENSIONS_VITEST_CONFIG
: DEFAULT_VITEST_CONFIG;
: kind === "extensionChannel"
? EXTENSION_CHANNELS_VITEST_CONFIG
: kind === "channel"
? CHANNEL_VITEST_CONFIG
: kind === "extension"
? EXTENSIONS_VITEST_CONFIG
: DEFAULT_VITEST_CONFIG;
const includePatterns =
kind === "default" || kind === "e2e"
? null

View File

@@ -241,7 +241,7 @@ describe("test-projects args", () => {
buildVitestRunPlans(["extensions/discord/src/monitor/message-handler.preflight.test.ts"]),
).toEqual([
{
config: "vitest.channels.config.ts",
config: "vitest.extension-channels.config.ts",
forwardedArgs: [],
includePatterns: ["extensions/discord/src/monitor/message-handler.preflight.test.ts"],
watchMode: false,

View File

@@ -7,6 +7,7 @@ import { createAgentsVitestConfig } from "../vitest.agents.config.ts";
import { createAutoReplyVitestConfig } from "../vitest.auto-reply.config.ts";
import { createChannelsVitestConfig } from "../vitest.channels.config.ts";
import { createCommandsVitestConfig } from "../vitest.commands.config.ts";
import { createExtensionChannelsVitestConfig } from "../vitest.extension-channels.config.ts";
import { createExtensionsVitestConfig } from "../vitest.extensions.config.ts";
import { createGatewayVitestConfig } from "../vitest.gateway.config.ts";
import { createScopedVitestConfig, resolveVitestIsolation } from "../vitest.scoped-config.ts";
@@ -69,6 +70,7 @@ describe("scoped vitest configs", () => {
const defaultChannelsConfig = createChannelsVitestConfig({});
const defaultAcpConfig = createAcpVitestConfig({});
const defaultExtensionsConfig = createExtensionsVitestConfig({});
const defaultExtensionChannelsConfig = createExtensionChannelsVitestConfig({});
const defaultGatewayConfig = createGatewayVitestConfig({});
const defaultCommandsConfig = createCommandsVitestConfig({});
const defaultAutoReplyConfig = createAutoReplyVitestConfig({});
@@ -80,6 +82,13 @@ describe("scoped vitest configs", () => {
expect(defaultChannelsConfig.test?.pool).toBe("forks");
});
it("keeps the core channel lane limited to non-extension roots", () => {
expect(defaultChannelsConfig.test?.include).toEqual([
"src/browser/**/*.test.ts",
"src/line/**/*.test.ts",
]);
});
it("loads channel include overrides from OPENCLAW_VITEST_INCLUDE_FILE", () => {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-vitest-channels-"));
try {
@@ -112,6 +121,17 @@ describe("scoped vitest configs", () => {
expect(defaultExtensionsConfig.test?.pool).toBe("forks");
});
it("normalizes extension channel include patterns relative to the scoped dir", () => {
expect(defaultExtensionChannelsConfig.test?.dir).toBe("extensions");
expect(defaultExtensionChannelsConfig.test?.include).toEqual([
"discord/**/*.test.ts",
"whatsapp/**/*.test.ts",
"slack/**/*.test.ts",
"signal/**/*.test.ts",
"imessage/**/*.test.ts",
]);
});
it("normalizes extension include patterns relative to the scoped dir", () => {
expect(defaultExtensionsConfig.test?.dir).toBe("extensions");
expect(defaultExtensionsConfig.test?.include).toEqual(["**/*.test.ts"]);

View File

@@ -20,8 +20,18 @@ export const channelTestRoots = [
"src/line",
];
export const extensionChannelTestRoots = channelTestRoots.filter((root) =>
root.startsWith(BUNDLED_PLUGIN_PATH_PREFIX),
);
export const coreChannelTestRoots = channelTestRoots.filter(
(root) => !root.startsWith(BUNDLED_PLUGIN_PATH_PREFIX),
);
export const channelTestPrefixes = channelTestRoots.map((root) => `${root}/`);
export const channelTestInclude = channelTestRoots.map((root) => `${root}/**/*.test.ts`);
export const extensionChannelTestInclude = extensionChannelTestRoots.map(
(root) => `${root}/**/*.test.ts`,
);
export const coreChannelTestInclude = coreChannelTestRoots.map((root) => `${root}/**/*.test.ts`);
export const channelTestExclude = channelTestRoots.map((root) => `${root}/**`);
const extensionChannelRootOverrideBasenames = new Map();
@@ -53,6 +63,10 @@ export const extensionExcludedChannelTestGlobs = channelTestRoots
return `${relativeRoot}/**/!(${alternation}).test.ts`;
});
export const extensionChannelOverrideExcludeGlobs = extensionRoutedChannelTestFiles
.filter((file) => file.startsWith(BUNDLED_PLUGIN_PATH_PREFIX))
.map((file) => file.slice(BUNDLED_PLUGIN_PATH_PREFIX.length));
export function isChannelSurfaceTestFile(filePath) {
const normalizedFile = normalizeRepoPath(filePath);
return (

View File

@@ -1,4 +1,4 @@
import { channelTestInclude, extensionRoutedChannelTestFiles } from "./vitest.channel-paths.mjs";
import { coreChannelTestInclude } from "./vitest.channel-paths.mjs";
import { loadPatternListFromEnv } from "./vitest.pattern-file.ts";
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
@@ -9,9 +9,9 @@ export function loadIncludePatternsFromEnv(
}
export function createChannelsVitestConfig(env?: Record<string, string | undefined>) {
return createScopedVitestConfig(loadIncludePatternsFromEnv(env) ?? channelTestInclude, {
return createScopedVitestConfig(loadIncludePatternsFromEnv(env) ?? coreChannelTestInclude, {
env,
exclude: ["src/gateway/**", ...extensionRoutedChannelTestFiles],
exclude: ["src/gateway/**"],
passWithNoTests: true,
});
}

View File

@@ -0,0 +1,18 @@
import {
extensionChannelOverrideExcludeGlobs,
extensionChannelTestInclude,
} from "./vitest.channel-paths.mjs";
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
export function createExtensionChannelsVitestConfig(
env: Record<string, string | undefined> = process.env,
) {
return createScopedVitestConfig(extensionChannelTestInclude, {
dir: "extensions",
env,
exclude: extensionChannelOverrideExcludeGlobs,
passWithNoTests: true,
});
}
export default createExtensionChannelsVitestConfig();

View File

@@ -101,6 +101,7 @@ export const sharedVitestConfig = {
"vitest.config.ts",
"vitest.contracts.config.ts",
"vitest.e2e.config.ts",
"vitest.extension-channels.config.ts",
"vitest.extensions.config.ts",
"vitest.gateway.config.ts",
"vitest.live.config.ts",