diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 5c271ac..fcb8938 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -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 diff --git a/.gitignore b/.gitignore index 04c68f4..9efb10b 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ tests/e2e/test-results/ tests/e2e/playwright-report/ __pycache__/ TestResults/ +test-output/ diff --git a/apps/behandel/project.json b/apps/behandel/project.json index 4c7a5e2..32d87f4 100644 --- a/apps/behandel/project.json +++ b/apps/behandel/project.json @@ -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": { diff --git a/apps/beheer/project.json b/apps/beheer/project.json index 890a071..d42393d 100644 --- a/apps/beheer/project.json +++ b/apps/beheer/project.json @@ -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": { diff --git a/apps/openbaar/project.json b/apps/openbaar/project.json index a85dfbd..b80161e 100644 --- a/apps/openbaar/project.json +++ b/apps/openbaar/project.json @@ -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": { diff --git a/apps/self-service/project.json b/apps/self-service/project.json index d856b4f..c4e2e38 100644 --- a/apps/self-service/project.json +++ b/apps/self-service/project.json @@ -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": { diff --git a/infra/vitest-summary.py b/infra/vitest-summary.py new file mode 100644 index 0000000..d74cd6a --- /dev/null +++ b/infra/vitest-summary.py @@ -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"))