feat: Add /reprocess command for full PR workflow reprocessing#894
feat: Add /reprocess command for full PR workflow reprocessing#894
Conversation
WalkthroughAdds a Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (6)📚 Learning: 2024-10-08T09:19:56.185ZApplied to files:
📚 Learning: 2024-10-29T10:42:50.163ZApplied to files:
📚 Learning: 2024-10-29T08:09:57.157ZApplied to files:
📚 Learning: 2025-05-13T12:06:27.297ZApplied to files:
📚 Learning: 2024-10-14T14:13:21.316ZApplied to files:
📚 Learning: 2025-10-28T16:09:08.689ZApplied to files:
🧬 Code graph analysis (1)webhook_server/libs/handlers/pull_request_handler.py (2)
⏰ 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). (10)
🔇 Additional comments (4)
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 |
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
|
/reprocess |
|
Starting full PR reprocessing workflow... |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
webhook_server/tests/test_pull_request_handler.py (1)
1207-1246: Consider more specific assertion for welcome message verification.The test is well-structured and comprehensive. However, the assertion on line 1237 checks for the generic word "Welcome" in the message body. Consider verifying the presence of
issue_url_for_welcome_msginstead, which is the actual marker used by the implementation to detect welcome comments.Apply this refinement:
- assert "Welcome" in mock_comment.call_args[1]["body"] + # Verify welcome message was created with the expected URL marker + assert pull_request_handler.github_webhook.issue_url_for_welcome_msg in mock_comment.call_args[1]["body"]This makes the test more robust and aligns with the actual implementation logic.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
README.md(1 hunks)webhook_server/libs/handlers/issue_comment_handler.py(3 hunks)webhook_server/libs/handlers/pull_request_handler.py(2 hunks)webhook_server/tests/test_issue_comment_handler.py(2 hunks)webhook_server/tests/test_pull_request_handler.py(1 hunks)webhook_server/utils/constants.py(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2024-10-08T09:19:56.185Z
Learnt from: myakove
Repo: myk-org/github-webhook-server PR: 586
File: webhook_server_container/libs/github_api.py:1947-1956
Timestamp: 2024-10-08T09:19:56.185Z
Learning: In `webhook_server_container/libs/github_api.py`, the indentation style used in the `set_pull_request_automerge` method is acceptable as per the project's coding standards.
Applied to files:
webhook_server/libs/handlers/pull_request_handler.py
📚 Learning: 2024-10-29T08:09:57.157Z
Learnt from: myakove
Repo: myk-org/github-webhook-server PR: 612
File: webhook_server_container/libs/github_api.py:2089-2100
Timestamp: 2024-10-29T08:09:57.157Z
Learning: In `webhook_server_container/libs/github_api.py`, when the function `_keep_approved_by_approvers_after_rebase` is called, existing approval labels have already been cleared after pushing new changes, so there's no need to check for existing approvals within this function.
Applied to files:
webhook_server/libs/handlers/pull_request_handler.py
📚 Learning: 2024-10-29T10:42:50.163Z
Learnt from: myakove
Repo: myk-org/github-webhook-server PR: 612
File: webhook_server_container/libs/github_api.py:925-926
Timestamp: 2024-10-29T10:42:50.163Z
Learning: In `webhook_server_container/libs/github_api.py`, the method `self._keep_approved_by_approvers_after_rebase()` must be called after removing labels when synchronizing a pull request. Therefore, it should be placed outside the `ThreadPoolExecutor` to ensure it runs sequentially after label removal.
Applied to files:
webhook_server/libs/handlers/pull_request_handler.py
📚 Learning: 2024-10-15T10:37:45.791Z
Learnt from: myakove
Repo: myk-org/github-webhook-server PR: 598
File: webhook_server_container/libs/github_api.py:1860-1874
Timestamp: 2024-10-15T10:37:45.791Z
Learning: In the `process_retest_command` method in `webhook_server_container/libs/github_api.py`, `_target_tests` is defined before use.
Applied to files:
webhook_server/tests/test_issue_comment_handler.py
🧬 Code graph analysis (4)
webhook_server/libs/handlers/pull_request_handler.py (2)
webhook_server/tests/conftest.py (4)
pull_request(115-116)PullRequest(99-111)github_webhook(120-140)create_issue_comment(107-107)webhook_server/utils/helpers.py (1)
format_task_fields(113-132)
webhook_server/libs/handlers/issue_comment_handler.py (2)
webhook_server/libs/handlers/owners_files_handler.py (1)
is_user_valid_to_run_commands(330-362)webhook_server/libs/handlers/pull_request_handler.py (1)
process_command_reprocess(1188-1220)
webhook_server/tests/test_issue_comment_handler.py (3)
webhook_server/libs/handlers/issue_comment_handler.py (2)
IssueCommentHandler(44-442)user_commands(159-308)webhook_server/libs/handlers/owners_files_handler.py (1)
is_user_valid_to_run_commands(330-362)webhook_server/utils/constants.py (1)
REACTIONS(79-87)
webhook_server/tests/test_pull_request_handler.py (1)
webhook_server/libs/handlers/pull_request_handler.py (4)
_welcome_comment_exists(1120-1127)_generate_issue_body(786-787)_tracking_issue_exists(1129-1133)process_new_or_reprocess_pull_request(1135-1186)
🪛 markdownlint-cli2 (0.18.1)
README.md
1164-1164: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
🔇 Additional comments (10)
webhook_server/libs/handlers/pull_request_handler.py (1)
1195-1219: Merged PR guard looks solidSkipping
/reprocessonce a PR is merged avoids wasting API calls and keeps the workflow side-effect free. Nice touch.webhook_server/tests/test_pull_request_handler.py (9)
1091-1114: LGTM! Comprehensive test for merged PR rejection.The test correctly verifies that
/reprocesson a merged PR posts a rejection message and skips the workflow execution. The mocking strategy and assertions are appropriate.
1116-1136: LGTM! Proper test for successful reprocess workflow.The test correctly verifies that
/reprocesson an open PR posts a starting message and triggers the full workflow. Good use of mocks and assertions.
1138-1169: LGTM! Thorough coverage of welcome comment existence checks.The three test cases comprehensively cover the
_welcome_comment_existshelper method: when the welcome message exists, when it doesn't, and when there are no comments. Good test design.
1171-1205: LGTM! Complete coverage of tracking issue existence checks.The three test cases thoroughly cover the
_tracking_issue_existshelper method with all relevant scenarios. Proper use of_generate_issue_bodyensures consistency with the actual implementation.
1248-1271: LGTM! Proper test for welcome message duplicate prevention.The test correctly verifies that the workflow skips creating a welcome message when one already exists, demonstrating the duplicate prevention logic works as expected.
1273-1298: LGTM! Proper test for tracking issue duplicate prevention.The test correctly verifies that the workflow skips creating a tracking issue when one already exists, demonstrating the duplicate prevention logic works as expected.
1300-1327: LGTM! Important edge case for dual duplicate prevention.The test correctly verifies that when both welcome message and tracking issue already exist, they are both skipped while the core workflow tasks still execute. This is an important edge case for the
/reprocesscommand.
1329-1348: LGTM! Verifies parallel execution pattern.The test confirms that
asyncio.gatheris used for parallel task execution. While this doesn't test actual concurrency behavior, it appropriately verifies the implementation pattern at the unit test level.
1350-1376: LGTM! Excellent test for workflow resilience.The test correctly verifies that when one task fails with an exception, the error is logged and the workflow continues (including automerge). This demonstrates the robustness of the error handling implementation using
asyncio.gatherwithreturn_exceptions=True.
Implement new user command `/reprocess` that triggers complete PR workflow reprocessing from scratch. This is useful when webhooks fail, processing is interrupted, or configuration changes require re-evaluation. Changes: - Add COMMAND_REPROCESS_STR constant - Implement process_command_reprocess() with merged PR check - Add helper methods for duplicate prevention: - _welcome_comment_exists() - check for existing welcome message - _tracking_issue_exists() - check for existing tracking issue - Extract reusable process_new_or_reprocess_pull_request() method - Add command handler in issue_comment_handler with OWNERS permission check - Update welcome message documentation - Add comprehensive tests (24 test cases, 90.22% coverage) - Update README with full command documentation Features: - Permission-gated (requires user in OWNERS file) - Skips merged PRs with clear message - Prevents duplicate welcome messages and tracking issues - Re-runs full workflow: reviewers, labels, checks, CI/CD - Comprehensive logging with logger.step() tracking
bea95e1 to
bfec32d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
README.md(1 hunks)webhook_server/libs/handlers/issue_comment_handler.py(3 hunks)webhook_server/libs/handlers/pull_request_handler.py(2 hunks)webhook_server/tests/test_issue_comment_handler.py(2 hunks)webhook_server/tests/test_pull_request_handler.py(1 hunks)webhook_server/utils/constants.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- webhook_server/utils/constants.py
- webhook_server/libs/handlers/issue_comment_handler.py
- README.md
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2024-10-15T10:37:45.791Z
Learnt from: myakove
Repo: myk-org/github-webhook-server PR: 598
File: webhook_server_container/libs/github_api.py:1860-1874
Timestamp: 2024-10-15T10:37:45.791Z
Learning: In the `process_retest_command` method in `webhook_server_container/libs/github_api.py`, `_target_tests` is defined before use.
Applied to files:
webhook_server/tests/test_issue_comment_handler.py
📚 Learning: 2024-10-08T09:19:56.185Z
Learnt from: myakove
Repo: myk-org/github-webhook-server PR: 586
File: webhook_server_container/libs/github_api.py:1947-1956
Timestamp: 2024-10-08T09:19:56.185Z
Learning: In `webhook_server_container/libs/github_api.py`, the indentation style used in the `set_pull_request_automerge` method is acceptable as per the project's coding standards.
Applied to files:
webhook_server/libs/handlers/pull_request_handler.py
📚 Learning: 2024-10-29T08:09:57.157Z
Learnt from: myakove
Repo: myk-org/github-webhook-server PR: 612
File: webhook_server_container/libs/github_api.py:2089-2100
Timestamp: 2024-10-29T08:09:57.157Z
Learning: In `webhook_server_container/libs/github_api.py`, when the function `_keep_approved_by_approvers_after_rebase` is called, existing approval labels have already been cleared after pushing new changes, so there's no need to check for existing approvals within this function.
Applied to files:
webhook_server/libs/handlers/pull_request_handler.py
📚 Learning: 2024-10-29T10:42:50.163Z
Learnt from: myakove
Repo: myk-org/github-webhook-server PR: 612
File: webhook_server_container/libs/github_api.py:925-926
Timestamp: 2024-10-29T10:42:50.163Z
Learning: In `webhook_server_container/libs/github_api.py`, the method `self._keep_approved_by_approvers_after_rebase()` must be called after removing labels when synchronizing a pull request. Therefore, it should be placed outside the `ThreadPoolExecutor` to ensure it runs sequentially after label removal.
Applied to files:
webhook_server/libs/handlers/pull_request_handler.py
🧬 Code graph analysis (3)
webhook_server/tests/test_issue_comment_handler.py (3)
webhook_server/libs/handlers/issue_comment_handler.py (2)
IssueCommentHandler(44-442)user_commands(159-308)webhook_server/libs/handlers/owners_files_handler.py (1)
is_user_valid_to_run_commands(330-362)webhook_server/utils/constants.py (1)
REACTIONS(79-87)
webhook_server/libs/handlers/pull_request_handler.py (2)
webhook_server/tests/conftest.py (3)
pull_request(115-116)PullRequest(99-111)create_issue_comment(107-107)webhook_server/utils/helpers.py (1)
format_task_fields(113-132)
webhook_server/tests/test_pull_request_handler.py (1)
webhook_server/libs/handlers/pull_request_handler.py (6)
PullRequestHandler(45-1212)process_command_reprocess(1188-1212)_welcome_comment_exists(1120-1127)_generate_issue_body(786-787)_tracking_issue_exists(1129-1133)process_new_or_reprocess_pull_request(1135-1186)
…locking Fixed blocking GitHub API calls in _welcome_comment_exists and _tracking_issue_exists methods by moving the entire fetch-and-filter operation inside background threads: - _welcome_comment_exists: Moved comment iteration inside nested function - _tracking_issue_exists: Moved issue iteration inside nested function This prevents synchronous HTTP calls from blocking the event loop when iterating over PaginatedList objects. Addresses CodeRabbit review comment about keeping GitHub API calls off the event loop. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
/reprocess |
|
/lgtm |
|
/verified |
|
New container for ghcr.io/myk-org/github-webhook-server:latest published |
Implement new user command
/reprocessthat triggers complete PR workflow reprocessing from scratch. This is useful when webhooks fail, processing is interrupted, or configuration changes require re-evaluation.Changes:
Features:
Summary by CodeRabbit
New Features
/reprocesscommand to re-run PR initialization and workflows for open PRs (available to OWNERS); welcome message now references/reprocess.Documentation
/reprocess, examples, permissions, behavior, and onboarding notes.Tests
/reprocess, duplicate detection, parallel execution, error handling, and related PR initialization paths.