fix(ci): default local low-memory checks

This commit is contained in:
Vincent Koc
2026-03-31 15:03:08 +09:00
parent 3a87783632
commit 8dfbcaa200
13 changed files with 198 additions and 90 deletions

42
scripts/run-oxlint.mjs Normal file
View File

@@ -0,0 +1,42 @@
import { spawnSync } from "node:child_process";
import path from "node:path";
const isLocalCheckEnabled = (env) => {
const raw = env.OPENCLAW_LOCAL_CHECK?.trim().toLowerCase();
return raw !== "0" && raw !== "false";
};
const hasFlag = (args, name) => args.some((arg) => arg === name || arg.startsWith(`${name}=`));
const args = process.argv.slice(2);
const env = { ...process.env };
const finalArgs = [...args];
const separatorIndex = finalArgs.indexOf("--");
const insertBeforeSeparator = (...items) => {
const index = separatorIndex === -1 ? finalArgs.length : separatorIndex;
finalArgs.splice(index, 0, ...items);
};
if (!hasFlag(finalArgs, "--type-aware")) {
insertBeforeSeparator("--type-aware");
}
if (!hasFlag(finalArgs, "--tsconfig")) {
insertBeforeSeparator("--tsconfig", "tsconfig.oxlint.json");
}
if (isLocalCheckEnabled(env) && !hasFlag(finalArgs, "--threads")) {
insertBeforeSeparator("--threads=1");
}
const oxlintPath = path.resolve("node_modules", ".bin", "oxlint");
const result = spawnSync(oxlintPath, finalArgs, {
stdio: "inherit",
env,
shell: process.platform === "win32",
});
if (result.error) {
throw result.error;
}
process.exit(result.status ?? 1);

37
scripts/run-tsgo.mjs Normal file
View File

@@ -0,0 +1,37 @@
import { spawnSync } from "node:child_process";
import path from "node:path";
const isLocalCheckEnabled = (env) => {
const raw = env.OPENCLAW_LOCAL_CHECK?.trim().toLowerCase();
return raw !== "0" && raw !== "false";
};
const args = process.argv.slice(2);
const env = { ...process.env };
const finalArgs = [...args];
const separatorIndex = finalArgs.indexOf("--");
const insertBeforeSeparator = (...items) => {
const index = separatorIndex === -1 ? finalArgs.length : separatorIndex;
finalArgs.splice(index, 0, ...items);
};
if (isLocalCheckEnabled(env) && !finalArgs.includes("--singleThreaded")) {
insertBeforeSeparator("--singleThreaded");
if (!env.GOGC) {
env.GOGC = "30";
}
}
const tsgoPath = path.resolve("node_modules", ".bin", "tsgo");
const result = spawnSync(tsgoPath, finalArgs, {
stdio: "inherit",
env,
shell: process.platform === "win32",
});
if (result.error) {
throw result.error;
}
process.exit(result.status ?? 1);