Add PR title to push CI report (#17246)
* add PR title to push CI report * add link Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
2
.github/workflows/self-push.yml
vendored
2
.github/workflows/self-push.yml
vendored
@@ -313,6 +313,8 @@ jobs:
|
|||||||
CI_SLACK_CHANNEL_DUMMY_TESTS: ${{ secrets.CI_SLACK_CHANNEL_DUMMY_TESTS }}
|
CI_SLACK_CHANNEL_DUMMY_TESTS: ${{ secrets.CI_SLACK_CHANNEL_DUMMY_TESTS }}
|
||||||
CI_SLACK_REPORT_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID }}
|
CI_SLACK_REPORT_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID }}
|
||||||
CI_EVENT: push
|
CI_EVENT: push
|
||||||
|
CI_TITLE: ${{ github.event.head_commit.message }}
|
||||||
|
CI_COMMIT_URL: ${{ github.event.head_commit.url }}
|
||||||
# We pass `needs.setup.outputs.matrix` as the argument. A processing in `notification_service.py` to change
|
# We pass `needs.setup.outputs.matrix` as the argument. A processing in `notification_service.py` to change
|
||||||
# `models/bert` to `models_bert` is required, as the artifact names use `_` instead of `/`.
|
# `models/bert` to `models_bert` is required, as the artifact names use `_` instead of `/`.
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -98,8 +98,9 @@ def dicts_to_sum(objects: Union[Dict[str, Dict], List[dict]]):
|
|||||||
|
|
||||||
|
|
||||||
class Message:
|
class Message:
|
||||||
def __init__(self, title: str, model_results: Dict, additional_results: Dict):
|
def __init__(self, title: str, ci_title: str, model_results: Dict, additional_results: Dict):
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self.ci_title = ci_title
|
||||||
|
|
||||||
# Failures and success of the modeling tests
|
# Failures and success of the modeling tests
|
||||||
self.n_model_success = sum(r["success"] for r in model_results.values())
|
self.n_model_success = sum(r["success"] for r in model_results.values())
|
||||||
@@ -158,6 +159,10 @@ class Message:
|
|||||||
def header(self) -> Dict:
|
def header(self) -> Dict:
|
||||||
return {"type": "header", "text": {"type": "plain_text", "text": self.title}}
|
return {"type": "header", "text": {"type": "plain_text", "text": self.title}}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ci_title_section(self) -> Dict:
|
||||||
|
return {"type": "section", "text": {"type": "mrkdwn", "text": self.ci_title}}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def no_failures(self) -> Dict:
|
def no_failures(self) -> Dict:
|
||||||
return {
|
return {
|
||||||
@@ -346,6 +351,9 @@ class Message:
|
|||||||
def payload(self) -> str:
|
def payload(self) -> str:
|
||||||
blocks = [self.header]
|
blocks = [self.header]
|
||||||
|
|
||||||
|
if self.ci_title:
|
||||||
|
blocks.append(self.ci_title_section)
|
||||||
|
|
||||||
if self.n_model_failures > 0 or self.n_additional_failures > 0:
|
if self.n_model_failures > 0 or self.n_additional_failures > 0:
|
||||||
blocks.append(self.failures)
|
blocks.append(self.failures)
|
||||||
|
|
||||||
@@ -724,7 +732,18 @@ if __name__ == "__main__":
|
|||||||
artifact_path["gpu"]
|
artifact_path["gpu"]
|
||||||
] += f"*{line}*\n_{stacktraces.pop(0)}_\n\n"
|
] += f"*{line}*\n_{stacktraces.pop(0)}_\n\n"
|
||||||
|
|
||||||
message = Message(f"🤗 Results of the {ci_event} tests.", model_results, additional_results)
|
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")
|
||||||
|
if ci_title is not None:
|
||||||
|
assert commit_url is not None
|
||||||
|
ci_title = ci_title.strip().split("\n")[0].strip()
|
||||||
|
ci_title = f"<{commit_url}|{ci_title}>"
|
||||||
|
else:
|
||||||
|
ci_title = ""
|
||||||
|
|
||||||
|
message = Message(title, ci_title, model_results, additional_results)
|
||||||
|
|
||||||
message.post()
|
message.post()
|
||||||
message.post_reply()
|
message.post_reply()
|
||||||
|
|||||||
Reference in New Issue
Block a user