Add PR author in CI report + merged by info (#17298)
* Add author info to CI report * Add merged by info * update Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -739,18 +739,35 @@ if __name__ == "__main__":
|
|||||||
title = f"🤗 Results of the {ci_event} tests."
|
title = f"🤗 Results of the {ci_event} tests."
|
||||||
# Add PR title with a link for push CI
|
# Add PR title with a link for push CI
|
||||||
ci_title = os.environ.get("CI_TITLE")
|
ci_title = os.environ.get("CI_TITLE")
|
||||||
commit_url = os.environ.get("CI_COMMIT_URL")
|
ci_url = os.environ.get("CI_COMMIT_URL")
|
||||||
|
|
||||||
|
commit_number = ci_url.split("/")[-1]
|
||||||
|
ci_detail_url = f"https://api.github.com/repos/huggingface/transformers/commits/{commit_number}"
|
||||||
|
ci_details = requests.get(ci_detail_url).json()
|
||||||
|
ci_author = ci_details["author"]["login"]
|
||||||
|
|
||||||
if ci_title is not None:
|
if ci_title is not None:
|
||||||
assert commit_url is not None
|
assert ci_url is not None
|
||||||
ci_title = ci_title.strip().split("\n")[0].strip()
|
ci_title = ci_title.strip().split("\n")[0].strip()
|
||||||
|
|
||||||
|
merged_by = None
|
||||||
# Find the PR number (if any) and change the url to the actual PR page.
|
# Find the PR number (if any) and change the url to the actual PR page.
|
||||||
numbers = pr_number_re.findall(ci_title)
|
numbers = pr_number_re.findall(ci_title)
|
||||||
if len(numbers) > 0:
|
if len(numbers) > 0:
|
||||||
pr_number = numbers[0]
|
pr_number = numbers[0]
|
||||||
commit_url = f"https://github.com/huggingface/transformers/pull/{pr_number}"
|
ci_detail_url = f"https://api.github.com/repos/huggingface/transformers/pulls/{pr_number}"
|
||||||
|
ci_details = requests.get(ci_detail_url).json()
|
||||||
|
|
||||||
|
ci_author = ci_details["user"]["login"]
|
||||||
|
ci_url = f"https://github.com/huggingface/transformers/pull/{pr_number}"
|
||||||
|
|
||||||
|
merged_by = ci_details["merged_by"]["login"]
|
||||||
|
|
||||||
|
if merged_by is None:
|
||||||
|
ci_title = f"<{ci_url}|{ci_title}>\nAuthor: {ci_author}"
|
||||||
|
else:
|
||||||
|
ci_title = f"<{ci_url}|{ci_title}>\nAuthor: {ci_author} | Merged by: {merged_by}"
|
||||||
|
|
||||||
ci_title = f"<{commit_url}|{ci_title}>"
|
|
||||||
else:
|
else:
|
||||||
ci_title = ""
|
ci_title = ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user