Repository navigation
Upload to Codecov with OIDC so Dependabot PRs can pass - #1819
Merged
Merged
Conversation
Dependabot-triggered workflow runs are not given GitHub Actions secrets, so CODECOV_TOKEN was empty and Codecov rejected the upload with "Token required because branch is protected". With fail_ci_if_error set, that failed every job in the test matrix on every Dependabot PR. Authenticate with a short-lived GitHub OIDC token instead, which needs no secret and is available to Dependabot runs. Fork PRs are unaffected: the action skips OIDC for forks and keeps using Codecov's tokenless upload.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1819 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 23 23
Lines 6632 6632
=======================================
Hits 6616 6616
Misses 16 16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every Dependabot PR fails the whole
Testsmatrix (currently #1818). The tests themselves pass; theUpload coverage to Codecovstep fails with:GitHub does not give Actions secrets to workflow runs triggered by Dependabot, so
secrets.CODECOV_TOKENis empty there. Codecov only accepts tokenless uploads from fork PRs, andDependabot branches live in this repository, so the upload is rejected and
fail_ci_if_error: truefails the job.
Fix
Authenticate the Codecov uploads with a short-lived GitHub OIDC token (
use_oidc: true) instead ofthe long-lived
CODECOV_TOKENsecret. This needsid-token: writeon thetestsjob; theworkflow-level default stays
contents: read.CODECOV_TOKENrepository secret is no longer referenced by any workflow.Verification
Testsrun exercises the OIDC upload for a same-repository branch.@dependabot rebaseon Bump astral-sh/setup-uv from 7.6.0 to 10.3.3 #1818 exercises it for a Dependabot-triggered run.