Repository navigation
ci: rewrite the upstream-sync bot: real merge, new branch, open a PR, never approve - #21
Merged
Merged
Conversation
… never approve The old job force-pushed the shared sync/upstream-latest branch, committed conflict markers (or, in mlx-swift, overwrote the tree with upstream), and masked PR-creation failures with `|| echo`. The job now runs .github/scripts/upstream-sync.sh: - merges mlx-swift's upstream main into a scratch worktree as a real two-parent merge (no -X ours/theirs); conflicts are never pushed, the run ends red with a report instead; - restores the fork's .github/workflows byte for byte and checks the result; - pushes ONLY a new branch bot/upstream-<up7>-<base7> (never an existing one, never forced) and opens a PR with `gh pr create`, SWIFTLM_PR_TOKEN first so CI starts, then GITHUB_TOKEN; if neither can, it ends red with a pre-filled compare link; - never approves, reviews, merges, comments on or edits a PR, and does not enable auto-merge; - stays quiet (green) while a sync PR is open, and never reopens a branch whose PR was closed. A dry run (the default outside GitHub Actions, or the workflow_dispatch dry_run input) pushes nothing and opens nothing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Rewrites the "🔄 Auto-Sync Upstream" workflow (
upstream-sync.yml). The bot may still open a PR on its own, but it never approves, reviews or merges anything.Why
The old job had three defects (from its run logs and from reading it):
git checkout upstream/main -- ., which overwrites the whole tree with upstream. Merging its PR would have wiped every fork patch (TurboQuant, SSD streaming, the scoped-device compile fix, ...).sync/upstream-latestevery day.gh pr createwas hidden by an|| echofallback, so a run could stay green without opening a PR.What the bot does now
The logic moved into
.github/scripts/upstream-sync.sh(the same file is proposed for SharpAI/mlx-swift-lm); the workflow only sets env vars and runs it.ml-explore/mlx-swift. If this fork already contains upstream, or a sync PR is already open, the run ends green and does nothing. A sync PR open for 7+ days adds a warning.--no-ff, no-X ours/theirs, no cherry-picks)..github/workflowsand checks that the merge commit leaves it identical tomain(the default token cannot push workflow changes).bot/upstream-<upstream sha7>-<main sha7>with a plaingit push: never forced, never an existing branch. If the branch already exists it must hold the same merge, otherwise the run ends red.gh pr create:SWIFTLM_PR_TOKENfirst (CI starts normally), thenGITHUB_TOKEN(CI does not start until someone closes and reopens the PR). If neither can, the run ends red with a pre-filled "open PR" link. A PR a person closed is not reopened or duplicated.Package.swiftandSource/Cmlx, and reports an advisoryswiftc -parseof the changed Swift files. The "I have read this PR description" box is left unchecked.What it never does
gh pr create.SWIFTLM_PR_TOKENis passed to thegh pr createprocess only.Note: the repo setting "Allow GitHub Actions to create and approve pull requests" is a single checkbox and cannot separate creating from approving. It is currently on, so the guarantee above comes from the script, not from the setting.
What to expect after merging
Source/Cmlx/mlxandSource/Cmlx/mlx-care vendored as plain trees here (upstream uses submodule gitlinks), so an upstream bump of either one will conflict and end the run red. It needs a manual sync like Sync upstream ml-explore/mlx-swift (mlx v0.32.2, mlx-c ebc88f1) via real merge #20; the conflict report says so.b4f7684), so the first real run should end green without a PR.sync/upstream-latestandsync/upstream-0.32.3-mergeare not touched by the new job and can be deleted.dry_run.Tests
The test harness is not part of this PR; it lives outside the repo.
gh: 4336 checks in 26 scenarios, 0 failures (clean merge, conflicts, workflow-only conflicts, rejected push, existing branch, PR already open / closed earlier, token failures, hostile file names, dry run, cleanup). It ran on macOS with bash 3.2 only.gh pr create(mocked in the harness). The first real run should be adry_rundispatch.Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changesAI usage
accurately describes the code changes.
🤖 Generated with Claude Code