fix(scripts): add short help to stale CI cleanup#3222
Conversation
Constraint: contributor maintenance scripts should expose help without requiring GitHub CLI calls.\nRejected: documenting only --help | the repo already supports short help aliases on adjacent helper scripts.\nConfidence: high\nScope-risk: narrow\nDirective: keep maintenance-script help paths before network or gh-dependent work.\nTested: node --test scripts/__tests__/cancel-stale-pr-ci-help.test.mjs; node scripts/codex-pr-preflight.mjs --lightweight; git diff --check --cached; pnpm --filter openhuman-app format:check reached cargo blocker after Prettier passed.\nNot-tested: full Rust format because cargo is not installed locally.
📝 WalkthroughWalkthroughThis pull request adds a short ChangesHelp flag enhancement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/__tests__/cancel-stale-pr-ci-help.test.mjs (1)
13-18: ⚡ Quick winConsider cleaning up the temporary directory.
The
mkdtempSynccreates a directory that is never removed, leaving test artifacts in the system temp directory. Consider adding cleanup logic.♻️ Proposed fix to add cleanup
function runHelp(flag) { const binDir = fs.mkdtempSync(join(os.tmpdir(), 'openhuman-gh-stub-')); - fs.writeFileSync( - join(binDir, 'gh'), - '#!/usr/bin/env sh\necho "gh should not run for help" >&2\nexit 99\n', - { mode: 0o755 }, - ); + try { + fs.writeFileSync( + join(binDir, 'gh'), + '#!/usr/bin/env sh\necho "gh should not run for help" >&2\nexit 99\n', + { mode: 0o755 }, + ); - return spawnSync(process.execPath, [SCRIPT, flag], { - encoding: 'utf8', - env: { - ...process.env, - PATH: `${binDir}${process.platform === 'win32' ? ';' : ':'}${process.env.PATH ?? ''}`, - }, - }); + return spawnSync(process.execPath, [SCRIPT, flag], { + encoding: 'utf8', + env: { + ...process.env, + PATH: `${binDir}${process.platform === 'win32' ? ';' : ':'}${process.env.PATH ?? ''}`, + }, + }); + } finally { + fs.rmSync(binDir, { recursive: true, force: true }); + } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/__tests__/cancel-stale-pr-ci-help.test.mjs` around lines 13 - 18, The test creates a temporary directory with fs.mkdtempSync assigned to binDir and writes a stub 'gh' there but never removes it; add cleanup to remove the temp directory (and contents) after the test runs — e.g., in an afterEach/afterAll or finally block, call fs.rmSync(binDir, { recursive: true, force: true }) or equivalent to delete binDir and its 'gh' file so the temp artifact is not left behind (update the test in cancel-stale-pr-ci-help.test.mjs where binDir is created).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@scripts/__tests__/cancel-stale-pr-ci-help.test.mjs`:
- Around line 13-18: The test creates a temporary directory with fs.mkdtempSync
assigned to binDir and writes a stub 'gh' there but never removes it; add
cleanup to remove the temp directory (and contents) after the test runs — e.g.,
in an afterEach/afterAll or finally block, call fs.rmSync(binDir, { recursive:
true, force: true }) or equivalent to delete binDir and its 'gh' file so the
temp artifact is not left behind (update the test in
cancel-stale-pr-ci-help.test.mjs where binDir is created).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6ea7206e-3828-431f-95f1-6e5d24b36ba6
📒 Files selected for processing (2)
scripts/__tests__/cancel-stale-pr-ci-help.test.mjsscripts/cancel-stale-pr-ci.mjs
Summary
-has a short help alias forscripts/cancel-stale-pr-ci.mjs.-hand--help.gh.Problem
--helpand-h, butcancel-stale-pr-ci.mjsonly accepted--help.Solution
-hthe same as--helpbefore parsing action flags or calling GitHub CLI.ghstub inPATHso any accidental GitHub CLI invocation fails the test.Submission Checklist
ghis invoked).Impact
node scripts/cancel-stale-pr-ci.mjs -hnow prints usage and exits without requiringgh.Related
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
codex/OH-2611-cancel-stale-ci-short-help16b6ddbValidation Run
pnpm --filter openhuman-app format:check(blocked after Prettier passed; see Validation Blocked)pnpm typecheck: N/A, root Node helper-only changenode --test scripts/__tests__/cancel-stale-pr-ci-help.test.mjsnode scripts/codex-pr-preflight.mjs --lightweightgit diff --check --cachedValidation Blocked
command:pnpm --filter openhuman-app format:checkerror:sh: cargo: command not foundimpact:Prettier passed, but the Rust format phase cannot run in this local environment until Cargo is installed.Behavior Changes
-hnow prints usage and exits 0 forcancel-stale-pr-ci.mjs.Parity Contract
--help, normal dry-run mode,--execute, and invalid argument behavior are unchanged.ghinvocation.Duplicate / Superseded PR Handling
Summary by CodeRabbit
New Features
-has a shorthand alternative to--helpfor displaying usage and help information.Tests
-hand--helpflags work correctly and that the script displays proper help information without unnecessary operations.