[llvm] [CI] Make Premerge only Comment if Tests Failed (PR #169102)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 14:39:54 PST 2025


https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/169102

>From c8bbdf45262089384982a18ea0c3620c8fb62b93 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Fri, 21 Nov 2025 21:58:48 +0000
Subject: [PATCH 1/2] [CI] Make Premerge only Comment if Tests Failed

---
 .ci/monolithic-linux.sh   | 43 ---------------------------------------
 .ci/monolithic-windows.sh | 13 ------------
 2 files changed, 56 deletions(-)

diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh
index e6a59a2ae1306..e92287df90ae6 100755
--- a/.ci/monolithic-linux.sh
+++ b/.ci/monolithic-linux.sh
@@ -63,46 +63,3 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
       -D LLVM_ENABLE_WERROR=ON
 
 start-group "ninja"
-
-if [[ -n "${targets}" ]]; then
-  # Targets are not escaped as they are passed as separate arguments.
-  ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log
-  cp ${BUILD_DIR}/.ninja_log ninja.ninja_log
-fi
-
-if [[ -n "${runtime_targets}" ]]; then
-  start-group "ninja Runtimes"
-
-  ninja -C "${BUILD_DIR}" ${runtime_targets} |& tee ninja_runtimes.log
-  cp ${BUILD_DIR}/.ninja_log ninja_runtimes.ninja_log
-fi
-
-# Compiling runtimes with just-built Clang and running their tests
-# as an additional testing for Clang.
-if [[ -n "${runtime_targets_needs_reconfig}" ]]; then
-  start-group "CMake Runtimes C++26"
-
-  cmake \
-    -D LIBCXX_TEST_PARAMS="std=c++26" \
-    -D LIBCXXABI_TEST_PARAMS="std=c++26" \
-    "${BUILD_DIR}"
-
-  start-group "ninja Runtimes C++26"
-
-  ninja -C "${BUILD_DIR}" ${runtime_targets_needs_reconfig} \
-    |& tee ninja_runtimes_needs_reconfig1.log
-  cp ${BUILD_DIR}/.ninja_log ninja_runtimes_needs_reconig.ninja_log
-
-  start-group "CMake Runtimes Clang Modules"
-
-  cmake \
-    -D LIBCXX_TEST_PARAMS="enable_modules=clang" \
-    -D LIBCXXABI_TEST_PARAMS="enable_modules=clang" \
-    "${BUILD_DIR}"
-
-  start-group "ninja Runtimes Clang Modules"
-
-  ninja -C "${BUILD_DIR}" ${runtime_targets_needs_reconfig} \
-    |& tee ninja_runtimes_needs_reconfig2.log
-  cp ${BUILD_DIR}/.ninja_log ninja_runtimes_needs_reconfig2.ninja_log
-fi
diff --git a/.ci/monolithic-windows.sh b/.ci/monolithic-windows.sh
index 36941644c6a6c..c76c93dea9192 100755
--- a/.ci/monolithic-windows.sh
+++ b/.ci/monolithic-windows.sh
@@ -50,16 +50,3 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
       -D LLVM_ENABLE_RUNTIMES="${runtimes}"
 
 start-group "ninja"
-
-if [[ -n "${targets}" ]]; then
-  # Targets are not escaped as they are passed as separate arguments.
-  ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log
-  cp ${BUILD_DIR}/.ninja_log ninja.ninja_log
-fi
-
-if [[ -n "${runtimes_targets}" ]]; then
-  start-group "ninja runtimes"
-  
-  ninja -C "${BUILD_DIR}" -k 0 ${runtimes_targets} |& tee ninja_runtimes.log
-  cp ${BUILD_DIR}/.ninja_log ninja_runtimes.ninja_log
-fi

>From 0eaec06172e3df4a97b924c934f4c4475cf5f609 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Fri, 21 Nov 2025 22:39:42 +0000
Subject: [PATCH 2/2] fix

---
 .ci/premerge_advisor_explain.py | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/.ci/premerge_advisor_explain.py b/.ci/premerge_advisor_explain.py
index 69568895e9030..335f1a83aac3f 100644
--- a/.ci/premerge_advisor_explain.py
+++ b/.ci/premerge_advisor_explain.py
@@ -79,16 +79,6 @@ def main(
       pr_number: The number of the PR associated with this run.
       return_code: The numerical return code of ninja/CMake.
     """
-    if return_code == 0:
-        with open("comment", "w") as comment_file_handle:
-            comment = get_comment(
-                github_token,
-                pr_number,
-                ":white_check_mark: With the latest revision this PR passed "
-                "the premerge checks.",
-            )
-            if "id" in comment:
-                json.dump([comment], comment_file_handle)
     junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
         build_log_files
     )
@@ -114,10 +104,10 @@ def main(
     advisor_response = requests.get(
         PREMERGE_ADVISOR_URL, json=explanation_request, timeout=5
     )
+    comment = None
     if advisor_response.status_code == 200:
         print(advisor_response.json())
-        comments = [
-            get_comment(
+        comment = get_comment(
                 github_token,
                 pr_number,
                 generate_test_report_lib.generate_report(
@@ -128,11 +118,15 @@ def main(
                     failure_explanations_list=advisor_response.json(),
                 ),
             )
-        ]
-        with open("comments", "w") as comment_file_handle:
-            json.dump(comments, comment_file_handle)
     else:
         print(advisor_response.reason)
+    if comment:
+        if return_code == 0 and "id" not in comment:
+            # If the job succeeds and there is not an existing comment, we
+            # should not write one to reduce noise.
+            return
+        with open("comments", "w") as comment_file_handle:
+            json.dump([comment], comment_file_handle)
 
 
 if __name__ == "__main__":



More information about the llvm-commits mailing list