Skip to content

[workflows] Drop the intermediate /branch comment for release workflow #79481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions .github/workflows/issue-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-->') &&
Expand Down Expand Up @@ -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@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
14 changes: 5 additions & 9 deletions llvm/docs/GitHub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

::
Expand All @@ -374,10 +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.

::

/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.
19 changes: 8 additions & 11 deletions llvm/utils/git/github-automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -472,9 +476,10 @@ 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
Expand Down Expand Up @@ -552,14 +557,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
Expand Down