openvibers/openvibe-git Commits

Forge runner: per-file test limits stretch on a slower machine; two runs at once (#120)

OP OpenVibers committed 12 days ago · 61b11a7202 · 6 files, +32 −11

testTimeoutScale (1-10) sets OV_TEST_TIMEOUT_SCALE in the test phase only (openvibe-shared's test runner 4.323.0 and
later multiply each file's limit by it): Live's 120 s crawl test ran out of time on the node while it passed on GitHub.
Three runs at once took Live 14 minutes and Network 18 on the node's four cores (GitHub: 8 and 12), so it runs two;
docs/ci.md says so, with the same-files answer and the merge gate. test/ci-deps-cache.test.js covers the scale.

Changes

ddiff --git a/docs/ci.md b/docs/ci.md
iindex ea4f8d7..9d47238 100644
---- a/docs/ci.md
++++ b/docs/ci.md
@@@ -120,8 +120,17 @@ repositories) to `ov-node-01` (8 cores, 15 GB):
lockfile → `npm ci`, a `package.json` alone → `npm install`; then `npm test`). A repository with no test script
reports "Nothing to test here" instead of failing. A repository that needs more names its commands (Live skips
onnxruntime's CUDA download; Games runs typecheck and lint like its workflow).
--- **Three runs at once** (`concurrency`, up to 8). The forge keeps one live run per repository, so they are always
-- different repositories. Each worker claims as `<host>/<n>`.
++- **Two runs at once** (`concurrency`, up to 8). The forge keeps one live run per repository, so they are always
++ different repositories. Each worker claims as `<host>/<n>`. Three was tried first: three full suites on the node's
++ four cores took Live 14 minutes and Network 18 (GitHub: 8 and 12), so it runs two. The test phase sets
++ `OV_TEST_TIMEOUT_SCALE=2` (`testTimeoutScale`; openvibe-shared's test runner 4.323.0 and later stretch each file's
++ limit by it), since a file's limit was set on GitHub's machines.
++- **Same files, same verdict.** A push whose tree is exactly that of a run that already passed (a pull request merged
++ onto an unmoved main) is recorded as passed at once, pointing at that run; nothing is tested twice. A run started by
++ hand always runs.
++- **Merging on it.** The ship script (`merge-after-ci.sh`) merges on a green `forge/test` without waiting for GitHub
++ Actions, and refuses on a red one once the repository's main has passed on the forge (before that, a suite that
++ cannot pass without the network does not block a merge GitHub would allow). The board is `/ci`.
- **Work in memory.** The work directories are a tmpfs (`/var/lib/ovci/work`, 8 GB at most): an install's tens of
thousands of files never touch the disk, and a run's directory is gone when it ends.
- **Installs kept per lockfile** (`runner/deps-cache.js`). After an install phase succeeds, what it made (every
ddiff --git a/runner/config.js b/runner/config.js
iindex 548168b..5a4be84 100644
---- a/runner/config.js
++++ b/runner/config.js
@@@ -9,7 +9,8 @@
* "tokenFile": "~/.config/openvibe/git-ci.token",
* "workRoot": "~/.cache/openvibe-git-ci",
* "engine": "auto", // auto | podman | bwrap
-- * "concurrency": 1, // runs at once (1-8); the shared node runs 3
++ * "concurrency": 1, // runs at once (1-8); the shared node runs 2
++ * "testTimeoutScale": 1, // OV_TEST_TIMEOUT_SCALE in the test phase (1-10; the node: 2)
* "depsCache": "~/.cache/openvibe-git-ci/deps", // installs kept between runs ("" turns it off)
* "depsCacheMb": 20480,
* "sharedCache": "~/.cache/openvibe-git-ci/shared", // npm and pnpm download caches, install phase only ("" off)
@@@ -67,6 +68,9 @@ function loadConfig(env = process.env) {
engine: ['auto', 'podman', 'bwrap'].includes(raw.engine) ? raw.engine : 'auto',
image: String(raw.image || 'docker.io/library/node:22-bookworm'),
concurrency: int(raw.concurrency, 1, 1, 8),
++ // The test phase's OV_TEST_TIMEOUT_SCALE (openvibe-shared/test-runner 4.323.0 and later): a runner slower or busier
++ // than the machines a repository's per-file limits were set on stretches them (the shared node: 2).
++ testTimeoutScale: Math.min(10, Math.max(1, Number(raw.testTimeoutScale) || 1)),
// Installs kept between runs (runner/deps-cache.js) and the package managers' download caches. Both live on
// disk: the page cache keeps the busy ones in memory and gives it back when something else needs it.
depsCache: raw.depsCache === '' ? '' : expand(raw.depsCache || path.join(HOME, '.cache', 'openvibe-git-ci', 'deps')),
ddiff --git a/runner/run.js b/runner/run.js
iindex 9fb3077..cfa805b 100644
---- a/runner/run.js
++++ b/runner/run.js
@@@ -81,6 +81,7 @@ function createRunner({ cfg, api, log = console, clock = Date.now }) {
say(`[git-ci-runner] sandbox: ${engine.why}; ${Object.keys(cfg.repos).length} repositories configured`);
const deps = cfg.depsCache ? createDepsCache({ root: cfg.depsCache, maxMb: cfg.depsCacheMb, log: say }) : null;
if (cfg.sharedCache) for (const sub of ['npm', 'pnpm-store']) fs.mkdirSync(path.join(cfg.sharedCache, sub), { recursive: true, mode: 0o700 });
++ const testEnv = cfg.testTimeoutScale > 1 ? { OV_TEST_TIMEOUT_SCALE: String(cfg.testTimeoutScale) } : {};
// Every phase running now, across the runs this runner holds at once: stop() ends them all.
const activeKills = new Set();
let stopping = false;
@@@ -141,11 +142,11 @@ function createRunner({ cfg, api, log = console, clock = Date.now }) {
if (engine.kind === 'podman') {
return {
command: 'podman',
-- args: [...rootArgs, ...podmanArgs({ name, workspace: runDir, image: job.image, limits, proxySock, sharedCache: cfg.sharedCache || null, script: command })],
++ args: [...rootArgs, ...podmanArgs({ name, workspace: runDir, image: job.image, limits, proxySock, sharedCache: cfg.sharedCache || null, testEnv, script: command })],
kill: () => podmanCleanup(name, rootArgs),
};
}
-- const wrapped = bwrapScope({ name, limits, args: bwrapArgs({ workspace: runDir, limits, proxySock, sharedCache: cfg.sharedCache || null, script: command }).args });
++ const wrapped = bwrapScope({ name, limits, args: bwrapArgs({ workspace: runDir, limits, proxySock, sharedCache: cfg.sharedCache || null, testEnv, script: command }).args });
return { command: wrapped.command, args: wrapped.args, kill: () => scopeCleanup(wrapped.killUnit) };
};
ddiff --git a/runner/sandbox.js b/runner/sandbox.js
iindex 709e355..58a709d 100644
---- a/runner/sandbox.js
++++ b/runner/sandbox.js
@@@ -108,7 +108,7 @@ ${command}
/**
* The podman command line for one phase. proxySock is null for the test phase (no network at all).
*/
--function podmanArgs({ name, workspace, image, limits, proxySock = null, sharedCache = null, script }) {
++function podmanArgs({ name, workspace, image, limits, proxySock = null, sharedCache = null, testEnv = {}, script }) {
const args = [
'run', '--rm', '--name', name, '--pull=never', '--network=none',
'--cpus', String(limits.cpus), '--memory', `${limits.memory_mb}m`, '--memory-swap', `${limits.memory_mb}m`,
@@@ -119,7 +119,7 @@ function podmanArgs({ name, workspace, image, limits, proxySock = null, sharedCa
'--stop-timeout', '5',
];
const shared = proxySock ? sharedCache : null;
-- for (const [key, value] of Object.entries(envList({ ...phaseEnv(proxySock), ...cacheEnv(shared) }))) args.push('-e', `${key}=${value}`);
++ for (const [key, value] of Object.entries(envList({ ...phaseEnv(proxySock), ...cacheEnv(shared), ...(proxySock ? {} : testEnv) }))) args.push('-e', `${key}=${value}`);
if (proxySock) args.push('-v', `${proxySock}:/run/ci-proxy.sock:rw`);
if (shared) args.push('-v', `${shared}:${SHARED_CACHE}:rw`);
args.push(image, '/bin/sh', '-c', script);
@@@ -150,7 +150,7 @@ function bwrapEtc(workspace) {
* The bubblewrap command line for one phase (no systemd scope here; the caller wraps it). Node is bound from
* the running runner's own installation, because a workstation's Node is rarely in /usr.
*/
--function bwrapArgs({ workspace, limits, proxySock = null, sharedCache = null, script }) {
++function bwrapArgs({ workspace, limits, proxySock = null, sharedCache = null, testEnv = {}, script }) {
const node = fs.realpathSync(process.execPath);
const prefix = path.dirname(path.dirname(node));
const nodeInside = path.join('/opt/node', path.relative(prefix, node));
@@@ -162,7 +162,7 @@ function bwrapArgs({ workspace, limits, proxySock = null, sharedCache = null, sc
'--uid', String(UID), '--gid', String(GID), '--hostname', 'ci',
];
const shared = proxySock ? sharedCache : null;
-- for (const [key, value] of Object.entries({ ...envList({ ...phaseEnv(proxySock), ...cacheEnv(shared) }), PATH: `${nodeBin}:/usr/local/bin:/usr/bin:/bin` })) {
++ for (const [key, value] of Object.entries({ ...envList({ ...phaseEnv(proxySock), ...cacheEnv(shared), ...(proxySock ? {} : testEnv) }), PATH: `${nodeBin}:/usr/local/bin:/usr/bin:/bin` })) {
args.push('--setenv', key, value);
}
args.push('--ro-bind', '/usr', '/usr');
ddiff --git a/server/http/pages.js b/server/http/pages.js
iindex cd27898..103798b 100644
---- a/server/http/pages.js
++++ b/server/http/pages.js
@@@ -177,7 +177,7 @@ function createPageRoutes(ctx) {
r.get('/ci', h(async (req, res) => {
const data = await ci.board({ limit: req.query.limit });
res.set('Cache-Control', 'no-store');
-- return page(req, res, ciViews.board({ ...data, runners: config.ci.boardRunners || 3 }), { title: 'CI', description: 'Every OpenVibers repository, tested on our own runner.', index: false });
++ return page(req, res, ciViews.board({ ...data, runners: config.ci.boardRunners || 2 }), { title: 'CI', description: 'Every OpenVibers repository, tested on our own runner.', index: false });
}));
r.get('/machines', h(async (req, res) => {
ddiff --git a/test/ci-deps-cache.test.js b/test/ci-deps-cache.test.js
iindex 3fcee36..bf74057 100644
---- a/test/ci-deps-cache.test.js
++++ b/test/ci-deps-cache.test.js
@@@ -126,14 +126,21 @@ const write = (file, text) => { fs.mkdirSync(path.dirname(file), { recursive: tr
const podTest = podmanArgs({ name: 'n', workspace: ws, image: 'img', limits, proxySock: null, sharedCache: shared, script: 'true' });
assert.ok(!podTest.some((x) => String(x).includes(':/cache')), 'podman\'s test phase gets no shared cache either');
assert.match(installScript('npm ci'), /NODE_USE_ENV_PROXY=1/, 'Node\'s own fetch uses the proxy');
++ // The test phase gets the timeout scale; the install phase does not.
++ const scaledTest = bwrapArgs({ workspace: ws, limits, proxySock: null, testEnv: { OV_TEST_TIMEOUT_SCALE: '2' }, script: 'true' }).args;
++ assert.strictEqual(scaledTest[scaledTest.indexOf('OV_TEST_TIMEOUT_SCALE') + 1], '2');
++ const scaledInstall = bwrapArgs({ workspace: ws, limits, proxySock: path.join(ws, 'p.sock'), testEnv: { OV_TEST_TIMEOUT_SCALE: '2' }, script: 'true' }).args;
++ assert.ok(!scaledInstall.includes('OV_TEST_TIMEOUT_SCALE'));
++ assert.ok(podmanArgs({ name: 'n', workspace: ws, image: 'img', limits, proxySock: null, testEnv: { OV_TEST_TIMEOUT_SCALE: '2' }, script: 'true' }).includes('OV_TEST_TIMEOUT_SCALE=2'));
assert.doesNotMatch(installScript('npm test', { proxy: false }), /NODE_USE_ENV_PROXY/);
// ── The configuration ──
const token = path.join(tmp, 'token');
fs.writeFileSync(token, 'x'.repeat(40), { mode: 0o600 });
const conf = path.join(tmp, 'ci.json');
-- fs.writeFileSync(conf, JSON.stringify({ tokenFile: token, concurrency: 8, repos: { 'OpenVibers/OpenVibe.Live': {} } }));
++ fs.writeFileSync(conf, JSON.stringify({ tokenFile: token, concurrency: 8, testTimeoutScale: 2, repos: { 'OpenVibers/OpenVibe.Live': {} } }));
const cfg = loadConfig({ GIT_CI_CONFIG: conf });
++ assert.strictEqual(cfg.testTimeoutScale, 2);
assert.strictEqual(cfg.concurrency, 8);
assert.ok(cfg.depsCache && cfg.sharedCache, 'both caches are on by default');
assert.deepStrictEqual(registrations(cfg).map((r) => [r.full_name, r.install_command, r.test_command]), [['openvibers/openvibe.live', 'auto', 'auto']]);