Skip to content
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

Is there a way to make this work with a PR from a fork #29

Closed
kevinbarabash opened this issue Oct 20, 2019 · 28 comments
Closed

Is there a way to make this work with a PR from a fork #29

kevinbarabash opened this issue Oct 20, 2019 · 28 comments

Comments

@kevinbarabash
Copy link

I have the codecov action working for PRs that I create in my repo, but it doesn't work for external contributors. I appears that secrets.CODECOV_TOKEN isn't getting set for external PRs. Is there anyway to get codecov working with PRs from forks?

@tenmozes
Copy link

tenmozes commented Oct 23, 2019

same problem as in #22
if you find the solution please share

@tenmozes
Copy link

@ibrahim0814 could you please tell about the future plans and this issue?

@kefranabg
Copy link

Regarding security, it would be bad to allows forked PRs to access your GitHub secrets.

@tenmozes
Copy link

Ok do we have suitable solution how avoid secret leaking and have tool which works?

@ibrahim0814
Copy link
Contributor

Hi all,

Currently there's no way to make this Action work for forks and PRs from other contributors since secrets are only available to the owner of the repository. We are looking to add tokenless support for Actions once GitHub releases a public API for Actions that would subsequently fix those issues. For context, we call the API during the upload process to verify repository details if no token is provided. However, until an API released, our hands are strapped.

I apologize for the limited capabilities on this particular Action right now, but we're definitely looking for ways to improve it in the near future

Ib

@hugovk
Copy link

hugovk commented Nov 20, 2019

Please give this a 👍or comment to let GitHub know:

@anuraaga
Copy link

anuraaga commented Dec 2, 2019

Hi @ibrahim0814 - found this issue looking into adding a codecov action to a public repo. You mention a dependency on a public Actions API, but I think it should be possible with current APIs. All builds have a temporary access token with read permissions for forks

https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token#permissions-for-the-github_token

So it should be possible to forward that to a codecov server and check whether the repository can be accessed by the token using current APIs such as https://developer.github.com/v3/repos/#list-your-repositories. With a repository-specific URL, I don't think it'd even need to parse any response an just check for a 403 on an API URL.

If a user wanted to make sure codecov didn't get a token with write permissions, they can tweak their workflow to use the default GITHUB_TOKEN for pull requests and a custom token scoped to read-only for pushes.

Not the greatest UX, but I think it's better than not working at all :) I'm not sure how the current out-of-box integrations for Travis / Appveyor work but I guess it's a similar process?

@hugovk
Copy link

hugovk commented Jan 8, 2020

If you hardcode the token, builds on forks (even if no PR is made) will be sent to the pytest's own Codecov, which clutters up the logs somewhat, and fork users cannot see their own coverage before creating PRs.

We temporarily worked around this (python-pillow/Pillow#4266) by adding a "Prepare coverage token" step before the "Upload coverage" step:

    - name: Prepare coverage token
      if: success() && github.repository == 'python-pillow/Pillow'
      run: cp .github/codecov-upstream.yml .codecov.yml

    - name: Upload coverage
      if: success()
      uses: codecov/codecov-action@v1
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        name: ${{ matrix.os }} Python ${{ matrix.python-version }}

https://github.com/python-pillow/Pillow/blob/ef4a0b2f4c9346db37140f102e80068abc280167/.github/workflows/test.yml#L94-L103

.github/codecov-upstream.yml is the same as .codecov.yml, except it has the hardcoded upstream token for Codecov.

If you do want GHA coverage from your own fork's builds sent to your own fork's Codecov, fetch your token from https://codecov.io/gh/my-username/pytest/settings and add it as CODECOV_TOKEN at https://github.com/my-username/pytest/settings/secrets.

ishitatsuyuki added a commit to ishitatsuyuki/rxRust that referenced this issue Jan 22, 2020
Suppresses the annoying X mark and failure notification due to codecov/codecov-action#29.
M-Adoo pushed a commit to rxRust/rxRust that referenced this issue Jan 23, 2020
Suppresses the annoying X mark and failure notification due to codecov/codecov-action#29.
Julian added a commit to python-jsonschema/jsonschema that referenced this issue Jan 26, 2020
See codecov/codecov-action#29 for discussion,
and there's an upstream GH thread about it
(which says solved IIRC, but don't be confused,
that just means acked). Two steps forward, one
step back.
@ishepard
Copy link

ishepard commented Feb 3, 2020

FYI: https://github.blog/changelog/2020-01-27-github-actions-api-beta/

There finally seems to be an API! And according to this comment, codecov is working on a tokenless upload 😃

@ibrahim0814
Copy link
Contributor

Yes, can confirm. We’re working to release that feature as quickly as possible :)

tarcieri added a commit to RustCrypto/elliptic-curves that referenced this issue Jul 12, 2020
Presently this action fails on any PR from a fork.

Codecov fixed things upstream to where public repos no longer require a
token when uploading from GitHub actions:

codecov/codecov-action#29

Upgrading should fix builds from forks
tarcieri added a commit to RustCrypto/elliptic-curves that referenced this issue Jul 12, 2020
Presently this action fails on any PR from a fork.

Codecov fixed things upstream to where public repos no longer require a
token when uploading from GitHub actions:

codecov/codecov-action#29

Upgrading should fix builds from forks
shniubobo added a commit to shniubobo/text2beep that referenced this issue Sep 5, 2020
There is no need now to provide a token when using Github Actions.
See codecov/codecov-action#29 for details.
@smorimoto
Copy link

FYI: We can do it this way without doing extra hacks now.
https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/

@s-weigand
Copy link

@smorimoto thanks for sharing 😄

matthewfeickert added a commit to scikit-hep/pyhf that referenced this issue Oct 12, 2021
* Report coverage to Codecov without using a secret Codecov token
   - c.f. codecov/codecov-action#29 (comment)
   - Effectively reverts Codecov logic part of PR #1622
* Ensure codecov/codecov-action v2 used
   - Amends PR #1623
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests