From 779b5db3637603df5399c165175694ff5fd42cfb Mon Sep 17 00:00:00 2001 From: Michael Kaye <1917473+michaelkaye@users.noreply.github.com> Date: Thu, 24 Feb 2022 10:32:01 +0000 Subject: [PATCH] Add a python script to cleanly display outputs in the github logs --- tools/ci/render_test_output.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tools/ci/render_test_output.py diff --git a/tools/ci/render_test_output.py b/tools/ci/render_test_output.py new file mode 100755 index 0000000000..1f9684bf18 --- /dev/null +++ b/tools/ci/render_test_output.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# +# Renders a list of xml files taken as arguments into GHA-styled messages in groups. +# Explicitly aims not to have any dependencies, to reduce installation load. +# Should just be able to run in the context of your standard github runner. + +import sys +import xml.etree.ElementTree as ET + +xmlfiles= sys.argv[1:] + +for xmlfile in xmlfiles: + tree = ET.parse(xmlfile) + + root = tree.getroot() + name = root.attrib['name'] + name = root.attrib['time'] + success = int(root.attrib['tests']) - int(root.attrib['failures']) - int(root.attrib['errors']) + total = int(root.attrib['tests']) - int(root.attrib['skipped']) + print(f"::group::{name} {success}/{total} in {time}") + + for testcase in root: + if testcase.tag != "testcase": + continue + testname = testcase.attrib['classname'] + message = testcase.attrib['name'] + time = testcase.attrib['time'] + child = testcase.find("failure") + if child is None: + print(f"{message} in {time}s") + else: + print(f"::error file={testname}::{message} in {time}s") + print(child.text) + print("::endgroup::")