Skip to content

[ci] Disabled auto-close PRs#673

Merged
nemesifier merged 1 commit into
masterfrom
ci/disable-stale-pr-auto-close
May 9, 2026
Merged

[ci] Disabled auto-close PRs#673
nemesifier merged 1 commit into
masterfrom
ci/disable-stale-pr-auto-close

Conversation

@nemesifier
Copy link
Copy Markdown
Member

Quickfix to disable auto-close PRs which is causing issues.

@nemesifier nemesifier self-assigned this May 9, 2026
@nemesifier nemesifier added the bug label May 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request temporarily disables the automatic closing of stale pull requests. The close_stale_pr() function is now stubbed to immediately print a message and return False, preventing any PR state changes, closing comments, or linked-issue unassignments from executing. The corresponding test class TestCloseStalePR is skipped via a pytest.mark.skip decorator to align with the disabled functionality.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

github_actions, helper-bots


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Bug Fixes ❌ Error Bypasses root cause (PR #668 has proper fix). No regression test—test suite skipped rather than asserting disabled behavior. Missing test verifying no side effects. Add test asserting close_stale_pr returns False with no side effects. Replace early return with explicit feature gate. Treat as CI exception if temporary kill-switch only.
Description check ⚠️ Warning The description is minimal and lacks the required template structure including checklist, issue reference, and detailed change description. Fill out the full description template with completed checklist items, link the issue number, and provide a detailed description of the changes and their impact.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required format with [ci] prefix and clearly describes the main change of disabling auto-close functionality for PRs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/disable-stale-pr-auto-close

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 and usage tips.

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented May 9, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • .github/actions/bot-autoassign/stale_pr_bot.py - Temporary disable of auto-close with clear documentation
  • .github/actions/bot-autoassign/tests/test_stale_pr_bot.py - Proper test skip for disabled feature

The PR is a clean temporary fix that disables the problematic auto-close functionality. The early return at the start of close_stale_pr() effectively prevents PRs from being auto-closed while referencing PR #668 for the proper fix.


Reviewed by kimi-k2.5-0127 · 78,302 tokens

@coderabbitai coderabbitai Bot added github_actions Pull requests that update GitHub Actions code helper-bots Helper bots, release management automation labels May 9, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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.

Inline comments:
In @.github/actions/bot-autoassign/stale_pr_bot.py:
- Around line 212-217: The unconditional early return that prints "Auto-close
currently disabled" should be replaced with a feature gate so the remaining
auto-close logic (below the current return) stays reachable; remove the
hardcoded "return False" and instead check a boolean flag (e.g., an env var like
ENABLE_AUTO_CLOSE or a config value) before returning—if the flag is false, log
the same message and return False, otherwise allow execution to continue into
the existing auto-close code that follows the block referencing pr.number.
Update any imports if needed (os or config) and ensure the new conditional uses
that flag to control flow rather than an unconditional return.

In @.github/actions/bot-autoassign/tests/test_stale_pr_bot.py:
- Line 332: Remove the `@pytest.mark.skip` on the TestCloseStalePR suite and
change the tests to assert the temporary disabled contract: call the
close_stale_pr (or the test helper that invokes it) and assert it returns False,
and assert the side-effect mocks (e.g., mock_post_comment, mock_edit_state,
mock_unassign or whatever fixtures are used in the test) were not called; keep
the test class name TestCloseStalePR and the close_stale_pr stub reference so
the assertions validate no comment was posted, no state was edited, and no
unassign occurred.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bcb0c182-8f10-45b3-879d-335dbab45987

📥 Commits

Reviewing files that changed from the base of the PR and between 8aa5674 and c96f187.

📒 Files selected for processing (2)
  • .github/actions/bot-autoassign/stale_pr_bot.py
  • .github/actions/bot-autoassign/tests/test_stale_pr_bot.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (python)

Comment on lines +212 to +217
# TEMPORARY: auto-close disabled. The stale-detection heuristic
# has been closing PRs that are merely blocked by bot reviews
# (or by reviews the same reviewer later approved). The proper
# fix lives in PR #668; until it lands, no PR is auto-closed.
print(f"Auto-close currently disabled, skipping PR #{pr.number}")
return False
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Replace unconditional early return with an explicit feature gate.

At Line 217, the unconditional return False makes Lines 218-280 permanently unreachable. That keeps dead logic in place and increases risk of silent drift while auto-close is disabled.

Proposed refactor
 class StalePRBot(GitHubBot):
     def __init__(self):
         super().__init__()
         self.DAYS_BEFORE_STALE_WARNING = 7
         self.DAYS_BEFORE_UNASSIGN = 14
         self.DAYS_BEFORE_CLOSE = 60
+        self.ENABLE_AUTO_CLOSE = False  # temporary kill-switch
 
     def close_stale_pr(self, pr, days_inactive):
-        # TEMPORARY: auto-close disabled. The stale-detection heuristic
-        # has been closing PRs that are merely blocked by bot reviews
-        # (or by reviews the same reviewer later approved). The proper
-        # fix lives in PR `#668`; until it lands, no PR is auto-closed.
-        print(f"Auto-close currently disabled, skipping PR #{pr.number}")
-        return False
+        if not self.ENABLE_AUTO_CLOSE:
+            print(f"Auto-close currently disabled, skipping PR #{pr.number}")
+            return False
         if pr.state == "closed":
             print(f"PR #{pr.number} is already closed, skipping")
             return True
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# TEMPORARY: auto-close disabled. The stale-detection heuristic
# has been closing PRs that are merely blocked by bot reviews
# (or by reviews the same reviewer later approved). The proper
# fix lives in PR #668; until it lands, no PR is auto-closed.
print(f"Auto-close currently disabled, skipping PR #{pr.number}")
return False
if not self.ENABLE_AUTO_CLOSE:
print(f"Auto-close currently disabled, skipping PR #{pr.number}")
return False
🤖 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 @.github/actions/bot-autoassign/stale_pr_bot.py around lines 212 - 217, The
unconditional early return that prints "Auto-close currently disabled" should be
replaced with a feature gate so the remaining auto-close logic (below the
current return) stays reachable; remove the hardcoded "return False" and instead
check a boolean flag (e.g., an env var like ENABLE_AUTO_CLOSE or a config value)
before returning—if the flag is false, log the same message and return False,
otherwise allow execution to continue into the existing auto-close code that
follows the block referencing pr.number. Update any imports if needed (os or
config) and ensure the new conditional uses that flag to control flow rather
than an unconditional return.

mock_issue.remove_from_assignees.assert_called_once_with("testuser")


@pytest.mark.skip(reason="Auto-close temporarily disabled; see close_stale_pr stub.")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Do not skip the whole close-PR suite; assert disabled behavior instead.

Skipping TestCloseStalePR at Line 332 removes coverage entirely. Keep tests running by asserting the temporary contract (auto-close disabled → returns False, no comment posted, no state edit, no unassign).

Suggested direction
-@pytest.mark.skip(reason="Auto-close temporarily disabled; see close_stale_pr stub.")
 class TestCloseStalePR:
-    def test_success(self, bot_env):
+    def test_disabled_no_side_effects(self, bot_env):
         bot = StalePRBot()
         mock_pr = Mock()
+        mock_pr.number = 1
         mock_pr.body = "Fixes `#123`"
         mock_pr.user.login = "testuser"
         mock_pr.state = "open"
-        ...
-        assert bot.close_stale_pr(mock_pr, 60)
-        mock_pr.create_issue_comment.assert_called_once()
-        ...
-        mock_pr.edit.assert_called_once_with(state="closed")
-        ...
+        assert bot.close_stale_pr(mock_pr, 60) is False
+        mock_pr.create_issue_comment.assert_not_called()
+        mock_pr.edit.assert_not_called()
🤖 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 @.github/actions/bot-autoassign/tests/test_stale_pr_bot.py at line 332,
Remove the `@pytest.mark.skip` on the TestCloseStalePR suite and change the tests
to assert the temporary disabled contract: call the close_stale_pr (or the test
helper that invokes it) and assert it returns False, and assert the side-effect
mocks (e.g., mock_post_comment, mock_edit_state, mock_unassign or whatever
fixtures are used in the test) were not called; keep the test class name
TestCloseStalePR and the close_stale_pr stub reference so the assertions
validate no comment was posted, no state was edited, and no unassign occurred.

@openwisp-companion
Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 97.513%. remained the same — ci/disable-stale-pr-auto-close into master

@nemesifier nemesifier merged commit 091245a into master May 9, 2026
52 of 53 checks passed
@nemesifier nemesifier deleted the ci/disable-stale-pr-auto-close branch May 9, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug github_actions Pull requests that update GitHub Actions code helper-bots Helper bots, release management automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants