From c52339a2ba72f5f0e18a40c06fa8e199232927af Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 12 Jun 2026 17:06:31 -0400 Subject: [PATCH] Add markdown test summaries and a coverage HTML report to CI ctest_summary.py renders a Test.xml as markdown for GITHUB_STEP_SUMMARY: a one-liner when everything passes, otherwise the first few failures inline with a link to the full Test.xml on MinIO. It's also usable locally with --all to list every failure from a downloaded Test.xml. The coverage job now also generates and uploads gcovr's html-details report and links it from the step summary. --- .gitea/workflows/ci.yml | 28 +++++++++++++++ ctest_summary.py | 76 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 ctest_summary.py diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 135b8bb..d8397dc 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -112,6 +112,13 @@ jobs: zstd build/Testing/*/Test.xml mc cp build/Testing/*/Test.xml.zst "minio/jenkins/conflict-set/${{ gitea.run_number }}/${{ matrix.name }}/" + - name: Test summary + if: always() + run: | + python3 ctest_summary.py build/Testing/*/Test.xml \ + --link "https://minio.weaselab.dev/jenkins/conflict-set/${{ gitea.run_number }}/${{ matrix.name }}/Test.xml.zst" \ + >> "$GITHUB_STEP_SUMMARY" + release: needs: build-image strategy: @@ -193,6 +200,13 @@ jobs: mc cp paper/*.pdf "$dest" fi + - name: Test summary + if: always() + run: | + python3 ctest_summary.py build/Testing/*/Test.xml \ + --link "https://minio.weaselab.dev/jenkins/conflict-set/${{ gitea.run_number }}/release-${{ matrix.arch }}/Test.xml.zst" \ + >> "$GITHUB_STEP_SUMMARY" + coverage: needs: build-image runs-on: ubuntu-latest-amd64 @@ -232,6 +246,8 @@ jobs: --gcov-executable "llvm-cov gcov" --exclude-noncode-lines) gcovr "${gcov_args[@]}" --cobertura > build/coverage.xml gcovr "${gcov_args[@]}" + mkdir -p build/coverage_html + gcovr "${gcov_args[@]}" --html-details build/coverage_html/index.html gcovr "${gcov_args[@]}" --fail-under-line 100 > /dev/null - name: Upload results to MinIO @@ -250,3 +266,15 @@ jobs: if [ -e build/coverage.xml ]; then mc cp build/coverage.xml "$dest" fi + if [ -d build/coverage_html ]; then + mc cp -r build/coverage_html "$dest" + fi + + - name: Test summary + if: always() + run: | + python3 ctest_summary.py build/Testing/*/Test.xml \ + --link "https://minio.weaselab.dev/jenkins/conflict-set/${{ gitea.run_number }}/coverage/Test.xml.zst" \ + >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "šŸ“Š [Coverage report](https://minio.weaselab.dev/jenkins/conflict-set/${{ gitea.run_number }}/coverage/coverage_html/index.html)" >> "$GITHUB_STEP_SUMMARY" diff --git a/ctest_summary.py b/ctest_summary.py new file mode 100644 index 0000000..5562f17 --- /dev/null +++ b/ctest_summary.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +"""Summarize a CTest Test.xml as markdown. + +Intended for $GITHUB_STEP_SUMMARY in CI, where only the first few failures +are shown inline (pass --link to point at the full Test.xml). Also reusable +locally to print every failure from a downloaded Test.xml with --all. +""" + +import argparse +import base64 +import gzip +import xml.etree.ElementTree as ET + +# Failure output is truncated to this many trailing characters, which is +# usually enough to include e.g. an ASan report's summary. +OUTPUT_TAIL_CHARS = 3000 + + +def test_output(test): + value = test.find("./Results/Measurement/Value") + if value is None or value.text is None: + return "" + text = value.text + if value.get("encoding") == "base64": + raw = base64.b64decode(text) + if value.get("compression") == "gzip": + raw = gzip.decompress(raw) + text = raw.decode(errors="replace") + return text + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("test_xml", help="path to a ctest Testing/*/Test.xml") + parser.add_argument( + "--inline", + type=int, + default=5, + help="how many failures to show inline (default 5)", + ) + parser.add_argument("--all", action="store_true", help="show every failure inline") + parser.add_argument( + "--link", help="URL of the full Test.xml, linked when failures are elided" + ) + args = parser.parse_args() + + testing = ET.parse(args.test_xml).getroot().find("Testing") + tests = testing.findall("Test") + failed = [t for t in tests if t.get("Status") == "failed"] + notrun = sum(1 for t in tests if t.get("Status") == "notrun") + + if not failed: + print(f"āœ… All {len(tests) - notrun} tests passed") + else: + print(f"āŒ {len(failed)} of {len(tests)} tests failed\n") + shown = failed if args.all else failed[: args.inline] + for test in shown: + name = test.findtext("Name") + output = test_output(test)[-OUTPUT_TAIL_CHARS:].strip() + print(f"
{name}\n") + print("````") + print(output) + print("````") + print("
\n") + remaining = len(failed) - len(shown) + if remaining > 0: + more = f"… and {remaining} more" + if args.link: + more += f" — full list in [Test.xml]({args.link})" + print(more) + if notrun: + print(f"\nāš ļø {notrun} tests not run") + + +if __name__ == "__main__": + main()