From 0327244ab456953de5add49e8c24fd1285c6f0d5 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sat, 18 Oct 2025 22:26:35 +0000 Subject: [PATCH 1/5] [CI] Add Initial Wiring for Premerge Advisor Explanations This patch adds a new script, premerge_advisor_explain.py that requests test failure explanations from the premerge advisor. For now it just prints them out to STDOUT. This allows for testing of the entire system by looking at failure explanations in failed jobs before we do the rest of the wiring to enable the premerge advisor to write out comments. --- .ci/premerge_advisor_explain.py | 60 +++++++++++++++++++++++++++++++++ .ci/utils.sh | 5 +++ 2 files changed, 65 insertions(+) create mode 100644 .ci/premerge_advisor_explain.py diff --git a/.ci/premerge_advisor_explain.py b/.ci/premerge_advisor_explain.py new file mode 100644 index 0000000000000..d6493635976b1 --- /dev/null +++ b/.ci/premerge_advisor_explain.py @@ -0,0 +1,60 @@ +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +"""Script for getting explanations from the premerge advisor.""" + +import argparse +import os +import platform +import sys + +import requests + +import generate_test_report_lib + +PREMERGE_ADVISOR_URL = ( + "http://premerge-advisor.premerge-advisor.svc.cluster.local:5000/explain" +) + + +def main(commit_sha: str, build_log_files: list[str]): + junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files( + build_log_files + ) + test_failures = generate_test_report_lib.get_failures(junit_objects) + current_platform = f"{platform.system()}-{platform.machine()}".lower() + explanation_reuqest = { + "base_commit_sha": commit_sha, + "platform": current_platform, + "failures": [], + } + if test_failures: + for _, failures in test_failures.items(): + for name, failure_messsage in failures: + explanation_reuqest["failures"].append( + {"name": name, "message": failure_messsage} + ) + else: + ninja_failures = generate_test_report_lib.find_failure_in_ninja_logs(ninja_logs) + for name, failure_message in ninja_failures: + explanation_reuqest["failures"].append( + {"name": name, "message": failure_message} + ) + advisor_response = requests.get(PREMERGE_ADVISOR_URL, json=explanation_reuqest) + print(advisor_response.json) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("commit_sha", help="The base commit SHA for the test.") + parser.add_argument( + "build_log_files", help="Paths to JUnit report files and ninja logs.", nargs="*" + ) + args = parser.parse_args() + + # Skip looking for results on AArch64 for now because the premerge advisor + # service is not available on AWS currently. + if platform.machine() == "arm64": + sys.exit(0) + + main(args.commit_sha, args.build_log_files) diff --git a/.ci/utils.sh b/.ci/utils.sh index 375ed2973bc53..dc8ce9b9a4214 100644 --- a/.ci/utils.sh +++ b/.ci/utils.sh @@ -43,6 +43,11 @@ function at-exit { python "${MONOREPO_ROOT}"/.ci/premerge_advisor_upload.py \ $(git rev-parse HEAD~1) $GITHUB_RUN_NUMBER \ "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log + if [[ "$GITHUB_ACTIONS" != "" ]]; then + python "${MONOREPO_ROOT}"/.ci/premerge_advisor_explain.py \ + $(git rev-parse HEAD~1) "${BUILD_DIR}"/test-results.*.xml \ + "${MONOREPO_ROOT}"/ninja*.log + fi fi } trap at-exit EXIT From a671a67e2e431e10451967445eb2379142bf759b Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sun, 19 Oct 2025 19:11:12 +0000 Subject: [PATCH 2/5] typo fix --- .ci/premerge_advisor_explain.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.ci/premerge_advisor_explain.py b/.ci/premerge_advisor_explain.py index d6493635976b1..53ee5c0fbee85 100644 --- a/.ci/premerge_advisor_explain.py +++ b/.ci/premerge_advisor_explain.py @@ -23,7 +23,7 @@ def main(commit_sha: str, build_log_files: list[str]): ) test_failures = generate_test_report_lib.get_failures(junit_objects) current_platform = f"{platform.system()}-{platform.machine()}".lower() - explanation_reuqest = { + explanation_request = { "base_commit_sha": commit_sha, "platform": current_platform, "failures": [], @@ -31,16 +31,16 @@ def main(commit_sha: str, build_log_files: list[str]): if test_failures: for _, failures in test_failures.items(): for name, failure_messsage in failures: - explanation_reuqest["failures"].append( + explanation_request["failures"].append( {"name": name, "message": failure_messsage} ) else: ninja_failures = generate_test_report_lib.find_failure_in_ninja_logs(ninja_logs) for name, failure_message in ninja_failures: - explanation_reuqest["failures"].append( + explanation_request["failures"].append( {"name": name, "message": failure_message} ) - advisor_response = requests.get(PREMERGE_ADVISOR_URL, json=explanation_reuqest) + advisor_response = requests.get(PREMERGE_ADVISOR_URL, json=explanation_request) print(advisor_response.json) From d2dc1c816f8757148147726c9b880f10b59661ef Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Mon, 20 Oct 2025 16:29:21 +0000 Subject: [PATCH 3/5] test --- .ci/monolithic-linux.sh | 2 +- .ci/monolithic-windows.sh | 2 +- llvm/utils/TableGen/llvm-tblgen.cpp | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh index 4a8418d7baa8c..ca590630bd94d 100755 --- a/.ci/monolithic-linux.sh +++ b/.ci/monolithic-linux.sh @@ -65,7 +65,7 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \ start-group "ninja" # Targets are not escaped as they are passed as separate arguments. -ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log +ninja -C "${BUILD_DIR}" ${targets} |& tee ninja.log cp ${BUILD_DIR}/.ninja_log ninja.ninja_log if [[ "${runtime_targets}" != "" ]]; then diff --git a/.ci/monolithic-windows.sh b/.ci/monolithic-windows.sh index 219979dd3e36e..aa58fe78ec107 100755 --- a/.ci/monolithic-windows.sh +++ b/.ci/monolithic-windows.sh @@ -54,7 +54,7 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \ start-group "ninja" # Targets are not escaped as they are passed as separate arguments. -ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log +ninja -C "${BUILD_DIR}" ${targets} |& tee ninja.log cp ${BUILD_DIR}/.ninja_log ninja.ninja_log if [[ "${runtime_targets}" != "" ]]; then diff --git a/llvm/utils/TableGen/llvm-tblgen.cpp b/llvm/utils/TableGen/llvm-tblgen.cpp index a38382472a992..26cebf42f50d2 100644 --- a/llvm/utils/TableGen/llvm-tblgen.cpp +++ b/llvm/utils/TableGen/llvm-tblgen.cpp @@ -12,6 +12,8 @@ #include "Basic/TableGen.h" +#error blah + /// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen. /// The indirection to tblgen_main exists to ensure that the static variables /// for the llvm::cl:: mechanism are linked into both executables. From a12e4e8b6c0a14890998c531e86cdbc4fd32bd06 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Mon, 20 Oct 2025 16:42:12 +0000 Subject: [PATCH 4/5] Try update --- .ci/premerge_advisor_explain.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.ci/premerge_advisor_explain.py b/.ci/premerge_advisor_explain.py index 53ee5c0fbee85..06c6cb9aaa46b 100644 --- a/.ci/premerge_advisor_explain.py +++ b/.ci/premerge_advisor_explain.py @@ -41,7 +41,10 @@ def main(commit_sha: str, build_log_files: list[str]): {"name": name, "message": failure_message} ) advisor_response = requests.get(PREMERGE_ADVISOR_URL, json=explanation_request) - print(advisor_response.json) + if advisor_response.status_code == 200: + print(advisor_response.json()) + else: + print(advisor_response.reason) if __name__ == "__main__": From eba259ecdf2396d45e058c0c59edbcc4b7938a89 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Mon, 20 Oct 2025 16:45:37 +0000 Subject: [PATCH 5/5] Revert "test" This reverts commit d2dc1c816f8757148147726c9b880f10b59661ef. --- .ci/monolithic-linux.sh | 2 +- .ci/monolithic-windows.sh | 2 +- llvm/utils/TableGen/llvm-tblgen.cpp | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh index ca590630bd94d..4a8418d7baa8c 100755 --- a/.ci/monolithic-linux.sh +++ b/.ci/monolithic-linux.sh @@ -65,7 +65,7 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \ start-group "ninja" # Targets are not escaped as they are passed as separate arguments. -ninja -C "${BUILD_DIR}" ${targets} |& tee ninja.log +ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log cp ${BUILD_DIR}/.ninja_log ninja.ninja_log if [[ "${runtime_targets}" != "" ]]; then diff --git a/.ci/monolithic-windows.sh b/.ci/monolithic-windows.sh index aa58fe78ec107..219979dd3e36e 100755 --- a/.ci/monolithic-windows.sh +++ b/.ci/monolithic-windows.sh @@ -54,7 +54,7 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \ start-group "ninja" # Targets are not escaped as they are passed as separate arguments. -ninja -C "${BUILD_DIR}" ${targets} |& tee ninja.log +ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log cp ${BUILD_DIR}/.ninja_log ninja.ninja_log if [[ "${runtime_targets}" != "" ]]; then diff --git a/llvm/utils/TableGen/llvm-tblgen.cpp b/llvm/utils/TableGen/llvm-tblgen.cpp index 26cebf42f50d2..a38382472a992 100644 --- a/llvm/utils/TableGen/llvm-tblgen.cpp +++ b/llvm/utils/TableGen/llvm-tblgen.cpp @@ -12,8 +12,6 @@ #include "Basic/TableGen.h" -#error blah - /// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen. /// The indirection to tblgen_main exists to ensure that the static variables /// for the llvm::cl:: mechanism are linked into both executables.