Skip to content

Commit

Permalink
Add PR author in CI report + merged by info (#17298)
Browse files Browse the repository at this point in the history
* Add author info to CI report

* Add merged by info

* update

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
  • Loading branch information
ydshieh and ydshieh authored May 17, 2022
1 parent 032d63b commit 0511305
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions utils/notification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""

Expand Down

0 comments on commit 0511305

Please sign in to comment.