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 1/6] 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::") From fbf29f6f1e8013ef17563b26aecd28ab8bf672b1 Mon Sep 17 00:00:00 2001 From: Michael Kaye <1917473+michaelkaye@users.noreply.github.com> Date: Thu, 24 Feb 2022 14:47:23 +0000 Subject: [PATCH 2/6] Quick hack python to render the xml test output including times in a easy to read format. --- .github/workflows/integration_tests.yml | 15 ++++----------- tools/ci/render_test_output.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 994c3b0780..89522f1163 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -93,10 +93,7 @@ jobs: - name: Read Results [org.matrix.android.sdk.session] if: always() id: get-comment-body-session - run: | - body="$(cat ./matrix-sdk-android/build/outputs/androidTest-results/connected/*.xml | grep " Date: Thu, 24 Feb 2022 11:40:04 +0000 Subject: [PATCH 3/6] Correct name of script --- .github/workflows/integration_tests.yml | 15 ++++++--------- tools/ci/render_test_output.py | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 89522f1163..c0fecea751 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -93,7 +93,7 @@ jobs: - name: Read Results [org.matrix.android.sdk.session] if: always() id: get-comment-body-session - run: python3 tools/ci/render_xml_output.py session ./matrix-sdk-android/build/outputs/androidTest-results/connected/*.xml + run: python3 ./tools/ci/render_test_output.py session ./matrix-sdk-android/build/outputs/androidTest-results/connected/*.xml - name: Run integration tests for Matrix SDK [org.matrix.android.sdk.account] API[${{ matrix.api-level }}] if: always() uses: reactivecircus/android-emulator-runner@v2 @@ -108,7 +108,7 @@ jobs: - name: Read Results [org.matrix.android.sdk.account] if: always() id: get-comment-body-account - run: python3 tools/ci/render_xml_output.py account ./matrix-sdk-android/build/outputs/androidTest-results/connected/*.xml + run: python3 ./tools/ci/render_test_output.py account ./matrix-sdk-android/build/outputs/androidTest-results/connected/*.xml # package: org.matrix.android.sdk.internal - name: Run integration tests for Matrix SDK [org.matrix.android.sdk.internal] API[${{ matrix.api-level }}] if: always() @@ -124,7 +124,7 @@ jobs: - name: Read Results [org.matrix.android.sdk.internal] if: always() id: get-comment-body-internal - run: python3 tools/ci/render_xml_output.py internal ./matrix-sdk-android/build/outputs/androidTest-results/connected/*.xml + run: python3 ./tools/ci/render_test_output.py internal ./matrix-sdk-android/build/outputs/androidTest-results/connected/*.xml # package: org.matrix.android.sdk.ordering - name: Run integration tests for Matrix SDK [org.matrix.android.sdk.ordering] API[${{ matrix.api-level }}] if: always() @@ -140,9 +140,7 @@ jobs: - name: Read Results [org.matrix.android.sdk.ordering] if: always() id: get-comment-body-ordering - run: | - body="$(cat ./matrix-sdk-android/build/outputs/androidTest-results/connected/*.xml | grep " Date: Thu, 24 Feb 2022 12:14:18 +0000 Subject: [PATCH 4/6] Fix typo in script --- tools/ci/render_test_output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/render_test_output.py b/tools/ci/render_test_output.py index 720e997f98..8288bcc032 100755 --- a/tools/ci/render_test_output.py +++ b/tools/ci/render_test_output.py @@ -38,6 +38,6 @@ for xmlfile in xmlfiles: print(f"::error file={testname}::{message} in {time}s") print(child.text) body = f"passed={passed} failures={failures} errors={errors} skipped={skipped}" - print(f"::set-output name={suitename}::passed={body}" + print(f"::set-output name={suitename}::passed={body}") print("::endgroup::") From 9ddcaffebf2f46c1ad3c498c77733e65b1830385 Mon Sep 17 00:00:00 2001 From: Michael Kaye <1917473+michaelkaye@users.noreply.github.com> Date: Thu, 24 Feb 2022 16:36:43 +0000 Subject: [PATCH 5/6] Adjust script to handle XML files --- tools/ci/render_test_output.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/ci/render_test_output.py b/tools/ci/render_test_output.py index 8288bcc032..54b5ffbf86 100755 --- a/tools/ci/render_test_output.py +++ b/tools/ci/render_test_output.py @@ -15,9 +15,8 @@ for xmlfile in xmlfiles: root = tree.getroot() name = root.attrib['name'] - name = root.attrib['time'] + time = root.attrib['time'] tests = int(root.attrib['tests']) - passed = int(root.attrib['passed']) skipped = int(root.attrib['skipped']) errors = int(root.attrib['errors']) failures = int(root.attrib['failures']) @@ -37,7 +36,7 @@ for xmlfile in xmlfiles: else: print(f"::error file={testname}::{message} in {time}s") print(child.text) - body = f"passed={passed} failures={failures} errors={errors} skipped={skipped}" - print(f"::set-output name={suitename}::passed={body}") + body = f"passed={success} failures={failures} errors={errors} skipped={skipped}" + print(f"::set-output name={suitename}::={body}") print("::endgroup::") From 0ce59989a5919040cd734d44cdf0d9c998da15c0 Mon Sep 17 00:00:00 2001 From: Michael Kaye <1917473+michaelkaye@users.noreply.github.com> Date: Fri, 25 Feb 2022 11:07:03 +0000 Subject: [PATCH 6/6] Log xml files we render. We seem to be missing some tests here (?) --- tools/ci/render_test_output.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/ci/render_test_output.py b/tools/ci/render_test_output.py index 54b5ffbf86..48dd3987a3 100755 --- a/tools/ci/render_test_output.py +++ b/tools/ci/render_test_output.py @@ -10,7 +10,10 @@ import xml.etree.ElementTree as ET suitename = sys.argv[1] xmlfiles = sys.argv[2:] +print(f"Arguments: {sys.argv}") + for xmlfile in xmlfiles: + print(f"Handling: {xmlfile}") tree = ET.parse(xmlfile) root = tree.getroot()