Skip to content

ci: publish coverage badges to a dedicated branch#300

Open
Kyleasmth wants to merge 6 commits into
mainfrom
ks/YPE-2483-test-artifacts-branch
Open

ci: publish coverage badges to a dedicated branch#300
Kyleasmth wants to merge 6 commits into
mainfrom
ks/YPE-2483-test-artifacts-branch

Conversation

@Kyleasmth

@Kyleasmth Kyleasmth commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Applies the test-artifacts pattern from platform-sdk-swift#95 to this repo (YPE-2483). Coverage badge JSON stops being committed to main and instead lives on a dedicated orphan badges branch, keeping main's history clean.

What changed

  • .github/workflows/ci.yml — the test job now writes the coverage badge JSON to a scratch dir and publishes it to the orphan badges branch (via GITHUB_TOKEN) instead of committing .coverage/ to main. Dropped [skip ci] since nothing listens on badges. Self-seeds the branch if it's ever missing.
  • packages/ui/vitest.config.ts — added a coverage block with the json-summary reporter so the UI package actually emits coverage-summary.json (core/hooks already did). Without it the UI badge could never render.
  • README.md — added core/hooks/ui coverage badges pointing at the badges branch.
  • .gitignore — ignore the .coverage/ and coverage-output/ scratch dirs; removed the tracked .coverage/.gitkeep.
  • changeset — empty (CI/tooling only, no package release).

Notes

  • The orphan badges branch is already pre-seeded (mirroring the Swift PR), so badges render immediately with no broken-badge window at merge: core 92.7% 🟢, hooks 90.47% 🟢, ui 79.9% 🟡.
  • main receives no commitsbadges is an isolated orphan history containing only the three JSON files.

@jhampton — followed your Swift badges-branch pattern here; tagging you since you filed the ticket. 🙂

Test plan

  • pnpm install --frozen-lockfile, pnpm lint, pnpm typecheck, pnpm test all green under Node 24
  • packages/ui now emits coverage-summary.json
  • ci.yml validates as YAML
  • badges branch seeded; raw endpoint returns HTTP 200
  • After merge: first main CI run updates the badges branch and the README badges keep rendering

Greptile Summary

This PR migrates coverage badge publishing from committing JSON files to main to pushing them onto a dedicated orphan badges branch, keeping main's history clean. It also adds a json-summary coverage reporter to packages/ui so the UI badge can be generated, and adds three shields.io endpoint badges to the README.

  • ci.yml — splits the old single-job approach into a test job (generates badge JSON, uploads artifact) and a new publish-coverage-badges job (runs only on main, clones the badges branch, replaces all JSON files atomically, and pushes). The contents: write permission is now scoped only to the publishing job.
  • packages/ui/vitest.config.ts — adds a root-level coverage block (provider: v8, json-summary reporter, ./coverage output dir) so the UI package emits coverage-summary.json alongside the other two packages.
  • .gitignore / .coverage/.gitkeep — scratch directories are now gitignored and the old tracked placeholder is removed.

Confidence Score: 4/5

Safe to merge as-is given the badges branch is already seeded, but the workflow has no recovery path if that branch is ever deleted.

The publish-coverage-badges job hard-requires the badges branch to exist — the checkout step will throw a reference not found error if it is gone, breaking every push to main until someone manually re-creates it. The PR description explicitly promises self-seeding but the implementation does not include it. All other changes are straightforward and low-risk.

publish-coverage-badges job in .github/workflows/ci.yml — the branch checkout has no fallback for a missing badges ref.

Important Files Changed

Filename Overview
.github/workflows/ci.yml Refactors badge publishing into a dedicated job on the badges orphan branch. Clean separation of concerns, but the badges branch checkout will fail hard if the branch is ever deleted — the self-seeding described in the PR description is not implemented.
packages/ui/vitest.config.ts Adds coverage block with json-summary reporter at the root test config level, which is the correct placement for Vitest projects. Coverage output goes to ./coverage, matching the path expected by the CI script.
README.md Adds three shields.io endpoint badges pointing at raw JSON files on the badges branch — straightforward and correct.
.gitignore Adds .coverage/ and coverage-output/ ignore entries to keep scratch dirs out of main; removes the now-deleted .gitkeep.
.changeset/test-artifacts-badges-branch.md Empty changeset for a CI/tooling-only change — correct per unified versioning convention (no package release triggered).

Sequence Diagram

sequenceDiagram
    participant PR as Push to main
    participant TJ as test job
    participant ART as GitHub Artifacts
    participant PJ as publish-coverage-badges job
    participant BB as badges branch

    PR->>TJ: trigger CI
    TJ->>TJ: pnpm test:coverage
    TJ->>TJ: Build badge JSON (core/hooks/ui)
    TJ->>ART: upload-artifact (coverage-badges)
    ART-->>PJ: needs: test (main only)
    PJ->>BB: checkout ref:badges to badges-branch
    PJ->>ART: download-artifact to coverage-output
    PJ->>BB: "rm *.json, cp coverage-output/*.json"
    PJ->>BB: git commit + git push
Loading

Reviews (5): Last reviewed commit: "Merge branch 'main' into ks/YPE-2483-tes..." | Re-trigger Greptile

@Kyleasmth
Kyleasmth requested a review from jhampton July 22, 2026 17:10
@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d1ca40f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread .github/workflows/ci.yml Outdated

@jhampton jhampton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile feedback and similar idiosyncrasies as the other PR

Comment thread .github/workflows/ci.yml Outdated
@Kyleasmth

Copy link
Copy Markdown
Collaborator Author

Addressed the feedback here plus the same idiosyncrasies from #95:

  • Token is no longer baked into a URL — the badges branch is checked out with actions/checkout, so auth is handled by the action, never in a string or the logs.
  • Badge publishing moved into its own main-only job (publish-coverage-badges) gated at the job level, instead of the per-step if.
  • Per Greptile: a missing coverage summary now fails the build (exit 1), and the publish step clears the badge set before copying so a dropped package can't leave a stale badge.

Ready for another look when you have a sec.

@Kyleasmth
Kyleasmth requested a review from jhampton July 23, 2026 20:01
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