-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not upload coverage results to Codecov when run in a fork #963
Conversation
Thanks! The example workflows already ignore the upload failures in PRs if there is no token. Isn't that enough? |
This PR addresses when I sync the upstream changes to my fork of the repository. When
|
I see, so the event in
is a We cannot solely rely on |
By this, do you mean that they do development in the fork that they never intend to submit upstream? In other words, you know of use cases where the user wants to maintain a separate Codecov account to track the code coverage only for the fork. In that case, why don't we check for the existence of Skip the Codecov upload step only if all of the following conditions are true:
Anyone doing real development in a fork that wants to configure Codecov uploads from their fork will need to define |
I don't really want to skip the upload completely, because it is supposed to work without a token as well, except in a PR. I also don't want to skip in forks if there is no token, because I want to know about these cases, so I want an error that I can fix. But these example workflows are only examples anyway, they are not going to be ideal for everyone. So feel free to adapt them to your needs. |
Thanks for considering my PR. Below I make my final arguments. If you're still unconvinced, then we can just close it.
My PR only skips it when running in a fork. And unless the user has installed the Codecov app on their fork, there is nowhere to upload to.
In my experience tokenless uploads from
I believe this behavior has changed over time. Now
I'm not sure if I fully follow. When running in a fork with no token, there is the error I have reported above:
I appreciate that. I have already fixed the workflows in the repositories that I regularly contribute to. I decided to submit this PR because I felt this would be a useful default for the R community. These example workflows are extremely popular, especially due to My view is that it is much more common for someone to fork a repository, make some changes, check that the CI passes, and then submit a PR. At least this is what I typically do. I've never configured Codecov to run on a fork. I feel that the use case of doing "real development" on a fork is the rarer option. How many R package developers fork a repository, install the Codecov app on the fork, and then define the repository secret However, I think we could support both use cases (skipping uploads on a fork, or uploading if the user defines - uses: codecov/codecov-action@v4
if: github.event.repository.fork == false || secrets.CODECOV_TOKEN |
Yes, and I would prefer to keep that error, instead of skipping silently.
You don't need to add a secret, the organization secret applies to the fork as well. I am not sure if there is anything special wrt forks in codecov, either, I don't think I had to do anything special to get coverage for https://app.codecov.io/gh/r-lib/nanoparquet But this is actually not that rare, abandoned projects get forked all the time, I have at least 10 repos that are forks.
I am not happy with skipping uploads on a fork, sorry. I think if you are pushing to a fork, then either:
|
When I sync my fork of a repository that has set
CODECOV_TOKEN
to upload coverage results to Codecov (#834), the step to upload the coverage results to Codecov fails because my fork has not definedCODECOV_TOKEN
.This PR updates the Codecov upload step to be skipped when running in a fork. However, it will still perform a token-less upload in a PR submitted from a fork. I learned about the existence of the variable
github.event.repository.fork
from peaceiris/actions-gh-pages#153 (comment)I've tested this update in two repositories I help maintain (Merck/simtrial#307, Merck/gsDesign2#496).