Skip to content

Commit e99edf6

Browse files
authored
[workflows] Drop the intermediate /branch comment for release workflow (#79481)
We used to support a /branch comment to specify a branch with commits to backport to the release branch. However, now that we can use pull requests this is not needed. This also simplifies the process, because now the cherry-pick job can create the pull request directly instead of having it split across two separate jobs.
1 parent 92ae2ca commit e99edf6

File tree

3 files changed

+14
-52
lines changed

3 files changed

+14
-52
lines changed

.github/workflows/issue-release-workflow.yml

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
runs-on: ubuntu-latest
3636
permissions:
3737
issues: write
38+
pull-requests: write
3839
if: >-
3940
(github.repository == 'llvm/llvm-project') &&
4041
!startswith(github.event.comment.body, '<!--IGNORE-->') &&
@@ -65,35 +66,3 @@ jobs:
6566
--branch-repo-token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
6667
--issue-number ${{ github.event.issue.number }} \
6768
auto
68-
69-
create-pull-request:
70-
name: Create Pull Request
71-
runs-on: ubuntu-latest
72-
permissions:
73-
issues: write
74-
pull-requests: write
75-
if: >-
76-
(github.repository == 'llvm/llvm-project') &&
77-
!startswith(github.event.comment.body, '<!--IGNORE-->') &&
78-
contains(github.event.comment.body, '/branch ')
79-
80-
steps:
81-
- name: Fetch LLVM sources
82-
uses: actions/checkout@v4
83-
with:
84-
persist-credentials: false
85-
86-
- name: Setup Environment
87-
run: |
88-
pip install -r ./llvm/utils/git/requirements.txt
89-
90-
- name: Create Pull Request
91-
run: |
92-
printf "%s" "$COMMENT_BODY" |
93-
./llvm/utils/git/github-automation.py \
94-
--repo "$GITHUB_REPOSITORY" \
95-
--token ${{ github.token }} \
96-
release-workflow \
97-
--branch-repo-token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
98-
--issue-number ${{ github.event.issue.number }} \
99-
auto

llvm/docs/GitHub.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ Releases
360360
Backporting Fixes to the Release Branches
361361
-----------------------------------------
362362
You can use special comments on issues to make backport requests for the
363-
release branches. This is done by making a comment containing one of the
364-
following commands on any issue that has been added to one of the "X.Y.Z Release"
363+
release branches. This is done by making a comment containing the following
364+
command on any issue that has been added to one of the "X.Y.Z Release"
365365
milestones.
366366

367367
::
@@ -374,10 +374,6 @@ apply cleanly, then a comment with a link to the failing job will be added to
374374
the issue. If the commit(s) do apply cleanly, then a pull request will
375375
be created with the specified commits.
376376

377-
::
378-
379-
/branch <owner>/<repo>/<branch>
380-
381-
This command will create a pull request against the latest release branch using
382-
the <branch> from the <owner>/<repo> repository. <branch> cannot contain any
383-
forward slash '/' characters.
377+
If a commit you want to backport does not apply cleanly, you may resolve
378+
the conflicts locally and then create a pull request against the release
379+
branch. Just make sure to add the release milestone to the pull request.

llvm/utils/git/github-automation.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ def repo_name(self) -> str:
308308
def issue_number(self) -> int:
309309
return self._issue_number
310310

311+
@property
312+
def branch_repo_owner(self) -> str:
313+
return self.branch_repo_name.split("/")[0]
314+
311315
@property
312316
def branch_repo_name(self) -> str:
313317
return self._branch_repo_name
@@ -394,7 +398,7 @@ def issue_notify_cherry_pick_failure(
394398
action_url = self.action_url
395399
if action_url:
396400
message += action_url + "\n\n"
397-
message += "Please manually backport the fix and push it to your github fork. Once this is done, please add a comment like this:\n\n`/branch <user>/<repo>/<branch>`"
401+
message += "Please manually backport the fix and push it to your github fork. Once this is done, please create a [pull request](https://github.com/llvm/llvm-project/compare)"
398402
issue = self.issue
399403
comment = issue.create_comment(message)
400404
issue.add_to_labels(self.CHERRY_PICK_FAILED_LABEL)
@@ -472,9 +476,10 @@ def create_branch(self, commits: List[str]) -> bool:
472476
print("Pushing to {} {}".format(push_url, branch_name))
473477
local_repo.git.push(push_url, "HEAD:{}".format(branch_name), force=True)
474478

475-
self.issue_notify_branch()
476479
self.issue_remove_cherry_pick_failed_label()
477-
return True
480+
return self.create_pull_request(
481+
self.branch_repo_owner, self.repo_name, branch_name
482+
)
478483

479484
def check_if_pull_request_exists(
480485
self, repo: github.Repository.Repository, head: str
@@ -552,14 +557,6 @@ def execute_command(self) -> bool:
552557
commits = list(map(lambda a: extract_commit_hash(a), arg_list))
553558
return self.create_branch(commits)
554559

555-
if command == "branch":
556-
m = re.match("([^/]+)/([^/]+)/(.+)", args)
557-
if m:
558-
owner = m.group(1)
559-
repo = m.group(2)
560-
branch = m.group(3)
561-
return self.create_pull_request(owner, repo, branch)
562-
563560
print("Do not understand input:")
564561
print(sys.stdin.readlines())
565562
return False

0 commit comments

Comments
 (0)