mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:30:42 +00:00
ci: bound release package tarball checks
This commit is contained in:
@@ -39,16 +39,33 @@ function parseArgs(argv) {
|
||||
return options;
|
||||
}
|
||||
|
||||
function run(command, args, cwd) {
|
||||
function run(command, args, cwd, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(command, args, {
|
||||
cwd,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
let timedOut = false;
|
||||
const timeout =
|
||||
options.timeoutMs === undefined
|
||||
? undefined
|
||||
: setTimeout(() => {
|
||||
timedOut = true;
|
||||
child.kill("SIGTERM");
|
||||
setTimeout(() => child.kill("SIGKILL"), 5_000).unref?.();
|
||||
}, options.timeoutMs);
|
||||
timeout?.unref?.();
|
||||
child.stdout.pipe(process.stderr, { end: false });
|
||||
child.stderr.pipe(process.stderr, { end: false });
|
||||
child.on("error", reject);
|
||||
child.on("close", (status, signal) => {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
if (timedOut) {
|
||||
reject(new Error(`${command} ${args.join(" ")} timed out after ${options.timeoutMs}ms`));
|
||||
return;
|
||||
}
|
||||
if (status === 0) {
|
||||
resolve();
|
||||
return;
|
||||
@@ -150,10 +167,15 @@ async function main() {
|
||||
}
|
||||
|
||||
console.error("==> Checking OpenClaw package tarball");
|
||||
const checkStartedAt = Date.now();
|
||||
await run(
|
||||
"node",
|
||||
[path.join(ROOT_DIR, "scripts/check-openclaw-package-tarball.mjs"), tarball],
|
||||
sourceDir,
|
||||
{ timeoutMs: 5 * 60 * 1000 },
|
||||
);
|
||||
console.error(
|
||||
`==> OpenClaw package tarball check finished in ${Math.round((Date.now() - checkStartedAt) / 1000)}s`,
|
||||
);
|
||||
|
||||
process.stdout.write(`${tarball}\n`);
|
||||
|
||||
@@ -93,6 +93,16 @@ function run(command, args, options = {}) {
|
||||
cwd: options.cwd ?? ROOT_DIR,
|
||||
stdio: options.capture ? ["ignore", "pipe", "pipe"] : ["ignore", "inherit", "inherit"],
|
||||
});
|
||||
let timedOut = false;
|
||||
const timeout =
|
||||
options.timeoutMs === undefined
|
||||
? undefined
|
||||
: setTimeout(() => {
|
||||
timedOut = true;
|
||||
child.kill("SIGTERM");
|
||||
setTimeout(() => child.kill("SIGKILL"), 5_000).unref?.();
|
||||
}, options.timeoutMs);
|
||||
timeout?.unref?.();
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
if (options.capture) {
|
||||
@@ -105,6 +115,13 @@ function run(command, args, options = {}) {
|
||||
}
|
||||
child.on("error", reject);
|
||||
child.on("close", (status, signal) => {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
if (timedOut) {
|
||||
reject(new Error(`${command} ${args.join(" ")} timed out after ${options.timeoutMs}ms`));
|
||||
return;
|
||||
}
|
||||
if (status === 0) {
|
||||
resolve(stdout);
|
||||
return;
|
||||
@@ -406,7 +423,14 @@ async function resolveCandidate(options) {
|
||||
}
|
||||
|
||||
const digest = await assertExpectedSha256(target, options.packageSha256);
|
||||
await run("node", ["scripts/check-openclaw-package-tarball.mjs", target]);
|
||||
console.error(`Checking OpenClaw package tarball: ${target}`);
|
||||
const checkStartedAt = Date.now();
|
||||
await run("node", ["scripts/check-openclaw-package-tarball.mjs", target], {
|
||||
timeoutMs: 5 * 60 * 1000,
|
||||
});
|
||||
console.error(
|
||||
`OpenClaw package tarball check finished in ${Math.round((Date.now() - checkStartedAt) / 1000)}s`,
|
||||
);
|
||||
const pkg = await readPackageJson(target);
|
||||
const metadata = {
|
||||
name: pkg.name,
|
||||
|
||||
Reference in New Issue
Block a user