Add scheduled workflow to auto-sync fork with upstream#632
Add scheduled workflow to auto-sync fork with upstream#632i-chaochen wants to merge 1 commit intomainfrom
Conversation
Add a GitHub Actions workflow that keeps the rocm/xla fork's main branch in sync with openxla/xla using the merge-upstream API. Runs every 3 hours on weekdays and once daily on weekends, with a manual workflow_dispatch trigger available for on-demand syncing.
There was a problem hiding this comment.
Pull request overview
This PR adds a GitHub Actions workflow to automatically keep the rocm/xla fork synchronized with its upstream repository (openxla/xla). The workflow is designed to run on a schedule - every 3 hours on weekdays and once daily on weekends - with an additional option for manual triggering. This automation supports the long-term goal of maintaining minimal divergence between the fork and upstream, primarily limited to .github directory differences, which will facilitate AI-assisted code review and enhanced CI capabilities.
Changes:
- Added a new scheduled GitHub Actions workflow that uses the GitHub merge-upstream API to automatically sync the main branch
- Configured dual scheduling: 8 times daily (every 3 hours) on weekdays and once daily at 09:00 UTC on weekends
- Included manual workflow_dispatch trigger for on-demand syncing
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,23 @@ | |||
| name: Sync Fork with Upstream | |||
There was a problem hiding this comment.
This workflow file is missing the standard Apache 2.0 copyright header that is consistently used across all other workflow files in this repository. All other workflow files in .github/workflows/ include a copyright header at the top (see ci.yml:1-14, rocm_xla_ci.yml:1-14, ci_multi_device.yml:1-14, cpu_benchmarks_nightly.yml:1-14, buildifier.yml:1-14, etc.). Please add the copyright header to maintain consistency.
| gh api \ | ||
| --method POST \ | ||
| /repos/${{ github.repository }}/merge-upstream \ | ||
| -f branch=main |
There was a problem hiding this comment.
The workflow lacks error handling and notification mechanisms. If the merge-upstream API call fails (e.g., due to merge conflicts, API errors, or authentication issues), the workflow will silently fail without notifying anyone. Consider adding error handling to capture failure scenarios and optionally send notifications (e.g., via GitHub Actions failure notifications or by creating an issue) so that merge conflicts or other problems can be addressed promptly.
| gh api \ | |
| --method POST \ | |
| /repos/${{ github.repository }}/merge-upstream \ | |
| -f branch=main | |
| set -euo pipefail | |
| BRANCH="main" | |
| if ! gh api \ | |
| --method POST \ | |
| /repos/${{ github.repository }}/merge-upstream \ | |
| -f branch="${BRANCH}"; then | |
| echo "::error::Failed to sync fork with upstream for branch '${BRANCH}'. Check for merge conflicts, API errors, or authentication issues." | |
| exit 1 | |
| fi |
| run: | | ||
| gh api \ | ||
| --method POST \ | ||
| /repos/${{ github.repository }}/merge-upstream \ | ||
| -f branch=main |
There was a problem hiding this comment.
Consider adding a conditional check or configuration to handle situations where the upstream and fork have diverged significantly and automatic merging may not be appropriate. The workflow description mentions that "the only divergence for our rocm/xla:main between openxla/xla:main is under .github," but if this assumption is violated in the future, automatic merging could cause issues. Consider adding a check to ensure the merge is only attempted when it's safe to do so, or documenting the expected state clearly.
nurmukhametov
left a comment
There was a problem hiding this comment.
I am confused why the target branch is main. Should it be rocm-dev-infra?
Yes, since we have rocm-dev-infra as the default, we don't need this PR anymore. Later on, we can put code review and performance CI there for our internal release branches |
https://github.com/ROCm/xla/tree/rocm-dev-infra
📝 Summary of Changes
Add a GitHub Actions workflow that keeps the rocm/xla fork's main branch in sync with openxla/xla using the merge-upstream API.
Runs every 3 hours on weekdays and once daily on weekends, with a manual workflow_dispatch trigger available for on-demand syncing.
🎯 Justification
Later on, the only divergence for our
rocm/xla:mainbetweenopenxla/xla:mainis under.githuband this can help us to setup AI agent to code review and more performance CIs