From 14f67e9f6c07e03de114bd8b1f3cfb5b66ef8c65 Mon Sep 17 00:00:00 2001 From: Noel Kwan <47273164+kwannoel@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:28:38 +0800 Subject: [PATCH] fix(ci): ensure timeout steps also notify (#18962) --- ci/scripts/notify.py | 17 +++++++++++++---- ci/workflows/main-cron.yml | 7 +++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ci/scripts/notify.py b/ci/scripts/notify.py index 8823c2f0ee92..668d19a3c9ad 100755 --- a/ci/scripts/notify.py +++ b/ci/scripts/notify.py @@ -11,6 +11,7 @@ MAIN_CRON_TEST_MAP = { "test-notify": ["noelkwan", "noelkwan"], "test-notify-2": ["noelkwan", "noelkwan"], + "test-notify-timeout": ["noelkwan", "noelkwan"], "docslt": ["tianxiao"], "e2e-test-release": ["zhi", "Eric"], "e2e-meta-backup-test-release": ["zhi", "Eric"], @@ -110,7 +111,15 @@ def get_failed_tests(get_test_status, test_map): failed_test_map = {} for test in test_map.keys(): test_status = get_test_status(test) - if test_status == "hard_failed" or test_status == "soft_failed": + if test_status == "hard_failed" or test_status == "soft_failed" or test_status == "errored": + print(f"{test} failed with outcome: {test_status}") + failed_test_map[test] = test_map[test] + elif test_status == "passed": + print(f"{test} passed with outcome: {test_status}") + elif test_status is None or test_status == "": + print(f"{test} no outcome, skipping") + else: + print(f"{test} failed with unknown outcome: {test_status}") failed_test_map[test] = test_map[test] return failed_test_map @@ -188,14 +197,14 @@ def run_test_1(): def main(): test_map = get_test_map() + print("--- Getting failed tests") failed_test_map = get_failed_tests(get_buildkite_test_status, test_map) message = generate_test_status_message(failed_test_map) if message == "": - print("All tests passed, no need to notify") + print("--- Tests passed, no need to notify") return else: - print("Some tests failed, notify users") - print(message) + print("--- Some tests failed, notify users") cmd = format_cmd(message) print(cmd) subprocess.run(cmd, shell=True) diff --git a/ci/workflows/main-cron.yml b/ci/workflows/main-cron.yml index e5fba261aa37..30c8d9420ebd 100644 --- a/ci/workflows/main-cron.yml +++ b/ci/workflows/main-cron.yml @@ -1179,6 +1179,13 @@ steps: command: | bash -c 'echo test && exit -1' + # Notification test. + - key: "test-notify-timeout" + if: build.pull_request.labels includes "ci/main-cron/test-notify" || build.env("CI_STEPS") =~ /(^|,)test_notify(,|$$)/ + command: | + bash -c 'echo test && sleep 300' + timeout_in_minutes: 1 + - wait: true continue_on_failure: true allow_dependency_failure: true