Use token when uploading unit test code coverage data to Codecov from workflow #368
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.
Codecov claims a token is not needed when using the
codecov/codecov-action
GitHub Actions action in workflows of a public repository:https://github.com/codecov/codecov-action#usage
However, experience shows that that step of the workflow is subject to intermittent spurious failures caused by a 404 error during the upload attempt:
https://github.com/arduino-libraries/ArduinoIoTCloud/actions/runs/5403452364/jobs/9816277077#step:4:32
It is suggested that this can be avoided by using the Codecov upload token for the repository (which can be passed to the
codecov/codecov-action
action via thetoken
input):https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
It should be noted that PRs from forks do not have access to repository secrets, so the approach suggested there of using an encrypted repository secret for the token would mean that PRs from forks (the workflow runs for which don't have access to secrets) would still be subject to the same intermittent spurious workflow run failures.
The alternative approach is to add the token in plaintext directly in the workflow. The security implications of that
approach are described here:
https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
I have evaluated the risks of exposing the token and am intentionally choosing to accept the possibility of it being used by a malicious actor to upload incorrect coverage data for this project to Codecov.