Repository navigation
ci: fall back to GITHUB_TOKEN for grcov install on fork PRs - #961
Merged
Merged
Conversation
Secrets are withheld from workflows triggered by pull_request events from forks, so secrets.PAT_TOKEN expands to an empty string. Actions drops empty inputs, leaving setup-grcov without its required github-token and failing the job before coverage runs. GITHUB_TOKEN is minted per job and stays available on fork PRs, where it is forced read-only. That is sufficient to download a grcov release asset, so fork PRs no longer depend on a secret they cannot receive.
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.
The
cargo testjob fails on every pull request opened from a fork, before the coverage report is generated. Tests themselves pass; the job dies at the Install grcov step withInput required and not supplied: github-token. This makes the fix a prerequisite for merging any external contribution.The cause is that GitHub withholds repository secrets from workflows triggered by
pull_requestevents originating in a fork.secrets.PAT_TOKENtherefore expands to an empty string, and because Actions drops empty inputs entirely,SierraSoftworks/setup-grcovsees its requiredgithub-tokeninput as absent rather than blank.How it works
secrets.PAT_TOKEN || secrets.GITHUB_TOKENkeeps the PAT on branch pushes and same-repo pull requests, where it is available and carries higher API rate limits.GITHUB_TOKEN, which is minted per job rather than stored as a repository secret and so remains available.GITHUB_TOKENis forced read-only for fork pull requests. Downloading a grcov release asset needs only read access, so the reduced scope is sufficient.GITHUB_TOKENis already present in every job context; passing it as an action input does not widen what a workflow can reach.Caveats
PAT_TOKENfrom fork pull requests is a deliberate protection, not a misconfiguration. Routing around it withpull_request_targetwould run the base workflow with full secrets and is deliberately not done here.arduino/setup-protocreads the same secret viarepo-tokenand is left unchanged. It treats the token as optional, so on fork pull requests it silently falls back to unauthenticated API calls and could hit rate limits under load. Worth a follow-up, but it is not currently failing.codecov/codecov-actionupload step runs without a token on fork pull requests. Tokenless upload generally works for public repositories, so it is untouched here.main; no rebase is needed. Re-running an existing failed run reuses the old commit and will not see the change, so a fresh run is required.