From 0511305549fbaa4c7c92a69396c2885377082ae4 Mon Sep 17 00:00:00 2001 From: Yih-Dar <2521628+ydshieh@users.noreply.github.com> Date: Tue, 17 May 2022 18:56:58 +0200 Subject: [PATCH] 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 --- utils/notification_service.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/utils/notification_service.py b/utils/notification_service.py index 9323079d55e9ba..2e93b99c9d2af7 100644 --- a/utils/notification_service.py +++ b/utils/notification_service.py @@ -739,18 +739,35 @@ def add_path(self, path: str, gpu: str = None): title = f"🤗 Results of the {ci_event} tests." # Add PR title with a link for push CI 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: - assert commit_url is not None + assert ci_url is not None 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. numbers = pr_number_re.findall(ci_title) if len(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: ci_title = ""