Skip to content

[ML] Improve backport automation with label copying and pending tracking#2940

Merged
edsavage merged 2 commits intoelastic:mainfrom
edsavage:backport-label-improvements
Mar 8, 2026
Merged

[ML] Improve backport automation with label copying and pending tracking#2940
edsavage merged 2 commits intoelastic:mainfrom
edsavage:backport-label-improvements

Conversation

@edsavage
Copy link
Contributor

@edsavage edsavage commented Mar 8, 2026

Summary

Improves the backport automation with three changes based on feedback from PR #2917:

  1. copySourcePRLabels (.backportrc.json): Copies labels from the original PR to backport PRs using a regex that excludes backport and v* version labels (to avoid recursive backport triggers). Labels like >bug, >enhancement, :ml will now appear on backport PRs automatically.

  2. sourcePRLabels (.backportrc.json): Adds a backport-pending label to the original PR when backport PRs are created, making it easy to filter which PRs still need backport attention.

  3. Automatic backport-pending removal (backport.yml): When a backport PR is merged, a new remove-backport-pending job extracts the original PR number from the title, checks if all sibling backport PRs are also merged/closed, and removes the backport-pending label from the original PR if none remain open. This completes the full lifecycle — no manual label removal needed.

How it works

Original PR merged with v9.2.7 + v9.3.2 labels
    |
    |-> Backport tool creates backport PRs for 9.2 and 9.3
    |   |- Copies >bug, :ml labels to backport PRs (copySourcePRLabels)
    |   +- Adds backport-pending to original PR (sourcePRLabels)
    |
    |-> Backport PR for 9.3 merged
    |   +- remove-backport-pending job runs -> 1 open backport remains -> label kept
    |
    +-> Backport PR for 9.2 merged
        +- remove-backport-pending job runs -> 0 open backports -> label removed

Test plan

  • Merge a PR with version labels and >bug/:ml labels
  • Verify backport PRs are created with >bug and :ml labels copied
  • Verify the original PR gets the backport-pending label added
  • Verify backport and v* labels are NOT copied to backport PRs
  • Merge one backport PR -> verify backport-pending remains on the original PR
  • Merge the remaining backport PR(s) -> verify backport-pending is removed from the original PR

- Add copySourcePRLabels to copy labels like >bug and :ml from the
  original PR to backport PRs, excluding backport and version labels
  to avoid recursive triggers.
- Add sourcePRLabels to apply a backport-pending label to the original
  PR when backports are created, making it easy to filter PRs that
  still need backport attention.

Made-with: Cursor
@prodsecmachine
Copy link

prodsecmachine commented Mar 8, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

When a backport PR (labelled 'backport') is merged, extract the
original PR number from the title, check if any sibling backport PRs
are still open, and remove the backport-pending label from the
original PR once all backports are complete.

Made-with: Cursor
@edsavage edsavage merged commit 570d24d into elastic:main Mar 8, 2026
4 of 16 checks passed
edsavage added a commit to edsavage/ml-cpp that referenced this pull request Mar 8, 2026
Trivial whitespace change to test the backport workflow improvements
from PR elastic#2940 (copySourcePRLabels, sourcePRLabels, and automatic
backport-pending removal). This commit will be reverted after testing.

Made-with: Cursor
edsavage added a commit that referenced this pull request Mar 8, 2026
Trivial whitespace change to test the backport workflow improvements
from PR #2940 (copySourcePRLabels, sourcePRLabels, and automatic
backport-pending removal). This commit will be reverted after testing.

Made-with: Cursor
github-actions bot pushed a commit that referenced this pull request Mar 8, 2026
Trivial whitespace change to test the backport workflow improvements
from PR #2940 (copySourcePRLabels, sourcePRLabels, and automatic
backport-pending removal). This commit will be reverted after testing.

Made-with: Cursor
(cherry picked from commit 0df84a6)
github-actions bot pushed a commit that referenced this pull request Mar 8, 2026
Trivial whitespace change to test the backport workflow improvements
from PR #2940 (copySourcePRLabels, sourcePRLabels, and automatic
backport-pending removal). This commit will be reverted after testing.

Made-with: Cursor
(cherry picked from commit 0df84a6)
edsavage added a commit that referenced this pull request Mar 8, 2026
Trivial whitespace change to test the backport workflow improvements
from PR #2940 (copySourcePRLabels, sourcePRLabels, and automatic
backport-pending removal). This commit will be reverted after testing.

Made-with: Cursor
(cherry picked from commit 0df84a6)

Co-authored-by: Ed Savage <ed.savage@elastic.co>
edsavage added a commit that referenced this pull request Mar 8, 2026
Trivial whitespace change to test the backport workflow improvements
from PR #2940 (copySourcePRLabels, sourcePRLabels, and automatic
backport-pending removal). This commit will be reverted after testing.

Made-with: Cursor
(cherry picked from commit 0df84a6)

Co-authored-by: Ed Savage <ed.savage@elastic.co>
@edsavage edsavage deleted the backport-label-improvements branch March 8, 2026 21:39
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