[llvm] [workflows] Drop the intermediate /branch comment for release workflow (PR #79481)

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 12:53:36 PST 2024


https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/79481

>From 7444bdade3efd0a7642230a3e15fb51163288f25 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Wed, 24 Jan 2024 16:49:20 -0800
Subject: [PATCH 1/3] [workflows] Drop the intermediate /branch comment for
 release workflow

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.
---
 .github/workflows/issue-release-workflow.yml | 33 +-------------------
 llvm/docs/GitHub.rst                         | 12 +++----
 llvm/utils/git/github-automation.py          | 17 ++++------
 3 files changed, 12 insertions(+), 50 deletions(-)

diff --git a/.github/workflows/issue-release-workflow.yml b/.github/workflows/issue-release-workflow.yml
index 17209ec055f858..112ece40bac9c1 100644
--- a/.github/workflows/issue-release-workflow.yml
+++ b/.github/workflows/issue-release-workflow.yml
@@ -35,6 +35,7 @@ jobs:
     runs-on: ubuntu-latest
     permissions:
       issues: write
+      pull-requests: write
     if: >-
       (github.repository == 'llvm/llvm-project') &&
       !startswith(github.event.comment.body, '<!--IGNORE-->') &&
@@ -65,35 +66,3 @@ jobs:
           --branch-repo-token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
           --issue-number ${{ github.event.issue.number }} \
           auto
-
-  create-pull-request:
-    name: Create Pull Request
-    runs-on: ubuntu-latest
-    permissions:
-      issues: write
-      pull-requests: write
-    if: >-
-      (github.repository == 'llvm/llvm-project') &&
-      !startswith(github.event.comment.body, '<!--IGNORE-->') &&
-      contains(github.event.comment.body, '/branch ')
-
-    steps:
-      - name: Fetch LLVM sources
-        uses: actions/checkout at v4
-        with:
-          persist-credentials: false
-
-      - name: Setup Environment
-        run: |
-          pip install -r ./llvm/utils/git/requirements.txt
-
-      - name: Create Pull Request
-        run: |
-          printf "%s" "$COMMENT_BODY" |
-          ./llvm/utils/git/github-automation.py \
-          --repo "$GITHUB_REPOSITORY" \
-          --token ${{ github.token }} \
-          release-workflow \
-          --branch-repo-token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
-          --issue-number ${{ github.event.issue.number }} \
-          auto
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index a89a4d955fc08b..b84d4953a9488f 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -360,8 +360,8 @@ Releases
 Backporting Fixes to the Release Branches
 -----------------------------------------
 You can use special comments on issues to make backport requests for the
-release branches.  This is done by making a comment containing one of the
-following commands on any issue that has been added to one of the "X.Y.Z Release"
+release branches.  This is done by making a comment containing the following
+command on any issue that has been added to one of the "X.Y.Z Release"
 milestones.
 
 ::
@@ -376,8 +376,6 @@ be created with the specified commits.
 
 ::
 
-  /branch <owner>/<repo>/<branch>
-
-This command will create a pull request against the latest release branch using
-the <branch> from the <owner>/<repo> repository.  <branch> cannot contain any
-forward slash '/' characters.
+If a commit you want to backport does not apply cleanly, you may resolve
+the conflicts locally and then create a pull request against the release
+branch.  Just make sure to add the release milestone to the pull request.
diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index 72db9995b0e8a5..0531915d560277 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -308,6 +308,10 @@ def repo_name(self) -> str:
     def issue_number(self) -> int:
         return self._issue_number
 
+    @property
+    def branch_repo_owner(self) -> str:
+        return self.branch_repo_name.split('/')[0]
+
     @property
     def branch_repo_name(self) -> str:
         return self._branch_repo_name
@@ -394,7 +398,7 @@ def issue_notify_cherry_pick_failure(
         action_url = self.action_url
         if action_url:
             message += action_url + "\n\n"
-        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>`"
+        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)"
         issue = self.issue
         comment = issue.create_comment(message)
         issue.add_to_labels(self.CHERRY_PICK_FAILED_LABEL)
@@ -472,9 +476,8 @@ def create_branch(self, commits: List[str]) -> bool:
         print("Pushing to {} {}".format(push_url, branch_name))
         local_repo.git.push(push_url, "HEAD:{}".format(branch_name), force=True)
 
-        self.issue_notify_branch()
         self.issue_remove_cherry_pick_failed_label()
-        return True
+        return self.create_pull_request(self.branch_repo_owner, self.repo_name, branch_name)
 
     def check_if_pull_request_exists(
         self, repo: github.Repository.Repository, head: str
@@ -552,14 +555,6 @@ def execute_command(self) -> bool:
                 commits = list(map(lambda a: extract_commit_hash(a), arg_list))
                 return self.create_branch(commits)
 
-            if command == "branch":
-                m = re.match("([^/]+)/([^/]+)/(.+)", args)
-                if m:
-                    owner = m.group(1)
-                    repo = m.group(2)
-                    branch = m.group(3)
-                    return self.create_pull_request(owner, repo, branch)
-
         print("Do not understand input:")
         print(sys.stdin.readlines())
         return False

>From f305dc1fecec4efa19cf3e0c7ec86637a67ef4b5 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Thu, 25 Jan 2024 10:42:56 -0800
Subject: [PATCH 2/3] Fix python formatting

---
 llvm/utils/git/github-automation.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index 0531915d560277..897705166c640e 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -310,7 +310,7 @@ def issue_number(self) -> int:
 
     @property
     def branch_repo_owner(self) -> str:
-        return self.branch_repo_name.split('/')[0]
+        return self.branch_repo_name.split("/")[0]
 
     @property
     def branch_repo_name(self) -> str:
@@ -477,7 +477,9 @@ def create_branch(self, commits: List[str]) -> bool:
         local_repo.git.push(push_url, "HEAD:{}".format(branch_name), force=True)
 
         self.issue_remove_cherry_pick_failed_label()
-        return self.create_pull_request(self.branch_repo_owner, self.repo_name, branch_name)
+        return self.create_pull_request(
+            self.branch_repo_owner, self.repo_name, branch_name
+        )
 
     def check_if_pull_request_exists(
         self, repo: github.Repository.Repository, head: str

>From 84046ffec3526f94d6e261ef80c5d877ab81c8be Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Thu, 25 Jan 2024 12:53:09 -0800
Subject: [PATCH 3/3] Fix documentation

---
 llvm/docs/GitHub.rst | 2 --
 1 file changed, 2 deletions(-)

diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index b84d4953a9488f..99c22f4b7220b8 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -374,8 +374,6 @@ apply cleanly, then a comment with a link to the failing job will be added to
 the issue.  If the commit(s) do apply cleanly, then a pull request will
 be created with the specified commits.
 
-::
-
 If a commit you want to backport does not apply cleanly, you may resolve
 the conflicts locally and then create a pull request against the release
 branch.  Just make sure to add the release milestone to the pull request.



More information about the llvm-commits mailing list