Skip to content

ci: add auto-updating test coverage badge to README - #89

Draft
artall64 wants to merge 1 commit into
masterfrom
cursor/coverage-badge-5f5a
Draft

artall64 wants to merge 1 commit into
masterfrom
cursor/coverage-badge-5f5a

Conversation

@artall64

@artall64 artall64 commented Jul 15, 2026

Copy link
Copy Markdown

Summary

Adds an auto-updating test coverage badge to the README, computed entirely inside GitHub Actions (no third-party services). Same approach as 1inch/cross-chain#428.

  • README: embeds the badge at the top, served from the orphan badges branch via https://github.com/1inch/cross-chain-sdk/raw/badges/coverage-badge.svg.
  • .github/workflows/coverage-badge.yml: on every push to master (and manual dispatch) it installs dependencies, runs pnpm test:cov, renders the badge SVG, and force-pushes it to the badges branch. On PRs it runs only when the coverage tooling itself changes, and skips publishing. Runner/pnpm/node setup mirrors pr-check.yml (ubuntu-latest, pnpm 10, node 20).
  • scripts/generate-coverage-badge.mjs: renders a shields.io-style SVG (total line coverage, color-coded) from Jest's json-summary reporter output.
  • package.json: adds a test:cov script (jest --coverage with text-summary + json-summary reporters).
  • jest.config.js: coverage reports now land in <repo>/coverage (gitignored) instead of src/coveragecoverageDirectory is resolved relative to rootDir (src), so the previous value wrote inside the source tree.

The badges branch has been seeded with the real current value (88.2% line coverage), so the README renders immediately; the workflow refreshes it on every subsequent push to master.

Verification

  • The pull_request run of the Coverage badge workflow on this PR passed (23 suites / 133 tests, total line coverage 88.2%).
  • The PR validation failure is unrelated: npm retired its legacy audit endpoint (HTTP 410 from registry.npmjs.org/-/npm/v1/security/audits), which breaks the pnpm audit step on every branch as of today — the same step passed on other PRs as recently as July 14.

Notes

  • Coverage reflects the unit test suite (jest.config.js); integration tests are not included.
  • The publish step relies on the workflow GITHUB_TOKEN having contents: write (declared in the workflow). If the org enforces read-only workflow tokens, the push step will fail and a PAT/deploy key would be needed instead.
Open in Web Open in Cursor 

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.

2 participants