feat(workflow): Add PR management automation#245
Conversation
👋 Welcome to the Hybrid Workflow!
PR Guidelines
Review ProcessPRs to
|
🔍 PR Validation ResultsBuild Status: ❌ Failed This comment was automatically generated by the PR validation workflow. |
There was a problem hiding this comment.
Pull Request Overview
This PR implements comprehensive GitHub workflow automation for PR management, supporting a hybrid development workflow with different handling for PRs targeting main vs dev branches.
- Automated PR labeling system based on size, target branch, and source branch naming conventions
- Contextual feedback and guidelines for newly opened PRs with special handling for large PRs and main branch targets
- Smart auto-merge functionality for small approved PRs to the dev branch with fallback error handling
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pr.number, | ||
| body: `⚠️ **Merge conflicts detected!**\n\nThis PR has conflicts with the base branch that must be resolved.\n\n### To resolve:\n\`\`\`bash\ngit checkout ${pr.head.ref}\ngit fetch origin\ngit rebase origin/${pr.base.ref}\n# Fix conflicts\ngit push --force-with-lease\n\`\`\`\n\nNeed help? Check our [conflict resolution guide](../docs/CONFLICT_RESOLUTION.md).` |
There was a problem hiding this comment.
The link to the conflict resolution guide uses a relative path ../docs/CONFLICT_RESOLUTION.md which may not resolve correctly from a GitHub comment. Consider using an absolute URL or removing the link if the documentation doesn't exist.
| body: `⚠️ **Merge conflicts detected!**\n\nThis PR has conflicts with the base branch that must be resolved.\n\n### To resolve:\n\`\`\`bash\ngit checkout ${pr.head.ref}\ngit fetch origin\ngit rebase origin/${pr.base.ref}\n# Fix conflicts\ngit push --force-with-lease\n\`\`\`\n\nNeed help? Check our [conflict resolution guide](../docs/CONFLICT_RESOLUTION.md).` | |
| body: `⚠️ **Merge conflicts detected!**\n\nThis PR has conflicts with the base branch that must be resolved.\n\n### To resolve:\n\`\`\`bash\ngit checkout ${pr.head.ref}\ngit fetch origin\ngit rebase origin/${pr.base.ref}\n# Fix conflicts\ngit push --force-with-lease\n\`\`\`\n\nNeed help? Check our [conflict resolution guide](https://github.com/<owner>/<repo>/blob/main/docs/CONFLICT_RESOLUTION.md).` |
| const allChecksPassed = checks.check_runs.every( | ||
| check => check.status === 'completed' && check.conclusion === 'success' | ||
| ); |
There was a problem hiding this comment.
The auto-merge logic only checks check_runs but ignores status checks from the legacy status API. This could cause auto-merge to proceed when some status checks haven't passed. Consider also checking github.rest.repos.getCombinedStatusForRef() for complete validation.
| const allChecksPassed = checks.check_runs.every( | |
| check => check.status === 'completed' && check.conclusion === 'success' | |
| ); | |
| // Fetch combined status from the legacy status API | |
| const { data: combinedStatus } = await github.rest.repos.getCombinedStatusForRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: pr.head.sha | |
| }); | |
| const allChecksPassed = checks.check_runs.every( | |
| check => check.status === 'completed' && check.conclusion === 'success' | |
| ) && combinedStatus.state === 'success'; |
|
|
||
| for (const pr of pullRequests) { | ||
| const updatedAt = new Date(pr.updated_at); | ||
| const daysSinceUpdate = (now - updatedAt) / (1000 * 60 * 60 * 24); |
There was a problem hiding this comment.
[nitpick] The magic number (1000 * 60 * 60 * 24) for milliseconds in a day should be extracted to a named constant for better readability and maintainability.
| const daysSinceUpdate = (now - updatedAt) / (1000 * 60 * 60 * 24); | |
| const daysSinceUpdate = (now - updatedAt) / MILLISECONDS_IN_A_DAY; |
| check => check.status === 'completed' && check.conclusion === 'success' | ||
| ); | ||
|
|
||
| if (!allChecksPassed) { |
There was a problem hiding this comment.
When there are no check runs, checks.check_runs.every() will return true, potentially allowing auto-merge when no checks have actually run. Consider checking if checks.check_runs.length > 0 before evaluating the results.
Add comprehensive PR management workflow to support hybrid development: - Auto-labeling by size, target branch, and type - PR feedback with guidelines based on target branch - Auto-merge for small approved PRs to dev (< 200 lines) - Conflict detection with resolution guidance - Stale PR management (7-day warning, 14-day close) This workflow balances automation with human oversight, making PR management more efficient while maintaining code quality standards. Part 2 of the hybrid workflow implementation. Co-authored-by: Claude <claude@anthropic.com>
a006209 to
e2497d5
Compare
🔍 PR Validation ResultsBuild Status: ✅ Passed This comment was automatically generated by the PR validation workflow. |
🤖 PR Management Workflow
This PR adds comprehensive PR management automation to support the hybrid workflow model.
What this adds:
Why this is needed:
The hybrid workflow requires different handling for PRs targeting main vs dev. This automation:
Configuration:
This is Part 2 of 5 of the hybrid workflow implementation.
Implements smart PR automation while maintaining human oversight for critical decisions.