feat(workflow): Add nightly dev-to-main rebase automation#244
feat(workflow): Add nightly dev-to-main rebase automation#244DrunkOnJava merged 1 commit intomainfrom
Conversation
🔍 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 an automated nightly workflow to rebase the dev branch onto main at 3 AM UTC daily, preventing branch divergence in a hybrid development workflow. The automation includes conflict detection, manual resolution workflows, and branch cleanup.
- Automated nightly rebases with conflict detection and resolution
- Success notifications via auto-closed issues and detailed conflict resolution PRs
- Cleanup job to remove old rebase branches after 7 days
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: 'open', | ||
| head: `${context.repo.owner}:rebase-dev-${new Date().toISOString().split('T')[0]}` |
There was a problem hiding this comment.
The head parameter format is incorrect for checking existing PRs. It should be just the branch name without the owner prefix when checking PRs in the same repository.
| head: `${context.repo.owner}:rebase-dev-${new Date().toISOString().split('T')[0]}` | |
| head: `rebase-dev-${new Date().toISOString().split('T')[0]}` |
| repo: context.repo.repo, | ||
| labels: 'rebase-success', | ||
| state: 'open', | ||
| since: today |
There was a problem hiding this comment.
The 'since' parameter expects an ISO 8601 timestamp, but 'today' is in YYYY-MM-DD format. This should be since: today + 'T00:00:00Z' to properly filter issues created today.
| echo "🧹 Cleaning up old rebase branches..." | ||
|
|
||
| # Get all rebase branches older than 7 days | ||
| CUTOFF_DATE=$(date -d '7 days ago' +%Y-%m-%d) |
There was a problem hiding this comment.
The date -d command is not portable and may fail on non-GNU systems like macOS. Since this runs on ubuntu-latest, it should work, but consider using a more portable date calculation or explicitly documenting the GNU date dependency.
| CUTOFF_DATE=$(date -d '7 days ago' +%Y-%m-%d) | |
| CUTOFF_DATE=$(node -e "console.log(new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0])") |
| DIVERGED=$(git rev-list --count origin/main..origin/dev) | ||
|
|
||
| echo "📊 Branch statistics:" | ||
| echo " - Main has $MAIN_COMMITS commits" | ||
| echo " - Dev has $DEV_COMMITS commits" | ||
| echo " - Dev is $DIVERGED commits ahead of main" |
There was a problem hiding this comment.
[nitpick] The variable name 'DIVERGED' is misleading as it represents commits ahead, not actual divergence. Consider renaming to 'AHEAD_COMMITS' or 'DEV_AHEAD' for clarity.
| DIVERGED=$(git rev-list --count origin/main..origin/dev) | |
| echo "📊 Branch statistics:" | |
| echo " - Main has $MAIN_COMMITS commits" | |
| echo " - Dev has $DEV_COMMITS commits" | |
| echo " - Dev is $DIVERGED commits ahead of main" | |
| AHEAD_COMMITS=$(git rev-list --count origin/main..origin/dev) | |
| echo "📊 Branch statistics:" | |
| echo " - Main has $MAIN_COMMITS commits" | |
| echo " - Dev has $DEV_COMMITS commits" | |
| echo " - Dev is $AHEAD_COMMITS commits ahead of main" |
| git rebase --abort | ||
|
|
||
| # Get conflict information | ||
| echo "conflict_files=$(git diff --name-only origin/main origin/dev | head -20 | tr '\n' ' ')" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
[nitpick] The magic number '20' for limiting conflict files should be defined as a variable or constant at the top of the file for better maintainability.
| echo "conflict_files=$(git diff --name-only origin/main origin/dev | head -20 | tr '\n' ' ')" >> $GITHUB_OUTPUT | |
| echo "conflict_files=$(git diff --name-only origin/main origin/dev | head -${{ env.MAX_CONFLICT_FILES }} | tr '\n' ' ')" >> $GITHUB_OUTPUT |
Update PR validation workflow to gracefully handle PRs that contain no Swift files (like workflow-only or documentation PRs): - Check for Swift files before running SwiftLint - Skip Xcode build steps for non-Swift PRs - Make Swift-specific checks conditional This fixes CI failures for PRs #244-#248 which only contain workflow files and scripts. Co-authored-by: Claude <claude@anthropic.com>
Update PR validation workflow to gracefully handle PRs that contain no Swift files (like workflow-only or documentation PRs): - Check for Swift files before running SwiftLint - Skip Xcode build steps for non-Swift PRs - Make Swift-specific checks conditional This fixes CI failures for PRs #244-#248 which only contain workflow files and scripts. Co-authored-by: Claude <claude@anthropic.com>
2da6bd0 to
5531dce
Compare
🔍 PR Validation ResultsBuild Status: ❌ Failed This comment was automatically generated by the PR validation workflow. |
- Check if PR contains Swift file changes before running SwiftLint - Skip Swift-specific checks (TODO/FIXME, security) for non-Swift PRs - Fixes CI failures on workflow-only PRs like #244-#248 This properly handles PRs that only modify workflows, scripts, or documentation without triggering Swift-related validations.
* fix(ci): Only run Swift checks on PRs with Swift changes - Check if PR contains Swift file changes before running SwiftLint - Skip Swift-specific checks (TODO/FIXME, security) for non-Swift PRs - Fixes CI failures on workflow-only PRs like #244-#248 This properly handles PRs that only modify workflows, scripts, or documentation without triggering Swift-related validations. * fix(ci): Also check Swift changes for project generation step The check_swift step needs to use the has_swift_changes output to avoid trying to generate Xcode projects for non-Swift PRs.
Add automated workflow to keep dev branch in sync with main: - Runs daily at 3 AM UTC - Attempts to rebase dev onto main - Creates conflict resolution PR if rebase fails - Cleans up old rebase branches after 7 days - Includes dry-run option for testing This is part 1 of the hybrid workflow implementation, focusing on automated branch synchronization to prevent divergence. Co-authored-by: Claude <claude@anthropic.com>
5531dce to
c189a7e
Compare
🔍 PR Validation ResultsBuild Status: ✅ Passed This comment was automatically generated by the PR validation workflow. |
🔄 Nightly Rebase Workflow
This PR adds an automated workflow to keep the
devbranch in sync withmainthrough nightly rebases.What this adds:
Why this is needed:
In the hybrid workflow,
devcan diverge frommainover time. This automation ensures:Implementation details:
--force-with-leasefor safer force pushesThis is Part 1 of 5 of the hybrid workflow implementation, focusing on the core automation infrastructure.
Related to the hybrid workflow implementation based on developer feedback about balancing automation with human oversight.