Skip to content

Commit f030b5e

Browse files
boomanaiden154github-actions[bot]
authored andcommitted
Automerge: [CI] Make CI Jobs Upload Failures to Premerge Advisor (#163276)
This allows the premerge advisor infrastructure to start ingesting data so we can get to work on making failure explanations work.
2 parents 0946004 + c2e42e3 commit f030b5e

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.ci/premerge_advisor_upload.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Script for uploading results to the premerge advisor."""
5+
6+
import argparse
7+
import os
8+
import platform
9+
import sys
10+
11+
import requests
12+
13+
import generate_test_report_lib
14+
15+
PREMERGE_ADVISOR_URL = (
16+
"http://premerge-advisor.premerge-advisor.svc.cluster.local:5000/upload"
17+
)
18+
19+
20+
def main(commit_sha, workflow_run_number, build_log_files):
21+
junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
22+
build_log_files
23+
)
24+
test_failures = generate_test_report_lib.get_failures(junit_objects)
25+
source = "pull_request" if "GITHUB_ACTIONS" in os.environ else "postcommit"
26+
failure_info = {
27+
"source_type": source,
28+
"base_commit_sha": commit_sha,
29+
"source_id": workflow_run_number,
30+
"failures": [],
31+
}
32+
if test_failures:
33+
for name, failure_message in test_failures:
34+
failure_info["failures"].append({"name": name, "message": failure_message})
35+
else:
36+
ninja_failures = generate_test_report_lib.find_failure_in_ninja_logs(ninja_logs)
37+
for name, failure_message in ninja_failures:
38+
failure_info["failures"].append({"name": name, "message": failure_message})
39+
requests.post(PREMERGE_ADVISOR_URL, json=failure_info)
40+
41+
42+
if __name__ == "__main__":
43+
parser = argparse.ArgumentParser()
44+
parser.add_argument("commit_sha", help="The base commit SHA for the test.")
45+
parser.add_argument("workflow_run_number", help="The run number from GHA.")
46+
parser.add_argument(
47+
"build_log_files", help="Paths to JUnit report files and ninja logs.", nargs="*"
48+
)
49+
args = parser.parse_args()
50+
51+
# Skip uploading results on AArch64 for now because the premerge advisor
52+
# service is not available on AWS currently.
53+
if platform.machine() == "arm64":
54+
sys.exit(0)
55+
56+
main(args.commit_sha, args.workflow_run_number, args.build_log_files)

.ci/utils.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ function at-exit {
3838
$retcode "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log \
3939
>> $GITHUB_STEP_SUMMARY
4040
fi
41+
42+
if [[ "$retcode" != "0" ]]; then
43+
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_upload.py \
44+
$(git rev-parse HEAD~1) $GITHUB_RUN_NUMBER \
45+
"${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log
46+
fi
4147
}
4248
trap at-exit EXIT
4349

0 commit comments

Comments
 (0)