mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-13 14:12:57 -06:00
fa03d9b913
* refactor: consolidate coercion helpers * fix: remove duplicate coercion imports * fix: preserve serialized coercion guard * chore: ratchet coercion helper carve-outs * fix(test): keep gauntlet subprocess startup lean * fix: preserve imported session timestamp semantics * fix: preserve catalog timestamp string semantics * chore: align plugin SDK surface ratchet * fix: preserve trajectory and SDK string contracts * fix(test): preserve QA record assertion semantics * fix: complete standalone record guard rename * refactor(cron): use canonical string coercion * fix(acpx): preserve Pi timestamp parsing * test(channels): adapt custody test harnesses * test(telegram): classify media harness as test support * test(acpx): split timestamp contract coverage * test(channels): support generated custody contracts * chore: ban the full coercion helper name set Extends the declaration guard to all eleven consolidated helper names and renames the cron schedule-identity readNumber wrapper to readScheduleInteger so the banned generic name cannot regrow. * fix(scripts): repair release-validation guard drift and lint cause Restores the renamed isJsonRecord guard in assertTrustedWorkflowHarness after main added isRecord call sites in parallel, and attaches the caught YAML error as the thrown error cause (preserve-caught-error was red on main). * fix: preserve Claude timestamp string semantics * fix: preserve persisted timestamp string semantics * fix: preserve date-first timestamp contracts * fix(openai): harden delegation failure formatting * chore: close coercion helper guard gaps * test(openai): model non-error delegation rejection * chore: refresh plugin SDK API contract * fix(tasks): use canonical string field reader * fix(ai): use canonical provider error field coercion * fix(browser): migrate native bootstrap coercion * docs(plugin-sdk): clarify text record export compatibility * fix(gateway): normalize approval execution identity * test(outbound): isolate message action poll harness
169 lines
5.6 KiB
TypeScript
169 lines
5.6 KiB
TypeScript
// Docker E2E CI helper.
|
|
// Converts scheduler JSON into GitHub Actions outputs and compact markdown
|
|
// summaries so the workflow does not duplicate Docker E2E planning logic.
|
|
import { asOptionalRecord } from "@openclaw/normalization-core/record-coerce";
|
|
import { readDockerE2eJsonArtifact } from "./lib/docker-e2e-json-artifacts.mts";
|
|
|
|
function recordOrEmpty(value: unknown) {
|
|
return asOptionalRecord(value) ?? {};
|
|
}
|
|
|
|
function recordArray(value: unknown) {
|
|
return Array.isArray(value) ? value.map(recordOrEmpty) : [];
|
|
}
|
|
|
|
function usage() {
|
|
return [
|
|
"Usage:",
|
|
" node scripts/docker-e2e.mjs github-outputs <plan.json>",
|
|
" node scripts/docker-e2e.mjs summary <summary.json> <title>",
|
|
" node scripts/docker-e2e.mjs failed-reruns <summary.json>",
|
|
].join("\n");
|
|
}
|
|
|
|
function boolOutput(value: unknown) {
|
|
return value ? "1" : "0";
|
|
}
|
|
|
|
function githubOutputs(value: unknown) {
|
|
const plan = recordOrEmpty(value);
|
|
const needs = recordOrEmpty(plan.needs);
|
|
const credentials = Array.isArray(plan.credentials)
|
|
? plan.credentials.filter(
|
|
(credential: unknown): credential is string => typeof credential === "string",
|
|
)
|
|
: [];
|
|
const requiredPackages: unknown[] = Array.isArray(plan.requiredPrepublishPluginPackages)
|
|
? plan.requiredPrepublishPluginPackages
|
|
: [];
|
|
return [
|
|
`credentials=${credentials.join(",")}`,
|
|
`needs_bare_image=${boolOutput(needs.bareImage)}`,
|
|
`needs_e2e_image=${boolOutput(needs.e2eImage)}`,
|
|
`needs_functional_image=${boolOutput(needs.functionalImage)}`,
|
|
`needs_live_image=${boolOutput(needs.liveImage)}`,
|
|
`needs_package=${boolOutput(needs.package)}`,
|
|
`needs_prepublish_plugin_registry=${boolOutput(needs.prepublishPluginRegistry)}`,
|
|
`required_prepublish_plugin_packages=${JSON.stringify(requiredPackages)}`,
|
|
];
|
|
}
|
|
|
|
function markdownCell(value: unknown) {
|
|
const text =
|
|
typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
? String(value)
|
|
: "";
|
|
return text.replaceAll("|", "\\|");
|
|
}
|
|
|
|
function inlineCode(value: unknown) {
|
|
const text =
|
|
typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
? String(value)
|
|
: "";
|
|
return `\`${text.replaceAll("`", "\\`")}\``;
|
|
}
|
|
|
|
function formatSeconds(value: unknown) {
|
|
const seconds = Number(value);
|
|
if (!Number.isFinite(seconds) || seconds < 0) {
|
|
return "";
|
|
}
|
|
const rounded = Math.round(seconds);
|
|
const minutes = Math.floor(rounded / 60);
|
|
const rest = rounded % 60;
|
|
return minutes > 0 ? `${minutes}m ${rest}s` : `${rest}s`;
|
|
}
|
|
|
|
function summaryMarkdown(value: unknown, title: string) {
|
|
const summary = recordOrEmpty(value);
|
|
const lanes = recordArray(summary.lanes);
|
|
const slowest = lanes
|
|
.filter((lane) => Number.isFinite(Number(lane.elapsedSeconds)))
|
|
.toSorted((a, b) => Number(b.elapsedSeconds) - Number(a.elapsedSeconds))
|
|
.slice(0, 8);
|
|
const lines = [
|
|
`### ${title}`,
|
|
"",
|
|
`Status: ${inlineCode(summary.status)}`,
|
|
"",
|
|
"| Lane | Status | Seconds | Timed out | Rerun |",
|
|
"| --- | ---: | ---: | --- | --- |",
|
|
];
|
|
for (const lane of lanes) {
|
|
const status = lane.status === 0 ? "pass" : `fail ${lane.status}`;
|
|
lines.push(
|
|
`| ${inlineCode(lane.name)} | ${markdownCell(status)} | ${markdownCell(lane.elapsedSeconds)} | ${lane.timedOut ? "yes" : "no"} | ${inlineCode(lane.rerunCommand)} |`,
|
|
);
|
|
}
|
|
|
|
if (slowest.length > 0) {
|
|
lines.push("", "| Slowest lane | Duration | Status |", "| --- | ---: | --- |");
|
|
for (const lane of slowest) {
|
|
const status = lane.status === 0 ? "pass" : `fail ${lane.status}`;
|
|
lines.push(
|
|
`| ${inlineCode(lane.name)} | ${markdownCell(formatSeconds(lane.elapsedSeconds))} | ${markdownCell(status)} |`,
|
|
);
|
|
}
|
|
}
|
|
|
|
const phases = recordArray(summary.phases);
|
|
if (phases.length > 0) {
|
|
lines.push("", "| Phase | Duration | Status | Image kind |", "| --- | ---: | --- | --- |");
|
|
for (const phase of phases) {
|
|
lines.push(
|
|
`| ${inlineCode(phase.name)} | ${markdownCell(formatSeconds(phase.elapsedSeconds))} | ${markdownCell(phase.status)} | ${markdownCell(phase.imageKind)} |`,
|
|
);
|
|
}
|
|
}
|
|
const failedReruns = failedRerunCommands(summary);
|
|
if (failedReruns.length > 0) {
|
|
lines.push("", "Failed lane reruns:", "");
|
|
for (const command of failedReruns) {
|
|
lines.push(`- ${inlineCode(command)}`);
|
|
}
|
|
}
|
|
return lines.join("\n");
|
|
}
|
|
|
|
function failedRerunCommands(value: unknown) {
|
|
const summary = recordOrEmpty(value);
|
|
const lanes = recordArray(summary.lanes);
|
|
return lanes.flatMap((lane) =>
|
|
lane.status !== 0 && lane.rerunCommand ? [String(lane.rerunCommand)] : [],
|
|
);
|
|
}
|
|
|
|
function main(argv: string[] = process.argv.slice(2)) {
|
|
const [command, file, ...args] = argv;
|
|
if (command === "--help" || command === "-h") {
|
|
process.stdout.write(`${usage()}\n`);
|
|
return 0;
|
|
}
|
|
if (!command || !file) {
|
|
throw new Error(usage());
|
|
}
|
|
|
|
if (command === "github-outputs") {
|
|
process.stdout.write(`${githubOutputs(readDockerE2eJsonArtifact(file)).join("\n")}\n`);
|
|
} else if (command === "summary") {
|
|
const title = args.join(" ").trim();
|
|
if (!title) {
|
|
throw new Error(usage());
|
|
}
|
|
process.stdout.write(`${summaryMarkdown(readDockerE2eJsonArtifact(file), title)}\n`);
|
|
} else if (command === "failed-reruns") {
|
|
process.stdout.write(`${failedRerunCommands(readDockerE2eJsonArtifact(file)).join("\n")}\n`);
|
|
} else {
|
|
throw new Error(`unknown command: ${command}\n${usage()}`);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
try {
|
|
process.exitCode = main();
|
|
} catch (error) {
|
|
console.error(error instanceof Error ? error.message : String(error));
|
|
process.exitCode = 1;
|
|
}
|