Files
openhuman/scripts/test-codex-pr-preflight.mjs
T
+14 932703f5f2 SYM-93: add scriptable Codex PR preflight runner (#1245)
Co-authored-by: Steven Enamakel <31011319+senamakel@users.noreply.github.com>
Co-authored-by: WOZCODE <contact@withwoz.com>
Co-authored-by: sanil-23 <sanil@vezures.xyz>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Cyrus Gray <144336577+graycyrus@users.noreply.github.com>
Co-authored-by: CodeGhost21 <164498022+CodeGhost21@users.noreply.github.com>
Co-authored-by: oxoxDev <164490987+oxoxDev@users.noreply.github.com>
Co-authored-by: Mega Mind <146339422+M3gA-Mind@users.noreply.github.com>
Co-authored-by: Gaurang Patel <ptelgm.yt@gmail.com>
Co-authored-by: unn-Known1 <unn-known1@users.noreply.github.com>
Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Steven Enamakel <senamakel@users.noreply.github.com>
Co-authored-by: Steven Enamakel's Droid <enamakel.agent@tinyhumans.ai>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: senamakel-droid <281415773+senamakel-droid@users.noreply.github.com>
Co-authored-by: YellowSnnowmann <167776381+YellowSnnowmann@users.noreply.github.com>
Co-authored-by: Neil <neil@maha.xyz>
Co-authored-by: Neel Mistry <neelmistry@Neels-MacBook-Pro.local>
Co-authored-by: obchain <167975049+obchain@users.noreply.github.com>
Co-authored-by: Jwalin Shah <jshah1331@gmail.com>
2026-05-05 11:15:31 -07:00

45 lines
1.6 KiB
JavaScript
Executable File

#!/usr/bin/env node
import { mkdtempSync, mkdirSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { execSync } from 'node:child_process';
function run(cmd, cwd) {
return execSync(cmd, { cwd, stdio: 'pipe', encoding: 'utf8' });
}
function makeRepo(branchName) {
const dir = mkdtempSync(path.join(tmpdir(), 'codex-preflight-'));
mkdirSync(path.join(dir, 'docs/src'), { recursive: true });
mkdirSync(path.join(dir, 'app'), { recursive: true });
writeFileSync(path.join(dir, 'AGENTS.md'), '# test\n');
writeFileSync(path.join(dir, 'docs/src/README.md'), 'ok\n');
writeFileSync(path.join(dir, 'Cargo.toml'), '[package]\nname="x"\nversion="0.1.0"\n');
writeFileSync(path.join(dir, 'app/package.json'), '{"name":"x"}\n');
run('git init', dir);
run('git config user.email test@example.com', dir);
run('git config user.name test', dir);
run('git add .', dir);
run('git commit -m init', dir);
run(`git checkout -b ${branchName}`, dir);
run('git remote add origin git@github.com:jwalin-shah/openhuman.git', dir);
return dir;
}
const script = path.resolve('scripts/codex-pr-preflight.mjs');
const passRepo = makeRepo('codex/SYM-93-preflight');
run(`CODEX_EXPECT_REPO_PATH=${passRepo} node ${script} --strict-path --lightweight`, passRepo);
const failRepo = makeRepo('feature/not-codex');
let failed = false;
try {
run(`CODEX_EXPECT_REPO_PATH=${failRepo} node ${script} --strict-path --lightweight`, failRepo);
} catch {
failed = true;
}
if (!failed) {
throw new Error('Expected invalid branch naming to fail preflight');
}
console.log('codex preflight self-test passed');