Add GitHub Actions workflow to automate cherry-pick hotfix PRs#4106
Add GitHub Actions workflow to automate cherry-pick hotfix PRs#4106paulmedynski wants to merge 11 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Actions workflow to automate creating cherry-pick PRs from merged hotfix PRs onto corresponding release/* branches based on Hotfix <version> labels, streamlining the hotfix backport process.
Changes:
- Introduces
.github/workflows/cherry-pick-hotfix.ymltriggered bypull_requestclosedandlabeledevents. - Detects hotfix versions from PR labels and fans out a matrix job (one cherry-pick per version).
- Creates either a normal cherry-pick PR or a “CONFLICTS” placeholder PR with manual resolution instructions.
| - main | ||
| - feat/** | ||
| - dev/** | ||
| - release/** |
There was a problem hiding this comment.
I think this, and the similar pipeline YAML changes, future-proof us when making new release branches, but I would like a second opinion. I feel like we used to have patterns like this, and then removed them, but I forget why.
| - Tag reviewers based on `CODEOWNERS` file | ||
|
|
||
| ## 🌿 Branch Naming | ||
| - All branches created by AI agents **must** use the `dev/automation/` prefix (e.g. `dev/automation/fix-connection-timeout`). |
There was a problem hiding this comment.
Hopefully this will avoid us having top-level branch paths like copilot/, etc.
eng/pipelines/dotnet-sqlclient-ci-project-reference-pipeline.yml
Outdated
Show resolved
Hide resolved
eng/pipelines/dotnet-sqlclient-ci-package-reference-pipeline.yml
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #4106 +/- ##
==========================================
- Coverage 73.22% 66.48% -6.75%
==========================================
Files 280 274 -6
Lines 43000 65778 +22778
==========================================
+ Hits 31486 43731 +12245
- Misses 11514 22047 +10533
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
269ef41 to
dd13252
Compare
…Hotfix X.Y.Z" labels.
…aming - Switch from pull_request to pull_request_target so fork PRs have write permissions for push and PR creation. - Detect parent count before cherry-pick: only pass --mainline 1 for true merge commits (2+ parents), omit it for squash merges. - Parse major.minor from the Hotfix label version for the target release branch name (e.g. 'Hotfix 7.0.1' targets release/7.0), while preserving the full version in PR titles, milestones, and cherry-pick branch names.
…bel validation - Remove --count from git rev-list so parent detection works correctly for both merge and squash-merge commits - Use CHERRY_PICK_BRANCH variable in conflict resolution instructions instead of hardcoded branch prefix - Tighten Hotfix label regex to only accept X.Y.Z semver format
…estone lookup, MAINLINE_FLAG in body, CI indentation - Add default-branch guard to prevent recursive cherry-picks from release branches - For 'labeled' events, only process the newly added label; skip if cherry-pick branch or PR already exists - Look up milestone before creating PR; if missing, omit --milestone and add a note to the PR description - Build CHERRY_PICK_CMD conditionally so empty MAINLINE_FLAG doesn't produce trailing '' in conflict-resolution instructions - Fix CI pipeline branch list indentation under include:
Add a pre-check using 'git cherry' to determine if the merge commit's patch is already present on the target release branch. If so, the job exits cleanly with a notice instead of producing an empty commit or a misleading CONFLICTS PR.
Move inline shell scripts from cherry-pick-hotfix.yml into standalone files under .github/scripts/: - extract-hotfix-versions.sh: Parses 'Hotfix X.Y.Z' labels from PR metadata and emits a JSON version matrix for fan-out. - cherry-pick-to-release.sh: Cherry-picks a merge commit onto the corresponding release branch and opens a PR (or a CONFLICTS PR with manual resolution instructions). Both scripts include: - Full header documentation with overview, env vars, and examples - Runtime --help / -h support - Input validation with clear error messages - Comments on all non-obvious operations Add bats-core test suites under .github/scripts/tests/: - 18 tests for extract-hotfix-versions.sh (label parsing, edge cases, duplicate detection, event-type handling) - 15 tests for cherry-pick-to-release.sh (version derivation, already-applied detection, merge type handling, milestone lookup, conflict path) Also fixes a quoting bug in the MILESTONE_NOTE assignment that caused 'command not found' when the milestone didn't exist.
- Replace git ls-remote with gh api for branch existence check in extract-hotfix-versions.sh (detect-versions job has no checkout) - Put cherry-pick options (--mainline 1) before SHA operand - Fix conflict-resolution command to put options before SHA - Update bats test mocks to match new gh api usage
…ITORY validation - Replace duplicated --help heredocs with awk extraction of the header comment block in both scripts, eliminating content drift. - Add GITHUB_REPOSITORY to required env var validation in extract-hotfix-versions.sh (was used with set -u but not validated). - Pass --repo to 'gh pr list' so it works without a .git directory. - Set GITHUB_REPOSITORY in bats test setup() for deterministic runs. - Update test assertions to match uppercase header comment headings.
Description
Adds a new GitHub Actions workflow (
.github/workflows/cherry-pick-hotfix.yml) that automates cherry-picking merged PRs into release branches when a "Hotfix <version>" label is present.How it works:
release/<version>.closedandlabeledevents.[<version> Cherry-pick] <original title>.[<version> Cherry-pick - CONFLICTS] <original title>, with manual resolution instructions in the body.Engineering processes (CI, pipelines):
Issues
No linked issue — this is a new engineering workflow to streamline the hotfix process.
Testing
Guidelines
Please review the contribution guidelines before submitting a pull request: