Skip to content

Replace Coveralls badge with self-hosted coverage badge on Pages#216

Merged
Fivell merged 1 commit intomasterfrom
coverage-badge
Apr 8, 2026
Merged

Replace Coveralls badge with self-hosted coverage badge on Pages#216
Fivell merged 1 commit intomasterfrom
coverage-badge

Conversation

@Fivell
Copy link
Copy Markdown
Member

@Fivell Fivell commented Apr 8, 2026

Summary

The README has been carrying a Coveralls badge for years, but no workflow in this repo actually pushes data to Coveralls (no coverallsapp/github-action, no coveralls gem). The badge has been showing whatever was last reported in the Travis era.

SimpleCov already runs locally in the existing coverage job and produces coverage/.last_run.json. We can use that file directly to mint a static shields.io endpoint badge JSON, deploy it to GitHub Pages from CI, and have the README badge point at it. No third-party service.

Changes

.github/workflows/test.yml

  • Adds top-level permissions block (contents: read, pages: write, id-token: write) — required by the Pages deployment actions
  • In the existing coverage job, after the SimpleCov run:
    • Generate badge/badge.json — reads coverage/.last_run.json, rounds the line percentage, picks a color bucket (brightgreen ≥90, green ≥75, yellow ≥60, otherwise red), and writes a shields.io endpoint document
    • Upload coverage-badge artifact with that file
  • New deploy-coverage job (only on push to master):
    • Downloads the coverage-badge artifact
    • Configures Pages, uploads the artifact via actions/upload-pages-artifact@v3
    • Deploys via actions/deploy-pages@v4 into the github-pages environment

README.md

  • Drops the dead [coveralls_badge] / [coveralls_link] reference definitions
  • Replaces the badge with ![Coverage][coverage_badge] pointing at https://img.shields.io/endpoint?url=https://activeadmin-plugins.github.io/active_admin_import/badge.json
  • Tightens the badge label spacing for consistency

Post-merge steps (manual, by repo admin)

  1. Flip Pages source from the legacy gh-pages branch to GitHub Actions workflow build:
    • UI: Settings → Pages → Source → "GitHub Actions"
    • API: gh api -X POST repos/activeadmin-plugins/active_admin_import/pages/deployments won't do this; the source change has to go through PUT repos/.../pages or the UI
  2. Re-run the Run workflow on master so deploy-coverage publishes the badge
  3. Once the badge is live and the README renders correctly, the now-orphaned gh-pages branch can be deleted: git push origin --delete gh-pages

Test plan

  • Workflow YAML validates locally
  • PR CI green (the deploy-coverage job is gated on push to master so it won't run from this PR — it will first run after merge)
  • Badge renders correctly in README after Pages source switch + first master deploy

Mirrors the active_admin_sidebar setup. SimpleCov already runs in the
coverage job; this commit adds:

- A step that reads coverage/.last_run.json, picks a shields.io color
  bucket, and writes a static badge.json in the shields endpoint format
- An upload-artifact step for the badge
- A deploy-coverage job (master pushes only) that downloads the badge
  and deploys it to GitHub Pages via actions/deploy-pages@v4
- Top-level permissions block (contents/pages/id-token) required by
  the Pages deployment actions

The README badge is switched from the dead Coveralls endpoint (no
workflow has pushed to it for years) to a shields.io endpoint badge
pointing at the new gh-pages-served badge.json.

After merging, the Pages source needs to be flipped from the legacy
gh-pages branch to "GitHub Actions" workflow build, after which the
gh-pages branch can be deleted.
@Fivell Fivell merged commit f2cfcba into master Apr 8, 2026
37 checks passed
@Fivell Fivell deleted the coverage-badge branch April 8, 2026 10:34
@Fivell Fivell mentioned this pull request Apr 8, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant