Skip to content

ci: authenticate Codecov uploads with OIDC - #345

Open
fbricon wants to merge 2 commits into
mainfrom
codecov-oidc
Open

fbricon wants to merge 2 commits into
mainfrom
codecov-oidc

Conversation

@fbricon

@fbricon fbricon commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Coverage uploads in this repo are silently rejected. codecov/codecov-action is called without a token, and Codecov only accepts tokenless uploads for unprotected branches — the action adds the owner:branch prefix only for cross-repository PRs. A push to main, or a PR from a branch in this repository, resolves to the protected default branch, and the upload is refused:

error - Upload queued for processing failed: {"message":"Token required because branch is protected"}

That happens three times (commit, report, upload) on the run for #344, and the job stays green because fail_ci_if_error defaults to false.

Fix: request id-token: write on the test job and let the action exchange it for a short-lived Codecov token (use_oidc: true). Nothing is stored, nothing needs rotating. Fork PRs cannot obtain an id-token, so the action skips OIDC for them and they keep using Codecov's tokenless path exactly as today.

Uploads stay non-blocking: fail_ci_if_error is left at its default (false), so a Codecov outage never turns a PR red.

file: → files: because that is the input name in current codecov-action v4; the old one is deprecated.

Validated with actionlint 1.7.12.

Note: this touches the same workflow as #344 (trusted publishing), so whichever lands second needs a rebase.

The test job uploads coverage with codecov/codecov-action but supplies no
token, and tokenless uploads are only accepted for unprotected branches:
the action prefixes a branch with the fork owner only for cross-repository
PRs. For a push to main, or for a PR opened from a branch in this
repository, Codecov resolves the upload to the protected default branch and
rejects it with "Token required because branch is protected".

Those rejections have been invisible because fail_ci_if_error defaults to
false. The run for #344 shows all three calls failing that way while the job
stays green.

Request an id-token and let the action exchange it for a short-lived Codecov
token instead. Fork PRs cannot obtain an id-token, so the action skips OIDC
for them and they keep using Codecov's tokenless path. fail_ci_if_error is
now set so a rejected upload fails the job rather than passing quietly.

Signed-off-by: Fred Bricon <fbricon@gmail.com>
A rejected upload or a Codecov outage should not turn the test job red.
The step keeps use_oidc and id-token: write, which is what replaces the
CODECOV_TOKEN secret; the upload result still shows up in the step log.

Signed-off-by: Fred Bricon <fbricon@gmail.com>

This branch was successfully deployed

1 active deployment
false — 3c178474 Deployed Nov 18, 2026 by fbricon via release-job #303
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