"vscode:/vscode.git/clone" did not exist on "75f6641eaf5ccf130cd6b6f4d4a04fb08e6e5ada"
Unverified Commit 3bb44662 authored by Lysandre Debut's avatar Lysandre Debut Committed by GitHub
Browse files

Better notification service (#13267)

parent 225de5cc
......@@ -355,6 +355,7 @@ jobs:
env:
CI_SLACK_BOT_TOKEN: ${{ secrets.CI_SLACK_BOT_TOKEN }}
CI_SLACK_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID }}
CI_SLACK_CHANNEL_ID_DAILY: ${{ secrets.CI_SLACK_CHANNEL_ID_DAILY }}
run: |
......
......@@ -39,7 +39,7 @@ def handle_test_results(test_results):
def format_for_slack(total_results, results, scheduled: bool):
print(results)
print(total_results, results)
header = {
"type": "header",
"text": {
......@@ -49,20 +49,21 @@ def format_for_slack(total_results, results, scheduled: bool):
},
}
total = (
{
if total_results["failed"] > 0:
total = {
"type": "section",
"fields": [
{"type": "mrkdwn", "text": f"*Failures:*\n{total_results['failed']} failures."},
{"type": "mrkdwn", "text": f"*Passed:*\n{total_results['success']} tests passed."},
],
}
if total_results["failed"] > 0
else {
else:
total = {
"type": "section",
"fields": [{"type": "mrkdwn", "text": f"*Congrats!*\nAll {total_results['success']} tests pass."}],
"fields": [
{"type": "mrkdwn", "text": "\n🌞 All tests passed."},
],
}
)
blocks = [header, total]
......@@ -82,7 +83,7 @@ def format_for_slack(total_results, results, scheduled: bool):
],
}
)
else:
elif not scheduled:
for key, result in results.items():
blocks.append(
{"type": "section", "fields": [{"type": "mrkdwn", "text": f"*{key}*\n{result['time_spent']}."}]}
......@@ -148,7 +149,7 @@ if __name__ == "__main__":
}
client = WebClient(token=os.environ["CI_SLACK_BOT_TOKEN"])
channel_id = os.environ["CI_SLACK_CHANNEL_ID"]
channel_id = os.environ["CI_SLACK_CHANNEL_ID_DAILY"] if scheduled else os.environ["CI_SLACK_CHANNEL_ID"]
try:
results = {}
......@@ -180,6 +181,7 @@ if __name__ == "__main__":
for result_key in test_results_keys:
total[result_key] += job_result[result_key]
if total["failed"] != 0 or scheduled:
to_be_sent_to_slack = format_for_slack(total, results, scheduled)
result = client.chat_postMessage(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment