bun run ci defers the browser suites and the desktop boot check to Forgejo CI when the 1-minute load is above 2x the cores (deferBrowser in tools/ci-plan.ts, said at the start and in the summary); CI=full forces them, Forgejo runs CI=full

This commit is contained in:
CRTkafa 2026-10-14 05:24:38 +08:00
parent 918146d4a6
commit 49a73c90e4
3 changed files with 28 additions and 6 deletions

View file

@ -2,7 +2,7 @@
// touches (ci:quick) and whether the desktop Rust host needs to run. Pure functions plus small file / git reads;
// tests/ci-plan.test.ts covers them.
import { mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
import { cpus } from 'node:os';
import { cpus, loadavg } from 'node:os';
import { dirname, join, normalize, relative } from 'node:path';
export const ROOT = join(import.meta.dir, '..');
@ -28,6 +28,15 @@ export function browserShardCount(env = process.env): number {
return Number.isInteger(n) && n > 0 ? n : 1;
}
/**
* The local pre-push gate on a busy shared machine: with the 1-minute load average above 2x the cores, the browser
* suites (HEAVY) and the desktop boot check (real Chrome) are deferred to the Forgejo CI on the VDS, which always runs
* them (CI=full; a red Forgejo CI on main stops releases). CI=full forces them locally.
*/
export function deferBrowser(env = process.env, load1 = loadavg()[0] ?? 0, cores = cpus().length): boolean {
return env.CI !== 'full' && load1 > 2 * cores;
}
/** Changes that can affect every test: run the whole suite. */
export const GLOBAL = /^(package\.json|bun\.lock|bunfig\.toml|tsconfig\.json|tests\/helpers\/preload\.ts)$/;