Skip to content

feat(workflow): Add PR management automation#245

Merged
DrunkOnJava merged 1 commit intomainfrom
feat/pr-management-workflow
Jul 31, 2025
Merged

feat(workflow): Add PR management automation#245
DrunkOnJava merged 1 commit intomainfrom
feat/pr-management-workflow

Conversation

@DrunkOnJava
Copy link
Owner

🤖 PR Management Workflow

This PR adds comprehensive PR management automation to support the hybrid workflow model.

What this adds:

  • Auto-labeling system:
    • Size labels (XS to XL based on line changes)
    • Target branch labels (main vs dev)
    • Type labels based on branch naming conventions
  • Contextual PR feedback:
    • Different guidelines for PRs to main vs dev
    • Warnings for large PRs (>500 lines)
    • Clear review process expectations
  • Smart auto-merge for dev:
    • Only for approved PRs under 200 lines
    • Requires all checks to pass
    • Falls back gracefully with error messages
  • Conflict detection:
    • Automatic conflict detection on PR updates
    • Resolution guidance with commands
    • Conflict status labeling
  • Stale PR management:
    • 7-day warning period
    • 14-day auto-close with notification
    • Manual trigger via workflow dispatch

Why this is needed:

The hybrid workflow requires different handling for PRs targeting main vs dev. This automation:

  • Reduces manual PR management overhead
  • Provides consistent labeling and feedback
  • Speeds up development on dev branch while maintaining main stability
  • Helps prevent PR backlog through stale management

Configuration:

  • Auto-merge is limited to dev branch only
  • Size thresholds can be adjusted based on team preferences
  • Stale timings are configurable (currently 7/14 days)

This is Part 2 of 5 of the hybrid workflow implementation.


Implements smart PR automation while maintaining human oversight for critical decisions.

Copilot AI review requested due to automatic review settings July 31, 2025 22:19
@github-actions
Copy link

👋 Welcome to the Hybrid Workflow!

⚠️ Important: This PR targets main directly. Please ensure:

  • This is a critical fix or thoroughly tested feature
  • All tests pass
  • You've considered creating this PR to dev first

PR Guidelines

  • Keep PRs focused on a single feature or fix
  • Ensure all tests pass before review
  • Update documentation if needed
  • Respond to review feedback promptly

Review Process

PRs to main require:

  • Approved review from maintainer
  • All status checks passing
  • No merge conflicts

@github-actions
Copy link

🔍 PR Validation Results

Build Status: ❌ Failed
SwiftLint: ⚠️ Issues found
Project Structure: ❌ Issues found
Compilation: ❌ Failed


This comment was automatically generated by the PR validation workflow.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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).`
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
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).`

Copilot uses AI. Check for mistakes.
Comment on lines +192 to +194
const allChecksPassed = checks.check_runs.every(
check => check.status === 'completed' && check.conclusion === 'success'
);
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
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';

Copilot uses AI. Check for mistakes.

for (const pr of pullRequests) {
const updatedAt = new Date(pr.updated_at);
const daysSinceUpdate = (now - updatedAt) / (1000 * 60 * 60 * 24);
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

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

Suggested change
const daysSinceUpdate = (now - updatedAt) / (1000 * 60 * 60 * 24);
const daysSinceUpdate = (now - updatedAt) / MILLISECONDS_IN_A_DAY;

Copilot uses AI. Check for mistakes.
check => check.status === 'completed' && check.conclusion === 'success'
);

if (!allChecksPassed) {
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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>
@DrunkOnJava DrunkOnJava force-pushed the feat/pr-management-workflow branch from a006209 to e2497d5 Compare July 31, 2025 23:10
@github-actions github-actions bot added size/L and removed size/L labels Jul 31, 2025
@github-actions
Copy link

🔍 PR Validation Results

Build Status: ✅ Passed
SwiftLint: ⚠️ Issues found
Project Structure: ❌ Issues found
Compilation: ❌ Failed


This comment was automatically generated by the PR validation workflow.

@DrunkOnJava DrunkOnJava merged commit 10c4887 into main Jul 31, 2025
7 of 9 checks passed
@DrunkOnJava DrunkOnJava deleted the feat/pr-management-workflow branch July 31, 2025 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants