[feature] Flag invalid pull requests that do not reference validated issues #709#715
Conversation
Implemented automated branch detection to avoid choosing between master and main when only one exists. Fixes openwisp#646
…issues openwisp#709 - Add pull_request_target edited/ready_for_review triggers - Implement regex issue references extraction helper - Add GraphQL project v2 board assignment check - Validate that PRs from external contributors link to open, labeled, and validated organization issues - Apply 'invalid' label and post warning comment if invalid - Automatically close invalid PRs after 24 hours in the stale PR workflow - Update documentation and add unit tests Closes openwisp#709
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThis PR adds PR-validation logic to the GitHub auto-assignment bot suite: Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Contributor
participant IssueAssignmentBot
participant GitHubBot
participant GitHubAPI
Contributor->>IssueAssignmentBot: open/edit/ready_for_review PR
IssueAssignmentBot->>GitHubBot: validate_pr_issues(pr)
GitHubBot->>GitHubAPI: extract linked issues, fetch issue/labels
GitHubAPI-->>GitHubBot: issue data
GitHubBot->>GitHubAPI: get_issue_projects(issue)
GitHubAPI-->>GitHubBot: project titles
GitHubBot-->>IssueAssignmentBot: valid/invalid
alt invalid
IssueAssignmentBot->>GitHubAPI: add "invalid" label
IssueAssignmentBot->>GitHubBot: has_bot_comment(pr, "invalid_unvalidated_issue")
GitHubBot-->>IssueAssignmentBot: comment exists?
IssueAssignmentBot->>GitHubAPI: post warning comment (if not already posted)
else valid
IssueAssignmentBot->>GitHubAPI: remove "invalid" label
end
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
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 |
Checklist
Reference to Existing Issue
Closes #709 .
Description of Changes
This pull request implements validation of pull requests opened by external contributors to ensure they target an issue validated by maintainers.
Key Changes
.github/workflows/bot-autoassign-pr-issue-link.ymltriggers to monitoreditedandready_for_reviewevents onpull_request_target.extract_all_linked_issuesinutils.pyto support same-repo references (#123), cross-repo references (org/repo#123), and absolute issue URLs.validate_pr_issuesinbase.pyto ensure that for external contributors (excluding owners, members, collaborators, and trusted bots), the PR links to an open issue in theopenwisporganization that has at least one label (other thaninvalidorwontfix) and is assigned to one of the authorized Projects v2 boards.invalidand posted a warning comment. When the pull request is updated to target a validated issue, theinvalidlabel is automatically removed.stale_pr_bot.pyto automatically check for pull requests with theinvalidlabel. If the issue remains invalid and 24 hours have elapsed since the warning comment was posted, the bot automatically posts a close message and closes the pull request.test_issue_assignment_bot.pyandtest_stale_pr_bot.pycovering all positive, negative, and edge cases.docs/developer/reusable-github-utils.rstwith the new triggers, workflow requirements, and policies.Screenshot
N/A