mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-26 08:31:55 +00:00
refactor(plugins): decouple bundled plugin runtime loading
This commit is contained in:
@@ -77,7 +77,7 @@ describe("check-no-conflict-markers", () => {
|
||||
git(rootDir, "config", "user.email", "test@example.com");
|
||||
git(rootDir, "config", "user.name", "Test User");
|
||||
|
||||
const scriptFile = path.join(rootDir, "scripts", "generate-bundled-plugin-metadata.mjs");
|
||||
const scriptFile = path.join(rootDir, "scripts", "bundled-plugin-metadata-runtime.mjs");
|
||||
fs.mkdirSync(path.dirname(scriptFile), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
scriptFile,
|
||||
@@ -89,7 +89,7 @@ describe("check-no-conflict-markers", () => {
|
||||
">>>>>>> branch",
|
||||
].join("\n"),
|
||||
);
|
||||
git(rootDir, "add", "scripts/generate-bundled-plugin-metadata.mjs");
|
||||
git(rootDir, "add", "scripts/bundled-plugin-metadata-runtime.mjs");
|
||||
|
||||
const violations = findConflictMarkersInFiles(listTrackedFiles(rootDir));
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
partitionExtensionTestFiles,
|
||||
resolveExtensionTestPlan,
|
||||
} from "../../scripts/test-extension.mjs";
|
||||
import { bundledPluginFile, bundledPluginRoot } from "../helpers/bundled-plugin-paths.js";
|
||||
|
||||
const scriptPath = path.join(process.cwd(), "scripts", "test-extension.mjs");
|
||||
|
||||
@@ -41,18 +42,24 @@ describe("scripts/test-extension.mjs", () => {
|
||||
const plan = resolveExtensionTestPlan({ targetArg: "slack", cwd: process.cwd() });
|
||||
|
||||
expect(plan.extensionId).toBe("slack");
|
||||
expect(plan.extensionDir).toBe("extensions/slack");
|
||||
expect(plan.extensionDir).toBe(bundledPluginRoot("slack"));
|
||||
expect(plan.config).toBe("vitest.channels.config.ts");
|
||||
expect(plan.testFiles.some((file) => file.startsWith("extensions/slack/"))).toBe(true);
|
||||
expect(plan.testFiles.some((file) => file.startsWith(`${bundledPluginRoot("slack")}/`))).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("splits channel monitor files into isolated runs", () => {
|
||||
const plan = resolveExtensionTestPlan({ targetArg: "discord", cwd: process.cwd() });
|
||||
|
||||
expect(plan.config).toBe("vitest.channels.config.ts");
|
||||
expect(plan.isolatedTestFiles).toContain("extensions/discord/src/monitor/provider.test.ts");
|
||||
expect(plan.sharedTestFiles).toContain("extensions/discord/src/channel.test.ts");
|
||||
expect(plan.sharedTestFiles).not.toContain("extensions/discord/src/monitor/provider.test.ts");
|
||||
expect(plan.isolatedTestFiles).toContain(
|
||||
bundledPluginFile("discord", "src/monitor/provider.test.ts"),
|
||||
);
|
||||
expect(plan.sharedTestFiles).toContain(bundledPluginFile("discord", "src/channel.test.ts"));
|
||||
expect(plan.sharedTestFiles).not.toContain(
|
||||
bundledPluginFile("discord", "src/monitor/provider.test.ts"),
|
||||
);
|
||||
});
|
||||
|
||||
it("resolves provider extensions onto the extensions vitest config", () => {
|
||||
@@ -60,28 +67,34 @@ describe("scripts/test-extension.mjs", () => {
|
||||
|
||||
expect(plan.extensionId).toBe("firecrawl");
|
||||
expect(plan.config).toBe("vitest.extensions.config.ts");
|
||||
expect(plan.testFiles.some((file) => file.startsWith("extensions/firecrawl/"))).toBe(true);
|
||||
expect(
|
||||
plan.testFiles.some((file) => file.startsWith(`${bundledPluginRoot("firecrawl")}/`)),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("applies exact isolated files for non-channel extensions", () => {
|
||||
const { isolatedTestFiles, sharedTestFiles } = partitionExtensionTestFiles({
|
||||
config: "vitest.extensions.config.ts",
|
||||
testFiles: [
|
||||
"extensions/firecrawl/src/firecrawl-scrape-tool.test.ts",
|
||||
"extensions/firecrawl/src/index.test.ts",
|
||||
bundledPluginFile("firecrawl", "src/firecrawl-scrape-tool.test.ts"),
|
||||
bundledPluginFile("firecrawl", "src/index.test.ts"),
|
||||
],
|
||||
});
|
||||
|
||||
expect(isolatedTestFiles).toEqual(["extensions/firecrawl/src/firecrawl-scrape-tool.test.ts"]);
|
||||
expect(sharedTestFiles).toEqual(["extensions/firecrawl/src/index.test.ts"]);
|
||||
expect(isolatedTestFiles).toEqual([
|
||||
bundledPluginFile("firecrawl", "src/firecrawl-scrape-tool.test.ts"),
|
||||
]);
|
||||
expect(sharedTestFiles).toEqual([bundledPluginFile("firecrawl", "src/index.test.ts")]);
|
||||
});
|
||||
|
||||
it("includes paired src roots when they contain tests", () => {
|
||||
const plan = resolveExtensionTestPlan({ targetArg: "line", cwd: process.cwd() });
|
||||
|
||||
expect(plan.roots).toContain("extensions/line");
|
||||
expect(plan.roots).toContain(bundledPluginRoot("line"));
|
||||
expect(plan.config).toBe("vitest.extensions.config.ts");
|
||||
expect(plan.testFiles.some((file) => file.startsWith("extensions/line/"))).toBe(true);
|
||||
expect(plan.testFiles.some((file) => file.startsWith(`${bundledPluginRoot("line")}/`))).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("infers the extension from the current working directory", () => {
|
||||
@@ -89,14 +102,14 @@ describe("scripts/test-extension.mjs", () => {
|
||||
const plan = readPlan([], cwd);
|
||||
|
||||
expect(plan.extensionId).toBe("slack");
|
||||
expect(plan.extensionDir).toBe("extensions/slack");
|
||||
expect(plan.extensionDir).toBe(bundledPluginRoot("slack"));
|
||||
});
|
||||
|
||||
it("maps changed paths back to extension ids", () => {
|
||||
const extensionIds = detectChangedExtensionIds([
|
||||
"extensions/slack/src/channel.ts",
|
||||
bundledPluginFile("slack", "src/channel.ts"),
|
||||
"src/line/message.test.ts",
|
||||
"extensions/firecrawl/package.json",
|
||||
bundledPluginFile("firecrawl", "package.json"),
|
||||
"src/not-a-plugin/file.ts",
|
||||
]);
|
||||
|
||||
@@ -134,7 +147,7 @@ describe("scripts/test-extension.mjs", () => {
|
||||
const extensionId = findExtensionWithoutTests();
|
||||
const stdout = runScript([extensionId]);
|
||||
|
||||
expect(stdout).toContain(`No tests found for extensions/${extensionId}.`);
|
||||
expect(stdout).toContain(`No tests found for ${bundledPluginRoot(extensionId)}.`);
|
||||
expect(stdout).toContain("Skipping.");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
resolveTestRunExitCode,
|
||||
} from "../../scripts/test-parallel-utils.mjs";
|
||||
import { loadTestCatalog } from "../../scripts/test-planner/catalog.mjs";
|
||||
import { bundledPluginFile } from "../helpers/bundled-plugin-paths.js";
|
||||
|
||||
const clearPlannerShardEnv = (env) => {
|
||||
const nextEnv = { ...env };
|
||||
@@ -54,10 +55,10 @@ const sharedTargetedUnitProxyFiles = (() => {
|
||||
|
||||
const targetedChannelProxyFiles = [
|
||||
...sharedTargetedChannelProxyFiles,
|
||||
"extensions/discord/src/monitor/message-handler.preflight.acp-bindings.test.ts",
|
||||
"extensions/discord/src/monitor/monitor.agent-components.test.ts",
|
||||
"extensions/telegram/src/bot.create-telegram-bot.test.ts",
|
||||
"extensions/whatsapp/src/monitor-inbox.streams-inbound-messages.test.ts",
|
||||
bundledPluginFile("discord", "src/monitor/message-handler.preflight.acp-bindings.test.ts"),
|
||||
bundledPluginFile("discord", "src/monitor/monitor.agent-components.test.ts"),
|
||||
bundledPluginFile("telegram", "src/bot.create-telegram-bot.test.ts"),
|
||||
bundledPluginFile("whatsapp", "src/monitor-inbox.streams-inbound-messages.test.ts"),
|
||||
];
|
||||
|
||||
const targetedUnitProxyFiles = [
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
buildExecutionPlan,
|
||||
explainExecutionTarget,
|
||||
} from "../../scripts/test-planner/planner.mjs";
|
||||
import { bundledPluginFile } from "../helpers/bundled-plugin-paths.js";
|
||||
|
||||
describe("test planner", () => {
|
||||
it("builds a capability-aware plan for mid-memory local runs", () => {
|
||||
@@ -195,7 +196,10 @@ describe("test planner", () => {
|
||||
surfaces: [],
|
||||
passthroughArgs: [
|
||||
"src/auto-reply/reply/followup-runner.test.ts",
|
||||
"extensions/discord/src/monitor/message-handler.preflight.acp-bindings.test.ts",
|
||||
bundledPluginFile(
|
||||
"discord",
|
||||
"src/monitor/message-handler.preflight.acp-bindings.test.ts",
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user