Skip to content

[code-infra] Allow cherry-picking after merge - #49207

Open
Janpot wants to merge 3 commits into
mui:masterfrom
Janpot:cherry-pick-after-merge
Open

Janpot wants to merge 3 commits into
mui:masterfrom
Janpot:cherry-pick-after-merge

Conversation

@Janpot

@Janpot Janpot commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

The cherry-pick workflow only runs when a PR is closed, and it reads the labels from that event. If needs cherry-pick or the target branch label is added after merge, nothing happens and there is no way to retrigger it.

This also runs the workflow when a label is added to a merged PR that has needs cherry-pick, as long as the added label is needs cherry-pick itself or a v*.x target label. The labels can be added in either order. To retry a failed cherry-pick, remove and re-add needs cherry-pick. Merged PRs without needs cherry-pick no longer start a run that the shared workflow skips anyway.

The shared workflow in mui-public already handles this: it reads the merge commit and PR details from the API instead of the event, and skips when a cherry-pick PR for that branch is already open, so re-adding a label never creates a duplicate.

@code-infra-dashboard

code-infra-dashboard Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-49207--material-ui.netlify.app/
QR code for https://deploy-preview-49207--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@Janpot
Janpot marked this pull request as ready for review September 25, 2026 08:10

@LukasTy LukasTy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice initiative.

Claude raised some concerns.

contains(github.event.pull_request.labels.*.name, 'needs cherry-pick') && (
github.event.action == 'closed' ||
github.event.label.name == 'needs cherry-pick' ||
(startsWith(github.event.label.name, 'v') && endsWith(github.event.label.name, '.x'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Claude Opus 5.5 observation

Adding a v*.x label re-runs the cherry-pick for every target label on the PR, not only for the new label. detectTargetBranch.js reads all v*.x labels, and the open-PR check skips a branch only while its cherry-pick PR is still open.

Example: the PR has needs cherry-pick + v9.x. The v9.x cherry-pick PR gets a manual conflict fix and is merged. Later, someone adds v8.x. The new run cherry-picks onto v9.x again with -X theirs. The conflicting hunks resolve to the master version, so the result is not empty. A new v9.x PR opens and reverts the manual fix. If the v9.x cherry-pick PR was closed as unwanted, the run opens it again.

The shared workflow already has a single-branch mode. We can use it for version-label events:

    with:
      target_branch: ${{ github.event.action == 'labeled' && github.event.label.name != 'needs cherry-pick' && github.event.label.name || '' }}
      pr_number: ${{ github.event.action == 'labeled' && github.event.label.name != 'needs cherry-pick' && format('{0}', github.event.pull_request.number) || '' }}

The retry path (remove and re-add needs cherry-pick) still re-runs all branches. The PR body can say that a retry also runs again on branches that already succeeded.

- 'v*.x'
- 'master'
types: ['closed']
types: ['closed', 'labeled']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Claude Opus 5.5 observation

If someone adds needs cherry-pick and v9.x in one label-picker action after merge, GitHub sends one labeled event per label. Each payload has the full label list, so both events pass this gate and start two runs.

Only one cherry-pick PR opens, because the concurrency group in the shared workflow runs the open step one at a time. But both detect jobs post "Cherry-pick PRs will be created targeting branches: v9.x" on the PR. If one action adds three labels, the newest queued job also cancels the pending job, and a cancelled run shows in the Actions tab.

I did not test this. A possible fix is in mui-public: post the comment from the open job after gh pr create, and include the new PR URL. The second run then stops at the existing-PR check and posts nothing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants