Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
208 lines
5.5 KiB
JavaScript
208 lines
5.5 KiB
JavaScript
// Assertions for Bun global install E2E validation.
|
|
import { spawn } from "node:child_process";
|
|
|
|
const DEFAULT_TIMEOUT_KILL_GRACE_MS = 30_000;
|
|
const PARENT_TERMINATION_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
|
|
const usage = () => {
|
|
console.error("Usage: assertions.mjs <run-with-timeout|assert-image-providers> [...]");
|
|
process.exit(2);
|
|
};
|
|
|
|
const [mode, ...args] = process.argv.slice(2);
|
|
|
|
const parsePositiveNumber = (value, label) => {
|
|
const parsed = Number(value);
|
|
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
throw new Error(`${label} must be a positive number`);
|
|
}
|
|
return parsed;
|
|
};
|
|
|
|
const signalChild = (child, signal) => {
|
|
if (!child.pid) {
|
|
return;
|
|
}
|
|
try {
|
|
if (process.platform === "win32") {
|
|
child.kill(signal);
|
|
return;
|
|
}
|
|
process.kill(-child.pid, signal);
|
|
} catch (error) {
|
|
if (error?.code !== "ESRCH") {
|
|
throw error;
|
|
}
|
|
}
|
|
};
|
|
|
|
const processGroupAlive = (child) => {
|
|
if (process.platform === "win32" || !child.pid) {
|
|
return false;
|
|
}
|
|
try {
|
|
process.kill(-child.pid, 0);
|
|
return true;
|
|
} catch (error) {
|
|
return error?.code === "EPERM";
|
|
}
|
|
};
|
|
|
|
const waitForProcessGroupExit = async (child, timeout) => {
|
|
const deadlineAt = Date.now() + timeout;
|
|
while (Date.now() < deadlineAt) {
|
|
if (!processGroupAlive(child)) {
|
|
return true;
|
|
}
|
|
await new Promise((resolve) => {
|
|
setTimeout(resolve, 25);
|
|
});
|
|
}
|
|
return !processGroupAlive(child);
|
|
};
|
|
|
|
const resolveSignalExitCode = (signal) => {
|
|
switch (signal) {
|
|
case "SIGINT":
|
|
return 130;
|
|
case "SIGHUP":
|
|
return 129;
|
|
default:
|
|
return 143;
|
|
}
|
|
};
|
|
|
|
const runWithTimeout = async (timeout, command, commandArgs) => {
|
|
const killGrace = parsePositiveNumber(
|
|
process.env.OPENCLAW_BUN_GLOBAL_SMOKE_TIMEOUT_KILL_GRACE_MS ??
|
|
String(DEFAULT_TIMEOUT_KILL_GRACE_MS),
|
|
"OPENCLAW_BUN_GLOBAL_SMOKE_TIMEOUT_KILL_GRACE_MS",
|
|
);
|
|
const child = spawn(command, commandArgs, {
|
|
detached: process.platform !== "win32",
|
|
env: process.env,
|
|
stdio: ["ignore", "pipe", "pipe"],
|
|
});
|
|
let timedOut = false;
|
|
let parentSignal = null;
|
|
let killTimer;
|
|
let killDeadlineAt = 0;
|
|
const scheduleForceKill = () => {
|
|
killDeadlineAt = Date.now() + killGrace;
|
|
killTimer ??= setTimeout(() => signalChild(child, "SIGKILL"), killGrace);
|
|
killTimer.unref();
|
|
};
|
|
|
|
child.stdout.setEncoding("utf8");
|
|
child.stderr.setEncoding("utf8");
|
|
child.stdout.on("data", (chunk) => process.stdout.write(chunk));
|
|
child.stderr.on("data", (chunk) => process.stderr.write(chunk));
|
|
|
|
const timeoutTimer = setTimeout(() => {
|
|
timedOut = true;
|
|
signalChild(child, "SIGTERM");
|
|
scheduleForceKill();
|
|
}, timeout);
|
|
timeoutTimer.unref();
|
|
|
|
const parentSignalHandlers = new Map(
|
|
PARENT_TERMINATION_SIGNALS.map((signal) => [
|
|
signal,
|
|
() => {
|
|
parentSignal ??= signal;
|
|
signalChild(child, signal);
|
|
scheduleForceKill();
|
|
},
|
|
]),
|
|
);
|
|
for (const [signal, handler] of parentSignalHandlers) {
|
|
process.on(signal, handler);
|
|
}
|
|
const cleanupParentSignalHandlers = () => {
|
|
for (const [signal, handler] of parentSignalHandlers) {
|
|
process.off(signal, handler);
|
|
}
|
|
};
|
|
|
|
let spawnError;
|
|
child.on("error", (error) => {
|
|
spawnError = error;
|
|
});
|
|
const result = await new Promise((resolve) => {
|
|
child.on("close", (status, signal) => resolve({ error: spawnError, signal, status }));
|
|
});
|
|
|
|
clearTimeout(timeoutTimer);
|
|
cleanupParentSignalHandlers();
|
|
if (timedOut || parentSignal) {
|
|
const remainingGraceMs = Math.max(0, killDeadlineAt - Date.now());
|
|
if (remainingGraceMs > 0) {
|
|
await waitForProcessGroupExit(child, remainingGraceMs);
|
|
}
|
|
if (processGroupAlive(child)) {
|
|
signalChild(child, "SIGKILL");
|
|
await waitForProcessGroupExit(child, 100);
|
|
}
|
|
clearTimeout(killTimer);
|
|
}
|
|
if (parentSignal) {
|
|
process.exit(resolveSignalExitCode(parentSignal));
|
|
}
|
|
if (timedOut) {
|
|
console.error(`command timed out after ${timeout}ms: ${command}`);
|
|
process.exit(1);
|
|
}
|
|
clearTimeout(killTimer);
|
|
if (result.error) {
|
|
console.error(`command failed: ${command}: ${result.error.message}`);
|
|
process.exit(1);
|
|
}
|
|
if (result.signal) {
|
|
console.error(`command terminated: ${command}: ${result.signal}`);
|
|
process.exit(1);
|
|
}
|
|
process.exit(result.status ?? 0);
|
|
};
|
|
|
|
if (mode === "run-with-timeout") {
|
|
const [timeoutMs, command, ...commandArgs] = args;
|
|
if (!command) {
|
|
usage();
|
|
}
|
|
let timeout;
|
|
try {
|
|
timeout = parsePositiveNumber(timeoutMs, "timeoutMs");
|
|
} catch {
|
|
usage();
|
|
}
|
|
await runWithTimeout(timeout, command, commandArgs);
|
|
}
|
|
|
|
if (mode === "assert-image-providers") {
|
|
const raw = process.env.OPENCLAW_IMAGE_PROVIDERS_JSON ?? "";
|
|
let parsed;
|
|
try {
|
|
parsed = JSON.parse(raw);
|
|
} catch (error) {
|
|
console.error(raw);
|
|
const message = error instanceof Error ? error.message : String(error);
|
|
throw new Error(`image providers output is not JSON: ${message}`, { cause: error });
|
|
}
|
|
if (!Array.isArray(parsed)) {
|
|
throw new Error("image providers output must be a JSON array");
|
|
}
|
|
if (parsed.length === 0) {
|
|
throw new Error("image providers output is empty");
|
|
}
|
|
const ids = new Set(parsed.map((entry) => (typeof entry?.id === "string" ? entry.id : "")));
|
|
for (const expected of ["google", "openai", "xai"]) {
|
|
if (!ids.has(expected)) {
|
|
throw new Error(`image providers output is missing bundled provider '${expected}'`);
|
|
}
|
|
}
|
|
console.log(`bun-global-install-smoke: image providers OK (${parsed.length} providers)`);
|
|
process.exit(0);
|
|
}
|
|
|
|
usage();
|