Skip to content

fix(tests): stub startup-failure recovery so scheduler tests are GITHUB_ACTIONS-agnostic - #1896

Merged
seonghobae merged 1 commit into
mainfrom
fix/scheduler-tests-github-actions-startup-recovery-leak
Sep 5, 2026
Merged

seonghobae merged 1 commit into
mainfrom
fix/scheduler-tests-github-actions-startup-recovery-leak

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Summary

recover_current_head_startup_failures() only runs inside inspect_pr() when os.environ["GITHUB_ACTIONS"] == "true" (introduced by #1846), so it silently never fired in a developer's local shell. But GitHub Actions sets that variable for the entire job, including the pytest process that runs this test file — so in real CI, this path fires for real inside the test suite itself.

14 pre-existing tests call inspect()/inspect_pr() with dry_run=False without anticipating this side effect:

  • 12 tests share the cancel_stale_pr_runs stub pattern and rely on make_pr()'s default headRefOid="head" placeholder — this blows up inside validate_git_sha with ValueError: invalid git sha: 'head'.
  • 2 tests (closing empty PRs) supply a real-looking sha but their narrow run stub (lambda args: ...) doesn't accept the recovery path's extra stdin= keyword argument — TypeError: ...<lambda>() got an unexpected keyword argument 'stdin'.

This is currently breaking the agent-review-runtime-quality required check on essentially every open PR whose diff touches the review_repair suite path — confirmed via gh api .../actions/workflows/349383189/runs, which shows this exact Verify scheduler and contextual-orchestrator review-repair contracts step failing across ~20 unrelated branches in the last day (docs/gap-baseline-main-history-splice, fix/hourly-review-repair-callers-cron-format-drift, codex/repair-codeql-startup-materialization, etc.), none of which touch this code path in their own diffs.

Fix

Stub recover_current_head_startup_failures to a no-op lambda repo, pr, *, dry_run: [] in each of the 14 affected tests, matching the exact pattern already used by the one test that intentionally exercises this integration (test_inspect_pr_recovers_startup_failure_before_other_actions). Test-only change — no production code touched.

Test plan

  • Reproduced the failure locally by setting GITHUB_ACTIONS=true (the missing piece that made this invisible in every local run) — confirmed all 17 sub-failures before the fix, on both Python 3.12 and the CI-pinned 3.14.
  • After the fix: GITHUB_ACTIONS=true PYTHONPATH=. python -m pytest tests/test_pr_review_merge_scheduler.py -q → 312 passed.
  • Full suite under the exact failing CI step's command (--cov=... --cov-branch --cov-fail-under=100) → 2833 passed, 1 skipped, 21 subtests, 100% coverage on the tracked modules — matches the CI job's own gate exactly.
  • python -m compileall -q tests/test_pr_review_merge_scheduler.py clean.

🤖 Generated with Claude Code

…UB_ACTIONS-agnostic

recover_current_head_startup_failures() only runs inside inspect_pr()
when os.environ["GITHUB_ACTIONS"] == "true" (#1846), so it silently
never fired in a developer's local shell -- but GitHub Actions sets
that variable for the entire job, including the pytest process that
runs this very test file. 14 pre-existing tests (12 sharing the
cancel_stale_pr_runs stub, 2 closing empty PRs) call inspect()/inspect_pr()
with dry_run=False and never anticipated this side effect, so in CI they
hit the real recovery path: one cluster used the fixture's placeholder
headRefOid="head" and blew up in validate_git_sha, the other supplied a
real sha but its narrow `run` stub didn't accept the recovery path's
extra kwargs. Stub recover_current_head_startup_failures to a no-op
`[]` in each, matching the existing pattern already used by
test_inspect_pr_recovers_startup_failure_before_other_actions for the
one test that intentionally exercises this integration.

Reproduced and verified with GITHUB_ACTIONS=true set locally under both
Python 3.12 and the CI-pinned 3.14: full suite 2833 passed, 1 skipped,
21 subtests, 100% coverage on the previously-failing job's tracked
modules.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-05T05:22:42.649931Z d0bc34c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 45 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 1024cf2e-5781-456a-8bed-71e4e1965567

📥 Commits

Reviewing files that changed from the base of the PR and between 1c74d9d and d0bc34c.

📒 Files selected for processing (1)
  • tests/test_pr_review_merge_scheduler.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Independent review verification (host 1)

Verified against a fresh origin/main checkout (not just trusting the description):

  1. Reproduced the root cause: GITHUB_ACTIONS=true python3 -m pytest tests/test_pr_review_merge_scheduler.py on a clean origin/main (at the time, past #1895) failed 17 tests (a few more than the PR's original "14" since main had advanced), matching the described inspect_pr() → recover_current_head_startup_failures() gate exactly.
  2. Merged this branch onto current origin/main and re-ran: GITHUB_ACTIONS=true python3 -m pytest tests/test_pr_review_merge_scheduler.py → 312 passed. Full suite under the same env var: 2841 passed, 1 skipped, 21 subtests.
  3. Reviewed the diff directly: all 14 additions follow the exact same monkeypatch.setattr(sched, "<fn>", lambda repo, pr, *, dry_run: []) no-op-stub pattern this file already uses for cancel_stale_pr_runs in the same tests — test-only, no production code touched, minimal risk.
  4. The 99%/98.3% coverage/docstring shortfall on this same checkout is the pre-existing, separately-tracked admission-controller gap (.github#1883, still unmerged) — unrelated to this PR's scope, confirmed by checking coverage report --show-missing's exact missing lines match that known gap.

LGTM from my side. (Also found and fixed a fresh regression while re-verifying: #1895's revert of #1892 broke the opencode-review-dispatch.yml blob-pin again in the opposite direction — bypass-merged as #1897, and re-confirmed this PR passes on top of that too.)

@seonghobae
seonghobae merged commit 6d7fbeb into main Sep 5, 2026
5 of 15 checks passed
@seonghobae
seonghobae deleted the fix/scheduler-tests-github-actions-startup-recovery-leak branch September 5, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant