Skip to content

Commit 527b7a4

Browse files
[CI][NFC] Refactor compute_platform_title into generate_test_report_lib
This enables reuse in other CI components, like premerge_advisor_explain.py. Reviewers: DavidSpickett, gburgessiv, Keenuts, dschuff, lnihlen Reviewed By: Keenuts, DavidSpickett Pull Request: #166604
1 parent 36d4778 commit 527b7a4

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

.ci/generate_test_report_github.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,10 @@
44
"""Script to generate a build report for Github."""
55

66
import argparse
7-
import platform
87

98
import generate_test_report_lib
109

1110

12-
def compute_platform_title() -> str:
13-
logo = ":window:" if platform.system() == "Windows" else ":penguin:"
14-
# On Linux the machine value is x86_64 on Windows it is AMD64.
15-
if platform.machine() == "x86_64" or platform.machine() == "AMD64":
16-
arch = "x64"
17-
else:
18-
arch = platform.machine()
19-
return f"{logo} {platform.system()} {arch} Test Results"
20-
21-
2211
if __name__ == "__main__":
2312
parser = argparse.ArgumentParser()
2413
parser.add_argument("return_code", help="The build's return code.", type=int)
@@ -28,7 +17,9 @@ def compute_platform_title() -> str:
2817
args = parser.parse_args()
2918

3019
report = generate_test_report_lib.generate_report_from_files(
31-
compute_platform_title(), args.return_code, args.build_test_logs
20+
generate_test_report_lib.compute_platform_title(),
21+
args.return_code,
22+
args.build_test_logs,
3223
)
3324

3425
print(report)

.ci/generate_test_report_lib.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""Library to parse JUnit XML files and return a markdown report."""
55

66
from typing import TypedDict
7+
import platform
78

89
from junitparser import JUnitXml, Failure
910

@@ -305,3 +306,13 @@ def load_info_from_files(build_log_files):
305306
def generate_report_from_files(title, return_code, build_log_files):
306307
junit_objects, ninja_logs = load_info_from_files(build_log_files)
307308
return generate_report(title, return_code, junit_objects, ninja_logs)
309+
310+
311+
def compute_platform_title() -> str:
312+
logo = ":window:" if platform.system() == "Windows" else ":penguin:"
313+
# On Linux the machine value is x86_64 on Windows it is AMD64.
314+
if platform.machine() == "x86_64" or platform.machine() == "AMD64":
315+
arch = "x64"
316+
else:
317+
arch = platform.machine()
318+
return f"{logo} {platform.system()} {arch} Test Results"

0 commit comments

Comments
 (0)