[llvm] Fix release issue workflow (PR #79268)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 24 01:08:18 PST 2024
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/79268
Remove the `--phab-token` argument (which currently eats the subsequent "auto" as the token no longer exists) and related code.
I think this will fix the workflow failure in https://github.com/llvm/llvm-project/issues/79253#issuecomment-1907679229.
>From 3698b121cc591937acabbdbe8ae5ec8ea87e0a65 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Wed, 24 Jan 2024 10:06:22 +0100
Subject: [PATCH] Fix release issue workflow
Remove the `--phab-token` argument (which currently eats the
subsequent "auto") and related code.
---
.github/workflows/issue-release-workflow.yml | 2 -
llvm/utils/git/github-automation.py | 91 --------------------
2 files changed, 93 deletions(-)
diff --git a/.github/workflows/issue-release-workflow.yml b/.github/workflows/issue-release-workflow.yml
index b09ef6555fa901..1f45799af16954 100644
--- a/.github/workflows/issue-release-workflow.yml
+++ b/.github/workflows/issue-release-workflow.yml
@@ -61,7 +61,6 @@ jobs:
--token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
release-workflow \
--issue-number ${{ github.event.issue.number }} \
- --phab-token ${{ secrets.RELEASE_WORKFLOW_PHAB_TOKEN }} \
auto
create-pull-request:
@@ -90,5 +89,4 @@ jobs:
--token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
release-workflow \
--issue-number ${{ github.event.issue.number }} \
- --phab-token ${{ secrets.RELEASE_WORKFLOW_PHAB_TOKEN }} \
auto
diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index f78d91059ecd36..ffe4e54484fd53 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -251,85 +251,6 @@ def setup_llvmbot_git(git_dir="."):
config.set_value("user", "email", "llvmbot at llvm.org")
-def phab_api_call(phab_token: str, url: str, args: dict) -> dict:
- """
- Make an API call to the Phabricator web service and return a dictionary
- containing the json response.
- """
- data = {"api.token": phab_token}
- data.update(args)
- response = requests.post(url, data=data)
- return response.json()
-
-
-def phab_login_to_github_login(
- phab_token: str, repo: github.Repository.Repository, phab_login: str
-) -> Optional[str]:
- """
- Tries to translate a Phabricator login to a github login by
- finding a commit made in Phabricator's Differential.
- The commit's SHA1 is then looked up in the github repo and
- the committer's login associated with that commit is returned.
-
- :param str phab_token: The Conduit API token to use for communication with Pabricator
- :param github.Repository.Repository repo: The github repo to use when looking for the SHA1 found in Differential
- :param str phab_login: The Phabricator login to be translated.
- """
-
- args = {
- "constraints[authors][0]": phab_login,
- # PHID for "LLVM Github Monorepo" repository
- "constraints[repositories][0]": "PHID-REPO-f4scjekhnkmh7qilxlcy",
- "limit": 1,
- }
- # API documentation: https://reviews.llvm.org/conduit/method/diffusion.commit.search/
- r = phab_api_call(
- phab_token, "https://reviews.llvm.org/api/diffusion.commit.search", args
- )
- data = r["result"]["data"]
- if len(data) == 0:
- # Can't find any commits associated with this user
- return None
-
- commit_sha = data[0]["fields"]["identifier"]
- committer = repo.get_commit(commit_sha).committer
- if not committer:
- # This committer had an email address GitHub could not recognize, so
- # it can't link the user to a GitHub account.
- print(f"Warning: Can't find github account for {phab_login}")
- return None
- return committer.login
-
-
-def phab_get_commit_approvers(phab_token: str, commit: github.Commit.Commit) -> list:
- args = {"corpus": commit.commit.message}
- # API documentation: https://reviews.llvm.org/conduit/method/differential.parsecommitmessage/
- r = phab_api_call(
- phab_token, "https://reviews.llvm.org/api/differential.parsecommitmessage", args
- )
- review_id = r["result"]["revisionIDFieldInfo"]["value"]
- if not review_id:
- # No Phabricator revision for this commit
- return []
-
- args = {"constraints[ids][0]": review_id, "attachments[reviewers]": True}
- # API documentation: https://reviews.llvm.org/conduit/method/differential.revision.search/
- r = phab_api_call(
- phab_token, "https://reviews.llvm.org/api/differential.revision.search", args
- )
- reviewers = r["result"]["data"][0]["attachments"]["reviewers"]["reviewers"]
- accepted = []
- for reviewer in reviewers:
- if reviewer["status"] != "accepted":
- continue
- phid = reviewer["reviewerPHID"]
- args = {"constraints[phids][0]": phid}
- # API documentation: https://reviews.llvm.org/conduit/method/user.search/
- r = phab_api_call(phab_token, "https://reviews.llvm.org/api/user.search", args)
- accepted.append(r["result"]["data"][0]["fields"]["username"])
- return accepted
-
-
def extract_commit_hash(arg: str):
"""
Extract the commit hash from the argument passed to /action github
@@ -364,7 +285,6 @@ def __init__(
branch_repo_name: str,
branch_repo_token: str,
llvm_project_dir: str,
- phab_token: str,
) -> None:
self._token = token
self._repo_name = repo
@@ -375,7 +295,6 @@ def __init__(
else:
self._branch_repo_token = self.token
self._llvm_project_dir = llvm_project_dir
- self._phab_token = phab_token
@property
def token(self) -> str:
@@ -401,10 +320,6 @@ def branch_repo_token(self) -> str:
def llvm_project_dir(self) -> str:
return self._llvm_project_dir
- @property
- def phab_token(self) -> str:
- return self._phab_token
-
@property
def repo(self) -> github.Repository.Repository:
return github.Github(self.token).get_repo(self.repo_name)
@@ -708,11 +623,6 @@ def execute_command(self) -> bool:
release_workflow_parser.add_argument(
"--issue-number", type=int, required=True, help="The issue number to update"
)
-release_workflow_parser.add_argument(
- "--phab-token",
- type=str,
- help="Phabricator conduit API token. See https://reviews.llvm.org/settings/user/<USER>/page/apitokens/",
-)
release_workflow_parser.add_argument(
"--branch-repo-token",
type=str,
@@ -759,7 +669,6 @@ def execute_command(self) -> bool:
args.branch_repo,
args.branch_repo_token,
args.llvm_project_dir,
- args.phab_token,
)
if not release_workflow.release_branch_for_issue:
release_workflow.issue_notify_no_milestone(sys.stdin.readlines())
More information about the llvm-commits
mailing list