summaryrefslogtreecommitdiff
path: root/.github/scripts
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-05-03 21:34:29 +0200
committerChristoph Berg <myon@debian.org>2026-05-03 21:34:29 +0200
commit5eb3965b437e51f116b9ff789dbbdf535f4a0a5e (patch)
treee9321335f3cb9e213b15778ac35dce9015178314 /.github/scripts
parent291b3817bf0c7a742e9e17d42c94fc8c9530e40d (diff)
parent71eb666b36ddc267dca42e389b5cd25f2fc7a42c (diff)
Update upstream source from tag 'upstream/3.0.1'
Update to upstream version '3.0.1' with Debian dir 169c6178f97ee7a7bf7a751aeafe5c95f0a2895d
Diffstat (limited to '.github/scripts')
-rw-r--r--.github/scripts/publish-ctest-summary.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/.github/scripts/publish-ctest-summary.py b/.github/scripts/publish-ctest-summary.py
new file mode 100644
index 00000000..26afe98a
--- /dev/null
+++ b/.github/scripts/publish-ctest-summary.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python3
+"""Render ctest-results.xml (JUnit) as a GitHub Actions step summary.
+
+Usage: publish-ctest-summary.py <label> [path-to-xml]
+
+Output goes to stdout; callers redirect into $GITHUB_STEP_SUMMARY.
+Missing or malformed XML produces a legible notice rather than a hard fail
+so the summary step stays non-blocking (the ctest step is the fail gate).
+"""
+import sys
+import xml.etree.ElementTree as ET
+from pathlib import Path
+
+
+def main() -> int:
+ label = sys.argv[1] if len(sys.argv) > 1 else ""
+ xml_path = Path(sys.argv[2]) if len(sys.argv) > 2 else Path("ctest-results.xml")
+
+ if not xml_path.exists():
+ print(f"## Test Results — {label}")
+ print()
+ print(f"No `{xml_path.name}` produced (ctest step did not run or was skipped).")
+ return 0
+
+ try:
+ root = ET.parse(xml_path).getroot()
+ except ET.ParseError as exc:
+ print(f"## Test Results — {label}")
+ print()
+ print(f"Malformed `{xml_path.name}`: {exc}")
+ return 0
+
+ suite = root if root.tag == "testsuite" else root.find("testsuite")
+ if suite is None:
+ print(f"## Test Results — {label}")
+ print()
+ print("Malformed ctest-results.xml (no `testsuite` element).")
+ return 0
+
+ total = int(suite.get("tests", "0"))
+ failures = int(suite.get("failures", "0"))
+ errors = int(suite.get("errors", "0"))
+ skipped = int(suite.get("skipped", "0"))
+ passed = max(0, total - failures - errors - skipped)
+ verdict = "PASS" if failures == 0 and errors == 0 else "FAIL"
+
+ print(f"## Test Results — {label} — {verdict}")
+ print()
+ print(f"**{passed}/{total} passed** ({failures} failed, {errors} errors, {skipped} skipped)")
+ print()
+ print("| Result | Test | Time (s) |")
+ print("|--------|------|----------|")
+ for case in suite.findall("testcase"):
+ name = case.get("name", "?")
+ raw_time = case.get("time", "")
+ try:
+ display_time = f"{float(raw_time):.2f}"
+ except ValueError:
+ display_time = raw_time
+ if case.find("failure") is not None:
+ result = "FAIL"
+ elif case.find("error") is not None:
+ result = "ERROR"
+ elif case.find("skipped") is not None:
+ result = "SKIP"
+ else:
+ result = "PASS"
+ print(f"| {result} | `{name}` | {display_time} |")
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())