Skip to content

Commit 50d1867

Browse files
authored
Add PR title to push CI report (#17246)
* add PR title to push CI report * add link Co-authored-by: ydshieh <[email protected]>
1 parent 506899d commit 50d1867

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

.github/workflows/self-push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ jobs:
313313
CI_SLACK_CHANNEL_DUMMY_TESTS: ${{ secrets.CI_SLACK_CHANNEL_DUMMY_TESTS }}
314314
CI_SLACK_REPORT_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID }}
315315
CI_EVENT: push
316+
CI_TITLE: ${{ github.event.head_commit.message }}
317+
CI_COMMIT_URL: ${{ github.event.head_commit.url }}
316318
# We pass `needs.setup.outputs.matrix` as the argument. A processing in `notification_service.py` to change
317319
# `models/bert` to `models_bert` is required, as the artifact names use `_` instead of `/`.
318320
run: |

utils/notification_service.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ def dicts_to_sum(objects: Union[Dict[str, Dict], List[dict]]):
9898

9999

100100
class Message:
101-
def __init__(self, title: str, model_results: Dict, additional_results: Dict):
101+
def __init__(self, title: str, ci_title: str, model_results: Dict, additional_results: Dict):
102102
self.title = title
103+
self.ci_title = ci_title
103104

104105
# Failures and success of the modeling tests
105106
self.n_model_success = sum(r["success"] for r in model_results.values())
@@ -158,6 +159,10 @@ def time(self) -> str:
158159
def header(self) -> Dict:
159160
return {"type": "header", "text": {"type": "plain_text", "text": self.title}}
160161

162+
@property
163+
def ci_title_section(self) -> Dict:
164+
return {"type": "section", "text": {"type": "mrkdwn", "text": self.ci_title}}
165+
161166
@property
162167
def no_failures(self) -> Dict:
163168
return {
@@ -346,6 +351,9 @@ def additional_failures(self) -> Dict:
346351
def payload(self) -> str:
347352
blocks = [self.header]
348353

354+
if self.ci_title:
355+
blocks.append(self.ci_title_section)
356+
349357
if self.n_model_failures > 0 or self.n_additional_failures > 0:
350358
blocks.append(self.failures)
351359

@@ -724,7 +732,18 @@ def add_path(self, path: str, gpu: str = None):
724732
artifact_path["gpu"]
725733
] += f"*{line}*\n_{stacktraces.pop(0)}_\n\n"
726734

727-
message = Message(f"🤗 Results of the {ci_event} tests.", model_results, additional_results)
735+
title = f"🤗 Results of the {ci_event} tests."
736+
# Add PR title with a link for push CI
737+
ci_title = os.environ.get("CI_TITLE")
738+
commit_url = os.environ.get("CI_COMMIT_URL")
739+
if ci_title is not None:
740+
assert commit_url is not None
741+
ci_title = ci_title.strip().split("\n")[0].strip()
742+
ci_title = f"<{commit_url}|{ci_title}>"
743+
else:
744+
ci_title = ""
745+
746+
message = Message(title, ci_title, model_results, additional_results)
728747

729748
message.post()
730749
message.post_reply()

0 commit comments

Comments
 (0)