Switch publish-report action to generate Markdown test reports instead of HTML; modify report structure and formatting.
Build and Analyse / build-and-analyse (push) Failing after 38s
Build and Analyse / build-and-analyse (push) Failing after 38s
This commit is contained in:
@@ -24,25 +24,55 @@ runs:
|
|||||||
cp "$f" "junit-short/${short}"
|
cp "$f" "junit-short/${short}"
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Generate HTML Report
|
- name: Generate Markdown Report
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
pip install junit2html --quiet
|
|
||||||
python3 - <<'EOF'
|
python3 - <<'EOF'
|
||||||
import glob, xml.etree.ElementTree as ET
|
import glob, xml.etree.ElementTree as ET
|
||||||
|
|
||||||
files = glob.glob("junit-short/*.xml")
|
files = glob.glob("junit-short/*.xml")
|
||||||
root = ET.Element("testsuites")
|
total_tests = total_failures = total_errors = total_skipped = 0
|
||||||
for f in files:
|
rows = []
|
||||||
|
|
||||||
|
for f in sorted(files):
|
||||||
tree = ET.parse(f)
|
tree = ET.parse(f)
|
||||||
r = tree.getroot()
|
r = tree.getroot()
|
||||||
if r.tag == "testsuites":
|
suites = r.findall("testsuite") if r.tag == "testsuites" else [r]
|
||||||
root.extend(r)
|
for ts in suites:
|
||||||
else:
|
name = ts.get("name", f)
|
||||||
root.append(r)
|
tests = int(ts.get("tests", 0))
|
||||||
ET.ElementTree(root).write("junit-short/merged.xml")
|
failures = int(ts.get("failures", 0))
|
||||||
EOF
|
errors = int(ts.get("errors", 0))
|
||||||
mkdir -p reports
|
skipped = int(ts.get("skipped", 0))
|
||||||
junit2html junit-short/merged.xml reports/index.html
|
passed = tests - failures - errors - skipped
|
||||||
|
status = "✅" if (failures + errors) == 0 else "❌"
|
||||||
|
total_tests += tests
|
||||||
|
total_failures += failures
|
||||||
|
total_errors += errors
|
||||||
|
total_skipped += skipped
|
||||||
|
rows.append(f"| {status} | {name} | {tests} | {passed} | {failures + errors} | {skipped} |")
|
||||||
|
|
||||||
|
total_passed = total_tests - total_failures - total_errors - total_skipped
|
||||||
|
overall = "✅ All tests passed" if (total_failures + total_errors) == 0 else "❌ Some tests failed"
|
||||||
|
|
||||||
|
md = f"""# Test Report
|
||||||
|
|
||||||
|
**{overall}**
|
||||||
|
|
||||||
|
| | Tests | Passed | Failed | Skipped |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| **Total** | {total_tests} | {total_passed} | {total_failures + total_errors} | {total_skipped} |
|
||||||
|
|
||||||
|
## Details
|
||||||
|
|
||||||
|
| Status | Suite | Tests | Passed | Failed | Skipped |
|
||||||
|
|---|---|---|---|---|---|
|
||||||
|
""" + "\n".join(rows) + "\n"
|
||||||
|
|
||||||
|
with open("reports/index.md", "w") as out:
|
||||||
|
out.write(md)
|
||||||
|
print(md)
|
||||||
|
EOF
|
||||||
|
|
||||||
- name: Commit Report to Repo
|
- name: Commit Report to Repo
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
Reference in New Issue
Block a user