Skip to content

Report coverage through Codecov instead of a hardcoded badge - #17

Merged
rt87 merged 1 commit into
mainfrom
ci_codecov-instead-of-a-hardcoded-coverage-badge
Oct 22, 2026
Merged

rt87 merged 1 commit into
mainfrom
ci_codecov-instead-of-a-hardcoded-coverage-badge

Conversation

@rt87

@rt87 rt87 commented Oct 22, 2026

Copy link
Copy Markdown
Owner

The README's coverage 100% badge was hardcoded. The number was true — the four resolved-Alembic jobs run
with --cov-fail-under=100 — but nothing measured it, so it would have kept claiming 100% after a drop.

The resolved jobs now also write coverage.xml and upload it to Codecov, one flag per interpreter so the
four reports merge instead of overwriting each other, and the badge becomes a live measurement.

Decisions in here

  • OIDC, not a secret. No CODECOV_TOKEN to manage or leak. That needs id-token: write on the test
    job; the token is minted for the audience https://codecov.io and can do nothing else. (release.yml
    keeps id-token away from its build job for a different reason — that one could publish.)
  • fail_ci_if_error: false. The gate already enforces the line. A Codecov outage, or a fork PR where
    OIDC is unavailable, says nothing about this code and must not fail the build.
  • codecov.yml mirrors the gate (project and patch target 100%, threshold 0%) rather than inventing a
    looser second standard; waits for all four uploads before judging a commit; ignores tests/ and
    examples/.
  • The badge URL was measured, not assumed. The old codecov.io/gh/<repo>/branch/<b>/graph/badge.svg
    form renders unknown even for repositories that do have coverage — checked against psf/requests. The
    shields.io endpoint and the newer codecov.io/github/<repo>/graph/badge.svg both work; this uses
    shields, matching the rest of the badge row.

What this PR cannot do

Codecov has to have the repository enabled before anything renders. If the first run on main leaves the
badge reading unknown, the answer is to drop the badge again rather than leave a dead one in the README.

Verified locally: pytest --cov-fail-under=100 --cov-report=xml → 115 passed, 100%, coverage.xml written
with src/alembic_static_data/... paths. Both YAML files parse.

🤖 Generated with Claude Code

https://claude.ai/code/session_017D7FmgZ7gdsg5dKbQWBiN7

The README claimed `coverage 100%` from a static shields.io badge. The number
was true - the four resolved-Alembic jobs run with --cov-fail-under=100 - but
nothing measured it, so it would have gone on claiming 100% after a drop.

The resolved jobs now also write coverage.xml and upload it to Codecov, one
flag per interpreter so the four reports merge instead of overwriting each
other. The badge becomes a live measurement.

Details worth knowing:

- Upload authenticates with OIDC, so there is no CODECOV_TOKEN secret to manage
  or leak. That needs id-token: write on the test job; the token is minted for
  the audience https://codecov.io and can do nothing else. release.yml keeps
  id-token away from its build job for a different reason - that one could
  publish.
- fail_ci_if_error is false on purpose. The gate above already enforces the
  line; a Codecov outage, or a fork PR where OIDC is unavailable, says nothing
  about the code.
- codecov.yml mirrors the gate (project and patch target 100%, threshold 0%)
  rather than inventing a looser second standard, waits for all four uploads
  before judging a commit, and ignores tests/ and examples/.
- The badge URL matters: the old codecov.io/gh/<repo>/branch/<b>/graph/badge.svg
  form renders "unknown" even for repositories that do have coverage - checked
  against psf/requests. The shields.io endpoint and the newer
  codecov.io/github/<repo>/graph/badge.svg form both work; this uses shields,
  matching the rest of the badge row.

Codecov has to have the repository enabled for any of this to render; until
then the badge reads "unknown".

Claude-Session: https://claude.ai/code/session_017D7FmgZ7gdsg5dKbQWBiN7
@rt87
rt87 merged commit b514d44 into main Oct 22, 2026
10 checks passed
@rt87
rt87 deleted the ci_codecov-instead-of-a-hardcoded-coverage-badge branch October 22, 2026 18:12
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