feat: Add automerge command and functionality#812
Conversation
|
Warning Rate limit exceeded@myakove has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 15 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughThis change introduces a new Changes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
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 ProcessAvailable Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
|
/retest tox |
1 similar comment
|
/retest tox |
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
webhook_server/libs/issue_comment_handler.py (1)
358-358: Use constant instead of hardcoded string.Replace the hardcoded "automerge" string with the
AUTOMERGE_LABEL_STRconstant for consistency.- if automerge: - await self.labels_handler._add_label(pull_request=pull_request, label="automerge") + if automerge: + await self.labels_handler._add_label(pull_request=pull_request, label=AUTOMERGE_LABEL_STR)
🧹 Nitpick comments (1)
README.md (1)
626-642: Fix markdown line length violations.The documentation content is excellent, but several lines exceed the 120-character limit as flagged by markdownlint.
Apply these line breaks to fix the formatting:
-| `/automerge` | Enable automatic merging when all requirements are met (maintainers/approvers only) | `/automerge` | +| `/automerge` | Enable automatic merging when all requirements are met (maintainers and approvers only) | `/automerge` | -| `/assign-reviewer` | Assign specific reviewer | `/assign-reviewer @username` | +| `/assign-reviewer` | Assign specific reviewer | `/assign-reviewer @username` | -| `/check-can-merge` | Checks if the pull request meets all merge requirements | `/check-can-merge` | +| `/check-can-merge` | Check if PR meets merge requirements | `/check-can-merge` | -| `/retest <test-name>` | Run specific tests like `tox` or `pre-commit` | `/retest <test-name>` | +| `/retest <test-name>` | Run specific tests like `tox` or `pre-commit` | `/retest <test-name>` |
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
README.md(1 hunks)webhook_server/libs/check_run_handler.py(3 hunks)webhook_server/libs/github_api.py(1 hunks)webhook_server/libs/issue_comment_handler.py(3 hunks)webhook_server/libs/pull_request_handler.py(4 hunks)webhook_server/libs/runner_handler.py(1 hunks)webhook_server/tests/test_app.py(1 hunks)webhook_server/utils/constants.py(2 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
628-628: Line length
Expected: 120; Actual: 123
(MD013, line-length)
630-630: Line length
Expected: 120; Actual: 122
(MD013, line-length)
631-631: Line length
Expected: 120; Actual: 123
(MD013, line-length)
632-632: Line length
Expected: 120; Actual: 133
(MD013, line-length)
633-633: Line length
Expected: 120; Actual: 126
(MD013, line-length)
634-634: Line length
Expected: 120; Actual: 132
(MD013, line-length)
635-635: Line length
Expected: 120; Actual: 128
(MD013, line-length)
639-639: Line length
Expected: 120; Actual: 123
(MD013, line-length)
641-641: Line length
Expected: 120; Actual: 126
(MD013, line-length)
🪛 Pylint (3.3.7)
webhook_server/libs/check_run_handler.py
[error] 8-8: Cannot import 'webhook_server.libs.owners_files_handler' due to 'f-string expression part cannot include a backslash (webhook_server.libs.owners_files_handler, line 269)'
(E0001)
[error] 8-8: No name 'owners_files_handler' in module 'webhook_server.libs'
(E0611)
⏰ Context from checks skipped due to timeout of 90000ms (13)
- GitHub Check: can-be-merged
- GitHub Check: can-be-merged
- GitHub Check: can-be-merged
- GitHub Check: tox
- GitHub Check: can-be-merged
- GitHub Check: can-be-merged
- GitHub Check: can-be-merged
- GitHub Check: can-be-merged
- GitHub Check: conventional-title
- GitHub Check: python-module-install
- GitHub Check: build-container
- GitHub Check: pre-commit
- GitHub Check: tox
🔇 Additional comments (11)
webhook_server/tests/test_app.py (1)
13-13: Verify that signature verification functionality is still adequately tested.The removal of
verify_signaturefrom the imports (along with the mentioned removal of its direct unit tests) suggests this function was refactored or relocated. While signature verification is still tested indirectly through integration tests liketest_process_webhook_signature_verification_failure, ensure that:
- The signature verification functionality hasn't been accidentally removed
- Test coverage for signature verification edge cases remains comprehensive
- The refactored implementation maintains the same security guarantees
#!/bin/bash # Description: Verify signature verification functionality still exists and is tested # Expected: Find signature verification logic in the codebase and confirm test coverage echo "=== Searching for signature verification logic ===" rg -A 10 -B 5 "signature.*verif|verif.*signature" --type py echo -e "\n=== Searching for webhook signature handling ===" rg -A 10 -B 5 "x-hub-signature|hub.signature|hmac.*sha256" --type py echo -e "\n=== Checking for any remaining verify_signature references ===" rg "verify_signature" --type pywebhook_server/utils/constants.py (1)
31-47: LGTM! Clean and consistent constant definitions.The new automerge constants follow the established naming patterns and the color choice ("0E8A16") appropriately matches other approval-related labels.
webhook_server/libs/runner_handler.py (2)
30-30: Good defensive programming approach.The fallback initialization ensures
owners_file_handleris always available, which supports the new automerge functionality reliably.
36-38: LGTM! Proper dependency injection.Passing the
owners_file_handlertoCheckRunHandlerenables the automerge functionality while maintaining clean separation of concerns.webhook_server/libs/pull_request_handler.py (3)
52-54: LGTM! Consistent with dependency injection pattern.Passing
owners_file_handlertoCheckRunHandleraligns with the changes in other handlers and enables automerge functionality.
166-166: Good integration with existing label logic.Adding
AUTOMERGE_LABEL_STRto the merge check trigger condition alongsideWIP_STRandHOLD_LABEL_STRis logical since all these labels affect merge eligibility.
231-231: Clear documentation for users.The welcome message properly documents the new command with appropriate permission restrictions noted.
webhook_server/libs/issue_comment_handler.py (1)
219-219: Good exclusion logic for automerge command.Properly excluding
AUTOMERGE_LABEL_STRfrom generic label handling since it has dedicated logic above.webhook_server/libs/github_api.py (1)
158-165: LGTM! Consistent pattern with other event handlers.The changes follow the same pattern established for other webhook event handlers (
issue_comment,pull_request,pull_request_review) by initializing theOwnersFileHandlerand passing it to the respective handler. This enables the automerge functionality for check run events.webhook_server/libs/check_run_handler.py (2)
30-41: LGTM! Constructor changes follow good patterns.The constructor changes properly handle the optional
OwnersFileHandlerand conditionally create theLabelsHandler. The type checking and conditional initialization are implemented correctly.
7-8: Address import issues flagged by static analysis.Static analysis tools are reporting import errors for
owners_files_handlermodule, suggesting there may be syntax issues (f-string with backslash at line 269) in the imported module.#!/bin/bash # Description: Check for syntax issues in the owners_files_handler module # Expected: Find any f-string syntax issues or import problems # Check for f-string syntax issues with backslashes rg -n "f[\"'][^\"']*\\\\[^\"']*[\"']" webhook_server/libs/owners_files_handler.py # Check if the module can be imported properly python -c " try: from webhook_server.libs.owners_files_handler import OwnersFileHandler print('Import successful') except Exception as e: print(f'Import failed: {e}') "
|
New container for ghcr.io/myk-org/github-webhook-server:latest published |
This commit introduces a new /automerge command that allows authorized users (maintainers and approvers) to enable automatic merging for a pull request once all requirements are met.
The automerge label is added to the pull request upon successful command execution. The webhook server will then monitor the PR's status and merge it automatically when all checks and approval requirements are satisfied.
Key changes include:
Implemented the /automerge command logic in IssueCommentHandler.
Added permission checks to ensure only authorized users can use the command.
Updated PullRequestHandler and CheckRunHandler to support the automerge workflow.
Fixed existing tests that failed due to recent refactoring.
Updated the README.md and the pull request welcome message to document the new command.
Summary by CodeRabbit
New Features
/automergecommand, allowing maintainers and approvers to enable automatic merging of pull requests when all requirements are met.Documentation
/automergecommand and other user commands, including usage examples for review, approval, and testing workflows.Tests