fix(test): route release script owners

This commit is contained in:
Vincent Koc
2026-06-21 16:53:49 +02:00
parent 63fdc57b3a
commit 757ab933f4
4 changed files with 227 additions and 0 deletions
+12
View File
@@ -957,6 +957,18 @@ const TOOLING_SOURCE_TEST_TARGETS = new Map([
["test/scripts/openclaw-cross-os-release-workflow.test.ts"],
],
["scripts/lib/restart-mac-gateway.sh", ["test/scripts/restart-mac.test.ts"]],
[
"scripts/openclaw-release-clawhub-runtime-state.ts",
["test/scripts/openclaw-release-clawhub-runtime-state.test.ts"],
],
[
"scripts/plan-release-workflow-matrix.mjs",
["test/scripts/release-workflow-matrix-plan.test.ts"],
],
[
"scripts/plugin-release-pretag-pack-check.ts",
["test/scripts/plugin-release-pretag-pack-check.test.ts"],
],
[
"scripts/github/security-sensitive-guard.mjs",
[
@@ -0,0 +1,74 @@
// OpenClaw release ClawHub runtime-state script tests cover its CLI-only parser.
import { spawnSync } from "node:child_process";
import { describe, expect, it } from "vitest";
const SCRIPT_PATH = "scripts/openclaw-release-clawhub-runtime-state.ts";
function runRuntimeStateScript(args: string[]) {
return spawnSync(process.execPath, ["--import", "tsx", SCRIPT_PATH, ...args], {
cwd: process.cwd(),
encoding: "utf8",
});
}
describe("scripts/openclaw-release-clawhub-runtime-state.ts", () => {
it("emits verifier args and proof lines for awaited ClawHub runs", () => {
const result = runRuntimeStateScript([
"--repository",
"openclaw/openclaw",
"--wait-for-clawhub",
"true",
"--force-skip-clawhub",
"false",
"--normal-run-id",
"123",
"--bootstrap-run-id",
"456",
"--bootstrap-completed",
"true",
]);
expect(result.status).toBe(0);
expect(JSON.parse(result.stdout)).toEqual({
verifierArgs: ["--plugin-clawhub-run", "123", "--plugin-clawhub-bootstrap-run", "456"],
proofLines: {
normal: "- plugin ClawHub publish: https://github.com/openclaw/openclaw/actions/runs/123",
bootstrap:
"- plugin ClawHub bootstrap: https://github.com/openclaw/openclaw/actions/runs/456",
},
});
expect(result.stderr).toBe("");
});
it("rejects invalid boolean flag values before emitting runtime state", () => {
const result = runRuntimeStateScript([
"--repository",
"openclaw/openclaw",
"--wait-for-clawhub",
"yes",
"--force-skip-clawhub",
"false",
"--bootstrap-completed",
"false",
]);
expect(result.status).toBe(1);
expect(result.stderr).toContain("--wait-for-clawhub must be true or false.");
expect(result.stdout).toBe("");
});
it("requires the workflow repository argument", () => {
const result = runRuntimeStateScript([
"--wait-for-clawhub",
"true",
"--force-skip-clawhub",
"false",
"--bootstrap-completed",
"false",
]);
expect(result.status).toBe(1);
expect(result.stderr).toContain("--repository is required.");
expect(result.stdout).toBe("");
});
});
@@ -0,0 +1,129 @@
// Plugin release pretag pack check tests cover its script-local target and command routing.
import { mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import { OPENCLAW_PLUGIN_NPM_REPOSITORY_URL } from "../../scripts/lib/plugin-npm-release.ts";
import {
collectPluginReleasePretagPackTargets,
runPluginReleasePretagPackCheck,
} from "../../scripts/plugin-release-pretag-pack-check.ts";
import { cleanupTempDirs, makeTempRepoRoot, writeJsonFile } from "../helpers/temp-repo.js";
const { execFileSyncMock } = vi.hoisted(() => ({
execFileSyncMock: vi.fn(),
}));
vi.mock("node:child_process", async () => {
const actual = await vi.importActual<typeof import("node:child_process")>("node:child_process");
return {
...actual,
execFileSync: execFileSyncMock,
};
});
const tempDirs: string[] = [];
type ExecOptions = {
cwd?: string;
env?: NodeJS.ProcessEnv;
stdio?: unknown;
};
afterEach(() => {
cleanupTempDirs(tempDirs);
execFileSyncMock.mockReset();
});
function createDualPublishPluginRepo() {
const repoDir = makeTempRepoRoot(tempDirs, "openclaw-plugin-pretag-pack-");
const packageDir = join(repoDir, "extensions", "demo-plugin");
mkdirSync(packageDir, { recursive: true });
writeJsonFile(join(repoDir, "package.json"), { name: "openclaw-test-root", type: "module" });
writeJsonFile(join(packageDir, "package.json"), {
name: "@openclaw/demo-plugin",
version: "2026.4.10",
type: "module",
repository: {
type: "git",
url: OPENCLAW_PLUGIN_NPM_REPOSITORY_URL,
},
openclaw: {
extensions: ["./index.ts"],
compat: {
pluginApi: ">=2026.4.10",
},
build: {
openclawVersion: "2026.4.10",
},
install: {
npmSpec: "@openclaw/demo-plugin",
},
release: {
publishToClawHub: true,
publishToNpm: true,
},
},
});
writeFileSync(join(packageDir, "README.md"), "# Demo plugin\n");
writeFileSync(join(packageDir, "index.ts"), "export const demo = 1;\n");
return repoDir;
}
function callOptions(index: number): ExecOptions {
return execFileSyncMock.mock.calls[index]?.[2] as ExecOptions;
}
describe("scripts/plugin-release-pretag-pack-check.ts", () => {
it("collects dual-published plugin targets for npm and ClawHub pack checks", () => {
const repoDir = createDualPublishPluginRepo();
expect(collectPluginReleasePretagPackTargets(repoDir)).toEqual([
{
packageDir: "extensions/demo-plugin",
packageName: "@openclaw/demo-plugin",
packClawHub: true,
packNpm: true,
},
]);
});
it("runs runtime build, npm pack, and ClawHub pack commands for selected targets", () => {
const repoDir = createDualPublishPluginRepo();
execFileSyncMock.mockImplementation(() => "");
runPluginReleasePretagPackCheck(repoDir);
expect(execFileSyncMock).toHaveBeenCalledTimes(3);
expect(execFileSyncMock.mock.calls[0]?.slice(0, 2)).toEqual([
process.execPath,
[
"scripts/check-plugin-npm-runtime-builds.mjs",
"--package",
"extensions/demo-plugin",
],
]);
expect(callOptions(0)).toMatchObject({ cwd: repoDir, stdio: "inherit" });
expect(execFileSyncMock.mock.calls[1]?.slice(0, 2)).toEqual([
"bash",
["scripts/plugin-npm-publish.sh", "--pack-dry-run", "extensions/demo-plugin"],
]);
expect(callOptions(1)).toMatchObject({
cwd: repoDir,
env: { OPENCLAW_PLUGIN_NPM_RUNTIME_BUILD: "0" },
stdio: ["inherit", "ignore", "inherit"],
});
expect(execFileSyncMock.mock.calls[2]?.slice(0, 2)).toEqual([
"bash",
["scripts/plugin-clawhub-publish.sh", "--pack", "extensions/demo-plugin"],
]);
expect(callOptions(2)).toMatchObject({
cwd: repoDir,
env: { OPENCLAW_PLUGIN_NPM_RUNTIME_BUILD: "0" },
stdio: ["inherit", "ignore", "inherit"],
});
expect(callOptions(2).env?.OPENCLAW_CLAWHUB_PACK_OUTPUT_DIR).toContain("clawhub-0");
});
});
+12
View File
@@ -1927,6 +1927,10 @@ describe("scripts/test-projects changed-target routing", () => {
"scripts/lib/workspace-bootstrap-smoke.mjs",
["test/release-check.test.ts", "test/openclaw-npm-release-check.test.ts"],
],
[
"scripts/openclaw-release-clawhub-runtime-state.ts",
["test/scripts/openclaw-release-clawhub-runtime-state.test.ts"],
],
["scripts/lib/openclaw-release-clawhub-plan.ts", ["test/plugin-clawhub-release.test.ts"]],
[
"scripts/lib/plugin-clawhub-release.ts",
@@ -1936,6 +1940,14 @@ describe("scripts/test-projects changed-target routing", () => {
"scripts/lib/plugin-npm-release.ts",
["test/plugin-npm-release.test.ts", "test/plugin-clawhub-release.test.ts"],
],
[
"scripts/plugin-release-pretag-pack-check.ts",
["test/scripts/plugin-release-pretag-pack-check.test.ts"],
],
[
"scripts/plan-release-workflow-matrix.mjs",
["test/scripts/release-workflow-matrix-plan.test.ts"],
],
[
"scripts/lib/plugin-npm-runtime-assets.mjs",
["test/scripts/plugin-npm-runtime-build-args.test.ts"],