92 lines
3.1 KiB
YAML
92 lines
3.1 KiB
YAML
name: Publish JUnit Report (Short Names)
|
|
description: Normalize JUnit XML report names and publish a summary-only test report.
|
|
inputs:
|
|
token:
|
|
description: GitHub token for creating the check run.
|
|
required: true
|
|
report-name:
|
|
description: Name shown for the test report.
|
|
required: false
|
|
default: Summary of JUnit Tests
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Normalize JUnit report names
|
|
shell: bash
|
|
run: |
|
|
mkdir -p junit-short
|
|
shopt -s globstar nullglob
|
|
for f in **/target/*-reports/TEST-*.xml; do
|
|
base="$(basename "$f")"
|
|
short="${base#TEST-}"
|
|
short="${short%.xml}"
|
|
cp "$f" "junit-short/${short}"
|
|
done
|
|
|
|
- name: Generate Markdown Report
|
|
shell: bash
|
|
run: |
|
|
python3 - <<'EOF'
|
|
import glob, xml.etree.ElementTree as ET
|
|
|
|
files = glob.glob("junit-short/*.xml")
|
|
total_tests = total_failures = total_errors = total_skipped = 0
|
|
rows = []
|
|
|
|
for f in sorted(files):
|
|
tree = ET.parse(f)
|
|
r = tree.getroot()
|
|
suites = r.findall("testsuite") if r.tag == "testsuites" else [r]
|
|
for ts in suites:
|
|
name = ts.get("name", f)
|
|
tests = int(ts.get("tests", 0))
|
|
failures = int(ts.get("failures", 0))
|
|
errors = int(ts.get("errors", 0))
|
|
skipped = int(ts.get("skipped", 0))
|
|
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
|
|
shell: bash
|
|
env:
|
|
GIT_USER: gitea-actions-bot
|
|
GIT_EMAIL: bot@mein-gateway.de
|
|
GITEA_TOKEN: ${{ inputs.token }}
|
|
run: |
|
|
git config user.name "$GIT_USER"
|
|
git config user.email "$GIT_EMAIL"
|
|
git remote set-url origin https://$GIT_USER:$GITEA_TOKEN@git.mein-gateway.de/${{ github.repository }}.git
|
|
git fetch origin
|
|
git checkout ${{ github.ref_name }}
|
|
git add reports/
|
|
git diff --cached --quiet && echo "No changes" && exit 0
|
|
git commit -m "ci: update test report [skip ci]"
|
|
git push origin ${{ github.ref_name }} |