Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": <percent>` in `backend/.c8rc.json`.

### Migrations
Expand Down
7 changes: 4 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": <percent>` in `backend/.c8rc.json`.

### Migrations
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Loading