Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit size of messages from the CI slack bot #48766

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions utils/ci-slack-bot/ci-slack-bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

FLAKY_ALERT_PROBABILITY = 0.20

MAX_TESTS_TO_REPORT = 4

# Slack has a stupid limitation on message size, it splits long messages into multiple ones breaking formatting
MESSAGE_LENGTH_LIMIT = 4000

Expand Down Expand Up @@ -64,6 +66,7 @@
AND test_status LIKE 'F%')
AND test_context_raw NOT LIKE '%CannotSendRequest%' and test_context_raw NOT LIKE '%Server does not respond to health check%'
GROUP BY test_name
ORDER BY (count_prev_periods + count) DESC
"""

# Returns total number of failed checks during the last 24 hours
Expand Down Expand Up @@ -155,11 +158,17 @@ def format_failed_tests_list(failed_tests, failure_type):
else:
res = "There are {} new {} tests:\n".format(len(failed_tests), failure_type)

for name, report in failed_tests:
for name, report in failed_tests[:MAX_TESTS_TO_REPORT]:
cidb_url = get_play_url(ALL_RECENT_FAILURES_QUERY.format(name))
res += "- *{}* - <{}|Report> - <{}|CI DB> \n".format(
name, report, cidb_url
)

if MAX_TESTS_TO_REPORT < len(failed_tests):
res += "- and {} other tests... :this-is-fine-fire:".format(
len(failed_tests) - MAX_TESTS_TO_REPORT
)

return res


Expand Down Expand Up @@ -199,7 +208,7 @@ def get_too_many_failures_message_impl(failures_count):
if curr_failures < MAX_FAILURES:
return None
if prev_failures < MAX_FAILURES:
return "*CI is broken: there are {} failures during the last 24 hours*".format(
return ":alert: *CI is broken: there are {} failures during the last 24 hours*".format(
curr_failures
)
if curr_failures < prev_failures:
Expand Down