From df6d31fd42252b9f53723fd0421a38e9ecf2e470 Mon Sep 17 00:00:00 2001 From: Johan Commelin Date: Mon, 14 Oct 2024 15:39:33 +0200 Subject: [PATCH] ci(nightly_detect_failure): restore dedup post logic This reverts most of commit 3ad544d9d2e7bbd808fb00b0591cb8513764bc24, aka #17329. --- .github/workflows/nightly_detect_failure.yml | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nightly_detect_failure.yml b/.github/workflows/nightly_detect_failure.yml index 25835698e99ab..0f52fa1c48fc2 100644 --- a/.github/workflows/nightly_detect_failure.yml +++ b/.github/workflows/nightly_detect_failure.yml @@ -212,14 +212,25 @@ jobs: payload = f"🛠️: it looks like it's time to create a new bump/nightly-{current_version} branch from nightly-testing (specifically {sha}), and then PR that to {bump_branch}. " payload += "To do so semi-automatically, run the following script from mathlib root:\n\n" payload += f"```bash\n./scripts/create-adaptation-pr.sh --bumpversion={bump_branch_suffix} --nightlydate={current_version} --nightlysha={sha}\n```\n" - # Post the reminder message - request = { - 'type': 'stream', - 'to': 'nightly-testing', - 'topic': 'Mathlib bump branch reminders', - 'content': payload - } - result = client.send_message(request) - print(result) + # Only post if the message is different + # We compare the first 160 characters, since that includes the date and bump version + if not messages or messages[0]['content'][:160] != payload[:160]: + # Log messages, because the bot seems to repeat itself... + if messages: + print("###### Last message:") + print(messages[0]['content']) + print("###### Current message:") + print(payload) + else: + print('The strings match!') + # Post the reminder message + request = { + 'type': 'stream', + 'to': 'nightly-testing', + 'topic': 'Mathlib bump branch reminders', + 'content': payload + } + result = client.send_message(request) + print(result) else: print('No action needed.')