r-lib / usethis

Set up commonly used 📦 components
https://usethis.r-lib.org/
Other
854 stars 284 forks source link

CodeCov requires a CODECOV_TOKEN #1435

Closed statnmap closed 3 years ago

statnmap commented 3 years ago

I set up codecov for my package but the report would not be created without the CODECOV_TOKEN set in the environment variable of my GitHub Action.
Maybe one of the two function I used below to set up the action could add a message to set up this Token to be able to use it on a CI. I think use_coverage() is the place because this token will be necessary for other CI than Actions.
You can use the link of the Badge created to inform the developers to follow this link a get the Token that will be shown on the page.

usethis::use_coverage()
usethis::use_github_action("test-coverage")
malcolmbarrett commented 3 years ago

I was under the impression that public repositories didn't need a token (and I don't recall setting one up any time recently); likewise, the actions template does not use a token (https://github.com/r-lib/actions/blob/master/examples/test-coverage.yaml). I'm now having issues as well, however: https://github.com/malcolmbarrett/code.cov.test/runs/2421122388?check_suite_focus=true.

A little issue surfing suggests that the uploader might have changed very recently to address similar issues: https://community.codecov.io/t/add-support-of-uploading-from-cirrus-ci-without-token/1028/32

@jimhester might have a better sense of what's happening here.

jimhester commented 3 years ago

Yes @malcolmbarrett that is correct, public repositories don't need a token, it is possible this was a temporary regression in the codecov.io service, it seems to be resolved now.

jennybc commented 3 years ago

I'm going to close, assuming this was part of the dust settling while Codecov responded to their breach. We can reopen if I'm wrong.

Moohan commented 2 years ago

Could this be related to caveat b, i.e. non-travis CI needs a token ?

privefl commented 1 year ago

I get this error "Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue." (cf. https://github.com/privefl/bigstatsr/actions/runs/3224863943/jobs/5276476155#step:5:5054).

Is it related? If so, how to get the token, and where to put it?

statnmap commented 1 year ago

You need to login to CodeCov.io and get your TOKEN for this specific project from there.
In your case, I guess this is: https://app.codecov.io/gh/privefl/bigstatsr/settings And add it to the secrets variables for GitHub Actions with CODECOV_TOKEN

You may be able to create a global Token from your user settings too, although I did not test this way. Probably here for you: https://app.codecov.io/account/gh/privefl/access

statnmap commented 1 year ago

Codecov says that if you use their GitHub Action, you should not need token for public repositories: https://github.com/codecov/codecov-action#usage

Can you start by updating the "test-coverage" action. I think it was fixed.

usethis::use_github_action("test-coverage")
privefl commented 1 year ago

Using a global CODECOV_TOKEN seems to have solved my problem. Thanks for the tip