Skip to content

Commit 0511305

Browse files
authored
Add PR author in CI report + merged by info (huggingface#17298)
* Add author info to CI report * Add merged by info * update Co-authored-by: ydshieh <[email protected]>
1 parent 032d63b commit 0511305

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

utils/notification_service.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,18 +739,35 @@ def add_path(self, path: str, gpu: str = None):
739739
title = f"🤗 Results of the {ci_event} tests."
740740
# Add PR title with a link for push CI
741741
ci_title = os.environ.get("CI_TITLE")
742-
commit_url = os.environ.get("CI_COMMIT_URL")
742+
ci_url = os.environ.get("CI_COMMIT_URL")
743+
744+
commit_number = ci_url.split("/")[-1]
745+
ci_detail_url = f"https://api.github.com/repos/huggingface/transformers/commits/{commit_number}"
746+
ci_details = requests.get(ci_detail_url).json()
747+
ci_author = ci_details["author"]["login"]
748+
743749
if ci_title is not None:
744-
assert commit_url is not None
750+
assert ci_url is not None
745751
ci_title = ci_title.strip().split("\n")[0].strip()
746752

753+
merged_by = None
747754
# Find the PR number (if any) and change the url to the actual PR page.
748755
numbers = pr_number_re.findall(ci_title)
749756
if len(numbers) > 0:
750757
pr_number = numbers[0]
751-
commit_url = f"https://github.com/huggingface/transformers/pull/{pr_number}"
758+
ci_detail_url = f"https://api.github.com/repos/huggingface/transformers/pulls/{pr_number}"
759+
ci_details = requests.get(ci_detail_url).json()
760+
761+
ci_author = ci_details["user"]["login"]
762+
ci_url = f"https://github.com/huggingface/transformers/pull/{pr_number}"
763+
764+
merged_by = ci_details["merged_by"]["login"]
765+
766+
if merged_by is None:
767+
ci_title = f"<{ci_url}|{ci_title}>\nAuthor: {ci_author}"
768+
else:
769+
ci_title = f"<{ci_url}|{ci_title}>\nAuthor: {ci_author} | Merged by: {merged_by}"
752770

753-
ci_title = f"<{commit_url}|{ci_title}>"
754771
else:
755772
ci_title = ""
756773

0 commit comments

Comments
 (0)