Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(stress): recognise pooler-owned files picked by CI scripts under scripts/
garrytanb8762c2a9302
diff --git a/scripts/stress/run.ts b/scripts/stress/run.tsindex c1ae9e5d58..1daf4e99fe 100644--- a/scripts/stress/run.ts+++ b/scripts/stress/run.ts@@ -352,7 +352,7 @@ const OWNING_WORKFLOWS = ['heavy-tests.yml', 'native-locks.yml', 'macos-validati/** Credentialed URLs of external services (a live Supabase Supavisor pooler) that no CI job provides: a secret by another name. */const EXTERNAL_SERVICE_URLS = ['GBRAIN_SUPAVISOR_URL'];-function skipReason(file: string): string | null {+export function skipReason(file: string): string | null {const text = readFileSync(join(ROOT, file), 'utf8');if (/process\.platform/.test(text)) return `every test skipped on ${process.platform}: platform-only tests, run by their owning native lane; not stressed`;const keys = [...new Set([...text.matchAll(/process\.env\.([A-Z0-9_]*(?:API_KEY|TOKEN|SECRET))/g)].map(m => m[1]!))];@@ -362,8 +362,9 @@ function skipReason(file: string): string | null {const owner = OWNING_WORKFLOWS.find(w => { const p = join(ROOT, '.github/workflows', w); return existsSync(p) && readFileSync(p, 'utf8').includes(file); });if (owner) return `every test skipped here: its prerequisite (agent binary or native target) comes from its owning job in .github/workflows/${owner}; not stressed`;if (/process\.env\.GBRAIN_PGBOUNCER_URL/.test(text) && !process.env.GBRAIN_PGBOUNCER_URL) {- const pooled = readdirSync(join(ROOT, '.github/workflows')).find(w => { const body = readFileSync(join(ROOT, '.github/workflows', w), 'utf8'); return body.includes(file) && body.includes('GBRAIN_CI_REQUIRE_PGBOUNCER'); });- if (pooled) return `every test skipped without the PgBouncer fixture (GBRAIN_PGBOUNCER_URL); its owning pooled job in .github/workflows/${pooled} requires it; not stressed`;+ const scripts = existsSync(join(ROOT, 'scripts')) ? readdirSync(join(ROOT, 'scripts')).filter(s => s.endsWith('.sh')).map(s => `scripts/${s}`) : [];+ const pooled = [...readdirSync(join(ROOT, '.github/workflows')).map(w => `.github/workflows/${w}`), ...scripts].find(p => { const body = readFileSync(join(ROOT, p), 'utf8'); return body.includes(file) && body.includes('GBRAIN_CI_REQUIRE_PGBOUNCER'); });+ if (pooled) return `every test skipped without the PgBouncer fixture (GBRAIN_PGBOUNCER_URL); its owning pooled job in ${pooled} requires it; not stressed`;}return null;}diff --git a/test/scripts/test-stress.test.ts b/test/scripts/test-stress.test.tsindex e18bd61f20..aa48b189f0 100644--- a/test/scripts/test-stress.test.ts+++ b/test/scripts/test-stress.test.ts@@ -10,7 +10,7 @@ import { spawnSync } from 'node:child_process';import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { failureSignature, parseArgs, readReport } from '../../scripts/stress/run.ts';+import { failureSignature, parseArgs, readReport, skipReason } from '../../scripts/stress/run.ts';const RUNNER = join(import.meta.dir, '..', '..', 'scripts', 'stress', 'run.ts');const dirs: string[] = [];@@ -102,6 +102,27 @@ describe('test:stress runner', () => {expect(owned.code, owned.out).toBe(1);});+ test('a pooled file whose owning job picks it in a CI script under scripts/ is not stressed', () => {+ const root = tree({+ 'test/script-pooled.test.ts': "import { test } from 'bun:test';\nconst pooled = process.env.GBRAIN_PGBOUNCER_URL;\ntest.skipIf(!pooled)('pooled', () => {});\n",+ '.github/workflows/e2e.yml': 'jobs:\n e2e:\n steps:\n - run: bash scripts/run-e2e.sh\n',+ 'scripts/run-e2e.sh': 'if [ "$f" = "test/script-pooled.test.ts" ] && [ "${GBRAIN_CI_REQUIRE_PGBOUNCER:-0}" = "1" ]; then exit 1; fi\n',+ });+ const r = stress(root, 'test/script-pooled.test.ts', '--iterations', '2');+ expect(r.code, r.out).toBe(0);+ expect(r.manifest.files[0]).toMatchObject({ status: 'not-stressed', reason: expect.stringContaining('owning pooled job in scripts/run-e2e.sh') });+ });++ test('test/e2e/pgbouncer-teardown.test.ts is pooler-owned in this repository', () => {+ const saved = process.env.GBRAIN_PGBOUNCER_URL;+ delete process.env.GBRAIN_PGBOUNCER_URL;+ try {+ expect(skipReason('test/e2e/pgbouncer-teardown.test.ts')).toContain('PgBouncer fixture');+ } finally {+ if (saved !== undefined) process.env.GBRAIN_PGBOUNCER_URL = saved;+ }+ });+test('a file that skips without an external Supavisor URL no CI job holds is not stressed', () => {const root = tree({ 'test/supavisor.test.ts': "import { test } from 'bun:test';\nconst url = process.env.GBRAIN_SUPAVISOR_URL;\ntest.skipIf(!url)('through supavisor', () => {});\n" });const r = stress(root, 'test/supavisor.test.ts', '--iterations', '2');