diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 27bac0705..afcc674d4 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -31,10 +31,11 @@ jobs: backend/coverage/lcov-report if-no-files-found: error - # Turns the coverage artifact into an SVG badge (scripts/coverage-report.mjs, no dependencies, - # no external service) and force-pushes it — plus the raw summary — to the orphan `badges` - # branch as a single commit, with the workflow's own GITHUB_TOKEN. README.md embeds it from - # https://github.com/rocket-admin/rocketadmin/raw/badges/backend-coverage.svg. + # Turns the coverage artifact into a Markdown report (metrics table) plus an SVG badge + # (scripts/coverage-report.mjs, no dependencies, no external service) and force-pushes them — + # with the raw summary — to the orphan `badges` branch as a single commit, with the workflow's + # own GITHUB_TOKEN. README.md links to the report (a link never renders as a broken image; the + # branch only exists after the first main build). coverage-badge: if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: test @@ -56,16 +57,14 @@ jobs: mkdir -p badges node scripts/coverage-report.mjs badge coverage-artifact/coverage-summary.json badges/backend-coverage.svg "backend coverage" cp coverage-artifact/coverage-summary.json badges/backend-coverage-summary.json - pct=$(node -e "console.log(require('./badges/backend-coverage-summary.json').total.lines.pct.toFixed(1))") { - echo "# Coverage badges" + echo "# Test coverage" echo echo "Generated by \`.github/workflows/backend.yml\` (job \`coverage-badge\`) for" echo "\`${GITHUB_SHA}\` on $(date -u +%Y-%m-%dT%H:%M:%SZ). Do not edit — every run replaces this branch." + echo "Per-file detail: the \`coverage-backend\` artifact (lcov + HTML report) of that run." echo - echo "| Package | Lines |" - echo "| --- | --- |" - echo "| backend | ${pct}% |" + node scripts/coverage-report.mjs markdown backend badges/backend-coverage-summary.json } > badges/README.md - name: publish to the badges branch env: diff --git a/AGENTS.md b/AGENTS.md index 34eaf0293..5dad2c029 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -62,9 +62,10 @@ runs as `appuser`, which is why the `Dockerfile` pre-creates `/app/backend/cover CI (`.github/workflows/backend.yml`): the `test` job runs `just test-coverage`, writes a lines / statements / functions / branches table to the job summary (`scripts/coverage-report.mjs markdown`) and uploads -`coverage-backend` as an artifact; on push to `main` the `coverage-badge` job renders the SVG badge at the top of -`README.md` (`scripts/coverage-report.mjs badge`) and force-pushes it to the orphan `badges` branch using the -workflow's own `GITHUB_TOKEN` — no external service or secret. No minimum coverage is enforced; a gate is +`coverage-backend` as an artifact; on push to `main` the `coverage-badge` job writes the metrics table that the +top of `README.md` links to (plus an SVG badge, `scripts/coverage-report.mjs`) and force-pushes it to the orphan +`badges` branch using the workflow's own `GITHUB_TOKEN` — no external service or secret. A link rather than an +embedded image: the image is broken until that branch exists. No minimum coverage is enforced; a gate is `"check-coverage": true` plus `"lines": ` in `backend/.c8rc.json`. ### Migrations diff --git a/CLAUDE.md b/CLAUDE.md index 34eaf0293..5dad2c029 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -62,9 +62,10 @@ runs as `appuser`, which is why the `Dockerfile` pre-creates `/app/backend/cover CI (`.github/workflows/backend.yml`): the `test` job runs `just test-coverage`, writes a lines / statements / functions / branches table to the job summary (`scripts/coverage-report.mjs markdown`) and uploads -`coverage-backend` as an artifact; on push to `main` the `coverage-badge` job renders the SVG badge at the top of -`README.md` (`scripts/coverage-report.mjs badge`) and force-pushes it to the orphan `badges` branch using the -workflow's own `GITHUB_TOKEN` — no external service or secret. No minimum coverage is enforced; a gate is +`coverage-backend` as an artifact; on push to `main` the `coverage-badge` job writes the metrics table that the +top of `README.md` links to (plus an SVG badge, `scripts/coverage-report.mjs`) and force-pushes it to the orphan +`badges` branch using the workflow's own `GITHUB_TOKEN` — no external service or secret. A link rather than an +embedded image: the image is broken until that branch exists. No minimum coverage is enforced; a gate is `"check-coverage": true` plus `"lines": ` in `backend/.c8rc.json`. ### Migrations diff --git a/README.md b/README.md index b9721312d..218628d93 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ ## Rocket Admin -[![backend test coverage](https://github.com/rocket-admin/rocketadmin/raw/badges/backend-coverage.svg)](https://github.com/rocket-admin/rocketadmin/actions/workflows/backend.yml) +**Backend test coverage:** [latest report](https://github.com/rocket-admin/rocketadmin/blob/badges/README.md) +(rewritten on every `main` build by the [backend workflow](https://github.com/rocket-admin/rocketadmin/actions/workflows/backend.yml)) ![720](https://github.com/rocket-admin/rocketadmin/assets/75169/31f1ac1b-ded0-40b6-984a-e50a3ddc4ee2)