mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-23 14:45:46 +00:00
test: trim heavy imports and harden ci checks
This commit is contained in:
@@ -532,6 +532,39 @@ export function resolveBoundaryCheckLockPath(rootDir = repoRoot) {
|
||||
return resolve(rootDir, "dist", ".extension-package-boundary.lock");
|
||||
}
|
||||
|
||||
function resolveBoundaryCheckLockOwnerPath(lockPath) {
|
||||
return join(lockPath, "owner.json");
|
||||
}
|
||||
|
||||
function isProcessAlive(pid) {
|
||||
if (!Number.isInteger(pid) || pid <= 0) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
process.kill(pid, 0);
|
||||
return true;
|
||||
} catch (error) {
|
||||
return Boolean(error && typeof error === "object" && "code" in error && error.code === "EPERM");
|
||||
}
|
||||
}
|
||||
|
||||
function removeStaleBoundaryCheckLock(lockPath) {
|
||||
const ownerPath = resolveBoundaryCheckLockOwnerPath(lockPath);
|
||||
let owner;
|
||||
try {
|
||||
owner = JSON.parse(readFileSync(ownerPath, "utf8"));
|
||||
} catch {
|
||||
rmSync(lockPath, { force: true, recursive: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
if (owner && typeof owner === "object" && isProcessAlive(owner.pid)) {
|
||||
return false;
|
||||
}
|
||||
rmSync(lockPath, { force: true, recursive: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
export function acquireBoundaryCheckLock(params = {}) {
|
||||
const rootDir = params.rootDir ?? repoRoot;
|
||||
const processObject = params.processObject ?? process;
|
||||
@@ -541,26 +574,37 @@ export function acquireBoundaryCheckLock(params = {}) {
|
||||
mkdirSync(lockPath);
|
||||
} catch (error) {
|
||||
if (error && typeof error === "object" && "code" in error && error.code === "EEXIST") {
|
||||
throw attachStepFailureMetadata(
|
||||
new Error(
|
||||
[
|
||||
"extension package boundary check",
|
||||
"kind: lock-contention",
|
||||
`lock: ${lockPath}`,
|
||||
"another extension package boundary check is already running in this checkout",
|
||||
].join("\n\n"),
|
||||
{ cause: error },
|
||||
),
|
||||
"extension package boundary check",
|
||||
{
|
||||
kind: "lock-contention",
|
||||
note: `lock: ${lockPath}\nanother extension package boundary check is already running in this checkout`,
|
||||
},
|
||||
);
|
||||
if (removeStaleBoundaryCheckLock(lockPath)) {
|
||||
mkdirSync(lockPath);
|
||||
} else {
|
||||
throw attachStepFailureMetadata(
|
||||
new Error(
|
||||
[
|
||||
"extension package boundary check",
|
||||
"kind: lock-contention",
|
||||
`lock: ${lockPath}`,
|
||||
"another extension package boundary check is already running in this checkout",
|
||||
].join("\n\n"),
|
||||
{ cause: error },
|
||||
),
|
||||
"extension package boundary check",
|
||||
{
|
||||
kind: "lock-contention",
|
||||
note: `lock: ${lockPath}\nanother extension package boundary check is already running in this checkout`,
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
writeFileSync(
|
||||
resolveBoundaryCheckLockOwnerPath(lockPath),
|
||||
`${JSON.stringify({ pid: process.pid, startedAt: new Date().toISOString() }, null, 2)}\n`,
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const release = () => {
|
||||
rmSync(lockPath, { force: true, recursive: true });
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@ const VALID_MODES = new Set(["all", "package-boundary"]);
|
||||
const ROOT_DTS_INPUTS = [
|
||||
"tsconfig.json",
|
||||
"tsconfig.plugin-sdk.dts.json",
|
||||
"src/channels/plugins",
|
||||
"src/plugin-sdk",
|
||||
"src/video-generation/dashscope-compatible.ts",
|
||||
"src/video-generation/types.ts",
|
||||
@@ -20,6 +21,7 @@ const ROOT_DTS_INPUTS = [
|
||||
const PACKAGE_DTS_INPUTS = [
|
||||
"tsconfig.json",
|
||||
"packages/plugin-sdk/tsconfig.json",
|
||||
"src/channels/plugins",
|
||||
"src/plugin-sdk",
|
||||
"src/video-generation/dashscope-compatible.ts",
|
||||
"src/video-generation/types.ts",
|
||||
|
||||
Reference in New Issue
Block a user