================
@@ -4,20 +4,58 @@
"""Script for getting explanations from the premerge advisor."""
import argparse
-import os
import platform
import sys
+import json
import requests
+import github
+import github.PullRequest
import generate_test_report_lib
PREMERGE_ADVISOR_URL = (
"http://premerge-advisor.premerge-advisor.svc.cluster.local:5000/explain"
)
+COMMENT_TAG = "<!--PREMERGE ADVISOR COMMENT: {platform}-->"
-def main(commit_sha: str, build_log_files: list[str]):
+def get_comment_id(platform: str, pr: github.PullRequest.PullRequest) -> int |
None:
+ platform_comment_tag = COMMENT_TAG.format(platform=platform)
+ for comment in pr.as_issue().get_comments():
+ if platform_comment_tag in comment.body:
+ return comment.id
+ return None
+
+
+def get_comment(
+ github_token: str,
+ pr_number: int,
+ body: str,
+) -> dict[str, str]:
+ repo = github.Github(github_token).get_repo("llvm/llvm-project")
+ pr = repo.get_issue(pr_number).as_pull_request()
+ comment = {"body": body}
+ comment_id = get_comment_id(platform.system(), pr)
+ if comment_id:
+ comment["id"] = comment_id
+
+
+def main(
+ commit_sha: str,
+ build_log_files: list[str],
+ github_token: str,
+ pr_number: int,
+ return_code: int,
+):
+ if return_code == 0:
+ with open("comment", "w") as comment_file_handle:
+ comment = get_comment(
+ ":white_check_mark: With the latest revision this PR passed "
+ "the premerge checks."
+ )
+ if comment["id"]:
----------------
boomanaiden154 wrote:
Yeah, this matches the behavior of the formatter.
I've added a docstring enumerating the cases. The formatter helper script does
not have good documentation on this.
https://github.com/llvm/llvm-project/pull/166605
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits