ci: per-frontend test table in the run summary via vitest json (refs #136)
This commit is contained in:
@@ -90,6 +90,12 @@ jobs:
|
||||
node-version: '24'
|
||||
cache: 'pnpm'
|
||||
- run: make frontend
|
||||
# Job summary (#136): a per-frontend (app) pass/fail table from the vitest JSON each app wrote.
|
||||
- name: Frontend test summary
|
||||
if: always()
|
||||
run: |
|
||||
[ -n "${GITHUB_STEP_SUMMARY:-}" ] || exit 0
|
||||
python3 infra/vitest-summary.py test-output >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
mutation:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -59,3 +59,4 @@ tests/e2e/test-results/
|
||||
tests/e2e/playwright-report/
|
||||
__pycache__/
|
||||
TestResults/
|
||||
test-output/
|
||||
|
||||
@@ -64,7 +64,9 @@
|
||||
"test": {
|
||||
"executor": "@angular/build:unit-test",
|
||||
"options": {
|
||||
"watch": false
|
||||
"watch": false,
|
||||
"reporters": ["default", "json"],
|
||||
"outputFile": "{workspaceRoot}/test-output/{projectName}.json"
|
||||
}
|
||||
},
|
||||
"serve-static": {
|
||||
|
||||
@@ -64,7 +64,9 @@
|
||||
"test": {
|
||||
"executor": "@angular/build:unit-test",
|
||||
"options": {
|
||||
"watch": false
|
||||
"watch": false,
|
||||
"reporters": ["default", "json"],
|
||||
"outputFile": "{workspaceRoot}/test-output/{projectName}.json"
|
||||
}
|
||||
},
|
||||
"serve-static": {
|
||||
|
||||
@@ -64,7 +64,9 @@
|
||||
"test": {
|
||||
"executor": "@angular/build:unit-test",
|
||||
"options": {
|
||||
"watch": false
|
||||
"watch": false,
|
||||
"reporters": ["default", "json"],
|
||||
"outputFile": "{workspaceRoot}/test-output/{projectName}.json"
|
||||
}
|
||||
},
|
||||
"serve-static": {
|
||||
|
||||
@@ -64,7 +64,9 @@
|
||||
"test": {
|
||||
"executor": "@angular/build:unit-test",
|
||||
"options": {
|
||||
"watch": false
|
||||
"watch": false,
|
||||
"reporters": ["default", "json"],
|
||||
"outputFile": "{workspaceRoot}/test-output/{projectName}.json"
|
||||
}
|
||||
},
|
||||
"serve-static": {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Render a per-frontend test table from vitest JSON reports for a Gitea job summary (#136).
|
||||
|
||||
Reads every *.json in the given directory (default: test-output), each written by an app's
|
||||
`test` target (reporters: json, outputFile: {workspaceRoot}/test-output/{projectName}.json), and
|
||||
prints a markdown table to stdout — one row per frontend app. The CI step redirects it into
|
||||
$GITHUB_STEP_SUMMARY. Stdlib only.
|
||||
"""
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main(results_dir):
|
||||
rows = []
|
||||
for path in sorted(glob.glob(os.path.join(results_dir, "*.json"))):
|
||||
try:
|
||||
with open(path) as fh:
|
||||
d = json.load(fh)
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
rows.append({
|
||||
"name": os.path.splitext(os.path.basename(path))[0],
|
||||
"passed": d.get("numPassedTests", 0),
|
||||
"failed": d.get("numFailedTests", 0),
|
||||
"skipped": d.get("numPendingTests", 0) + d.get("numTodoTests", 0),
|
||||
"total": d.get("numTotalTests", 0),
|
||||
"ok": d.get("success", False),
|
||||
})
|
||||
if not rows:
|
||||
print("_No frontend test results found._")
|
||||
return 0
|
||||
print("## 🅰️ Frontend tests\n")
|
||||
print("| Frontend | Result | Passed | Failed | Skipped | Total |")
|
||||
print("| -------- | :----: | -----: | -----: | ------: | ----: |")
|
||||
for r in rows:
|
||||
status = "✅" if r["ok"] and not r["failed"] else "❌"
|
||||
print(f"| {r['name']} | {status} | {r['passed']} | {r['failed']} | {r['skipped']} | {r['total']} |")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1] if len(sys.argv) > 1 else "test-output"))
|
||||
Reference in New Issue
Block a user