test: baseline bundled runtime sidecar paths

This commit is contained in:
Peter Steinberger 2026-04-03 14:25:54 +01:00
parent 8fabfa5d1c
commit bb25a8050c
No known key found for this signature in database
12 changed files with 154 additions and 21 deletions

View File

@ -1041,6 +1041,8 @@
"release:openclaw:npm:verify-published": "node --import tsx scripts/openclaw-npm-postpublish-verify.ts",
"release:plugins:npm:check": "node --import tsx scripts/plugin-npm-release-check.ts",
"release:plugins:npm:plan": "node --import tsx scripts/plugin-npm-release-plan.ts",
"runtime-sidecars:check": "node --import tsx scripts/generate-runtime-sidecar-paths-baseline.ts --check",
"runtime-sidecars:gen": "node --import tsx scripts/generate-runtime-sidecar-paths-baseline.ts --write",
"stage:bundled-plugin-runtime-deps": "node scripts/stage-bundled-plugin-runtime-deps.mjs",
"start": "node scripts/run-node.mjs",
"test": "node scripts/test-projects.mjs",

View File

@ -0,0 +1,35 @@
#!/usr/bin/env node
import path from "node:path";
import { writeBundledRuntimeSidecarPathBaseline } from "../src/plugins/runtime-sidecar-paths-baseline.js";
const args = new Set(process.argv.slice(2));
const checkOnly = args.has("--check");
const writeMode = args.has("--write");
if (checkOnly === writeMode) {
console.error("Use exactly one of --check or --write.");
process.exit(1);
}
const repoRoot = process.cwd();
const result = await writeBundledRuntimeSidecarPathBaseline({
repoRoot,
check: checkOnly,
});
if (checkOnly) {
if (result.changed) {
console.error(
[
"Bundled runtime sidecar path baseline drift detected.",
`Expected current: ${path.relative(repoRoot, result.jsonPath)}`,
"If this bundled plugin runtime-sidecar change is intentional, run `pnpm runtime-sidecars:gen` and commit the updated baseline file.",
"If not intentional, fix the bundled plugin metadata/public surface drift first.",
].join("\n"),
);
process.exit(1);
}
console.log(`OK ${path.relative(repoRoot, result.jsonPath)}`);
} else {
console.log(`Wrote ${path.relative(repoRoot, result.jsonPath)}`);
}

View File

@ -0,0 +1,36 @@
[
"dist/extensions/acpx/runtime-api.js",
"dist/extensions/bluebubbles/runtime-api.js",
"dist/extensions/browser/runtime-api.js",
"dist/extensions/copilot-proxy/runtime-api.js",
"dist/extensions/diffs/runtime-api.js",
"dist/extensions/discord/runtime-api.js",
"dist/extensions/feishu/runtime-api.js",
"dist/extensions/google/runtime-api.js",
"dist/extensions/googlechat/runtime-api.js",
"dist/extensions/imessage/runtime-api.js",
"dist/extensions/line/runtime-api.js",
"dist/extensions/lobster/runtime-api.js",
"dist/extensions/matrix/helper-api.js",
"dist/extensions/matrix/runtime-api.js",
"dist/extensions/matrix/thread-bindings-runtime.js",
"dist/extensions/mattermost/runtime-api.js",
"dist/extensions/memory-core/runtime-api.js",
"dist/extensions/msteams/runtime-api.js",
"dist/extensions/nextcloud-talk/runtime-api.js",
"dist/extensions/nostr/runtime-api.js",
"dist/extensions/ollama/runtime-api.js",
"dist/extensions/open-prose/runtime-api.js",
"dist/extensions/qqbot/runtime-api.js",
"dist/extensions/signal/runtime-api.js",
"dist/extensions/slack/runtime-api.js",
"dist/extensions/telegram/runtime-api.js",
"dist/extensions/tlon/runtime-api.js",
"dist/extensions/twitch/runtime-api.js",
"dist/extensions/voice-call/runtime-api.js",
"dist/extensions/whatsapp/light-runtime-api.js",
"dist/extensions/whatsapp/runtime-api.js",
"dist/extensions/zai/runtime-api.js",
"dist/extensions/zalo/runtime-api.js",
"dist/extensions/zalouser/runtime-api.js"
]

View File

@ -5,7 +5,7 @@ import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { pathToFileURL } from "node:url";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../src/plugins/public-artifacts.ts";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../src/plugins/runtime-sidecar-paths.ts";
import { parseReleaseVersion, resolveNpmCommandInvocation } from "./openclaw-npm-release-check.ts";
type InstalledPackageJson = {

View File

@ -3,7 +3,7 @@ import os from "node:os";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { bundledDistPluginFile } from "../../test/helpers/bundled-plugin-paths.js";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../plugins/public-artifacts.js";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../plugins/runtime-sidecar-paths.js";
import { captureEnv } from "../test-utils/env.js";
import {
canResolveRegistryVersionForPackageTarget,

View File

@ -1,7 +1,7 @@
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../plugins/public-artifacts.js";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../plugins/runtime-sidecar-paths.js";
import { pathExists } from "../utils.js";
import { readPackageVersion } from "./package-json.js";
import { applyPathPrepend } from "./path-prepend.js";

View File

@ -3,7 +3,7 @@ import os from "node:os";
import path from "node:path";
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { bundledDistPluginFile } from "../../test/helpers/bundled-plugin-paths.js";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../plugins/public-artifacts.js";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../plugins/runtime-sidecar-paths.js";
import { withEnvAsync } from "../test-utils/env.js";
import { pathExists } from "../utils.js";
import { resolveStableNodePath } from "./stable-node-path.js";

View File

@ -12,6 +12,8 @@ import {
pluginTestRepoRoot as repoRoot,
writeJson,
} from "./generated-plugin-test-helpers.js";
import { collectBundledRuntimeSidecarPaths } from "./runtime-sidecar-paths-baseline.js";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "./runtime-sidecar-paths.js";
const BUNDLED_PLUGIN_METADATA_TEST_TIMEOUT_MS = 300_000;
@ -59,6 +61,16 @@ describe("bundled plugin metadata", () => {
},
);
it(
"matches the checked-in runtime sidecar path baseline",
{ timeout: BUNDLED_PLUGIN_METADATA_TEST_TIMEOUT_MS },
() => {
expect(BUNDLED_RUNTIME_SIDECAR_PATHS).toEqual(
collectBundledRuntimeSidecarPaths({ rootDir: repoRoot }),
);
},
);
it("captures setup-entry metadata for bundled channel plugins", () => {
const discord = listBundledPluginMetadata().find((entry) => entry.dirName === "discord");
expect(discord?.source).toEqual({ source: "./index.ts", built: "index.js" });

View File

@ -1,4 +1,4 @@
import { listBundledPluginMetadata } from "./bundled-plugin-metadata.js";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "./runtime-sidecar-paths.js";
function assertUniqueValues<T extends string>(values: readonly T[], label: string): readonly T[] {
const seen = new Set<string>();
@ -20,21 +20,6 @@ export function getPublicArtifactBasename(relativePath: string): string {
return relativePath.split("/").at(-1) ?? relativePath;
}
function buildBundledDistArtifactPath(dirName: string, artifact: string): string {
return ["dist", "extensions", dirName, artifact].join("/");
}
export const BUNDLED_RUNTIME_SIDECAR_PATHS = assertUniqueValues(
listBundledPluginMetadata()
.flatMap((entry) =>
(entry.runtimeSidecarArtifacts ?? []).map((artifact) =>
buildBundledDistArtifactPath(entry.dirName, artifact),
),
)
.toSorted((left, right) => left.localeCompare(right)),
"bundled runtime sidecar path",
);
const EXTRA_GUARDED_EXTENSION_PUBLIC_SURFACE_BASENAMES = assertUniqueValues(
[
"action-runtime.runtime.js",

View File

@ -0,0 +1,41 @@
import fs from "node:fs";
import path from "node:path";
import { listBundledPluginMetadata } from "./bundled-plugin-metadata.js";
function buildBundledDistArtifactPath(dirName: string, artifact: string): string {
return ["dist", "extensions", dirName, artifact].join("/");
}
export function collectBundledRuntimeSidecarPaths(params?: {
rootDir?: string;
}): readonly string[] {
return listBundledPluginMetadata(params)
.flatMap((entry) =>
(entry.runtimeSidecarArtifacts ?? []).map((artifact) =>
buildBundledDistArtifactPath(entry.dirName, artifact),
),
)
.toSorted((left, right) => left.localeCompare(right));
}
export async function writeBundledRuntimeSidecarPathBaseline(params: {
repoRoot: string;
check: boolean;
}): Promise<{ changed: boolean; jsonPath: string }> {
const jsonPath = path.join(
params.repoRoot,
"scripts",
"lib",
"bundled-runtime-sidecar-paths.json",
);
const expectedJson = `${JSON.stringify(collectBundledRuntimeSidecarPaths(), null, 2)}\n`;
const currentJson = fs.existsSync(jsonPath) ? fs.readFileSync(jsonPath, "utf8") : "";
const changed = currentJson !== expectedJson;
if (!params.check && changed) {
fs.mkdirSync(path.dirname(jsonPath), { recursive: true });
fs.writeFileSync(jsonPath, expectedJson, "utf8");
}
return { changed, jsonPath };
}

View File

@ -0,0 +1,22 @@
import bundledRuntimeSidecarPaths from "../../scripts/lib/bundled-runtime-sidecar-paths.json" with { type: "json" };
function assertUniqueValues<T extends string>(values: readonly T[], label: string): readonly T[] {
const seen = new Set<string>();
const duplicates = new Set<string>();
for (const value of values) {
if (seen.has(value)) {
duplicates.add(value);
continue;
}
seen.add(value);
}
if (duplicates.size > 0) {
throw new Error(`Duplicate ${label}: ${Array.from(duplicates).join(", ")}`);
}
return values;
}
export const BUNDLED_RUNTIME_SIDECAR_PATHS = assertUniqueValues(
bundledRuntimeSidecarPaths,
"bundled runtime sidecar path",
);

View File

@ -3,7 +3,7 @@ import {
buildPublishedInstallScenarios,
collectInstalledPackageErrors,
} from "../scripts/openclaw-npm-postpublish-verify.ts";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../src/plugins/public-artifacts.ts";
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../src/plugins/runtime-sidecar-paths.ts";
describe("buildPublishedInstallScenarios", () => {
it("uses a single fresh scenario for plain stable releases", () => {