Skip to content

ci: authenticate Codecov uploads with OIDC - #644

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

fbricon wants to merge 2 commits into
masterfrom
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 master, 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 #643, and also on the last push to master, while 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 #643 (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 master, 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 runs for #643 and for the last push to master show 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>
@codecov-commenter

codecov-commenter commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 24.67%. Comparing base (3655703) to head (112e21e).
⚠️ Report is 32 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #644      +/-   ##
==========================================
- Coverage   25.85%   24.67%   -1.18%     
==========================================
  Files           4        4              
  Lines         294      308      +14     
  Branches       55       61       +6     
==========================================
  Hits           76       76              
- Misses        218      232      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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
long-lived token; the upload result still shows up in the step log.

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

fbricon commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

On the red check: test (ubuntu-latest) fails in Run UI tests (Unable to create the server ... there are no rsp providers, then xvfb-run exits 1). That is the same failure as the run for #643 and predates this change — the Codecov step is after the UI tests, so it never runs on that leg.

The two legs that do reach it (macOS and Windows) upload fine with the OIDC token:

info - Using token to create a commit for protected branch `codecov-oidc`
info - Upload queued for processing complete

And Codecov uploads no longer fail the build: fail_ci_if_error is left at its default (false).

This branch was successfully deployed

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