-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Implement code coverage in GitHub actions #6441
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
Conversation
This overwrites the `codecov.yml` file in the root of the repository with `codecov-upstream.yml` file (which contains the code-cov token)´, so PRs and branches on the repository can upload coverage. Suggestion from here: pytest-dev#6421 (comment) Security concerns: the token might be misused, but only to upload bogus coverage to `codecov.io`, so the team believe this is harmless. If we decide to fallback from this decision , we just need to revoke the token. Related to pytest-dev#6369
run: "tox -e ${{ matrix.tox_env }}" | ||
|
||
- name: Prepare coverage token | ||
if: success() && !matrix.skip_coverage && ( github.repository == 'pytest-dev/pytest' || github.event_name == 'pull_request' ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hugovk small difference here: we still upload coverage on PRs. Of course this may happen on PRs on fork -> fork, but this should be rare and not a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, should be fine.
So, when github.event_name == 'pull_request'
, is it something like github.repository == 'nicoddemus/pytest'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't check, but I think so
I've tried to remove the Azure pipelines/add it back to see if I could fix the failures, but the Pipelines page no longer shows Anyway, I think we can disable azure entirely now because all Windows builds will be done on GitHub actions. Still keeping Travis for deploy, at least until #6369 is fully resolved. |
It would be nice to merge this soon, as Azure is broken. |
I do not get why we need |
Makes sense already now if it cannot be fixed. |
codecov.yml
Outdated
@@ -1,3 +1,5 @@ | |||
# note: `.github/codecov-upstream.yml` is basically a copy of this file, please propagate | |||
# changes as needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If (the concept of) .github/codecov-upstream.yml
needs to be kept it could also just append necessary lines to this file, making this comment unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
append necessary lines to this file
What do you mean? Is there a way to merge the two files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cat >> codecov.yml <<EOF
codecov:
# token from: https://codecov.io/gh/pytest-dev/pytest/settings
# use same URL to regenerate it if needed
token: "1eca3b1f-31a2-4fb8-a8c3-138b441b50a7"
EOF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @hugovk in case you want to adopt it also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done. 👍
Used a python script so I can put docs, do assertions, etc.
From here: #6421 (comment)
Not sure how common it is to use codecov on forks though. |
Ok, let's only add the token manually then for now. |
But won't the below be a problem?
|
@nicoddemus |
Appending should be fine too (with the same pre-conditions), it avoids needing to duplicate and keep the rest of the file in sync. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking forward to having coverage for Windows again.. 👍
Please squash.
Can be even rewritten in Python.. :) |
@nicoddemus |
Not yet it seems. I will go ahead and merge this one. |
Guess I should request changes for this in the future. |
🎉 GitHub Actions is now showing up under the builds for new commits on Codecov! Compare to an older commit from last week: |
Sorry didn't see that; my initial take was to keep the commit, but in retrospect I agree it would have been better to squash it. |
@@ -1,8 +1,7 @@ | |||
# evaluating GitHub actions for CI, disconsider failures when evaluating PRs | |||
# evaluating GitHub actions for CI, disregard failures when evaluating PRs | |||
# | |||
# this is still missing: | |||
# - deploy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the links!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to ping me for help/review. I'm kinda developing my own framework for GH Apps&Actions + I authored that guide & action...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do! I don't expect many problems, I've already setup deployment for a number of projects (including pytest-mock
), but you never know!
This overwrites the
codecov.yml
file in the root of the repository withcodecov-upstream.yml
file (which contains the code-cov token), so PRsand branches on the repository can upload coverage.
Suggestion from here:
#6421 (comment)
Security concerns: the token might be misused, but only to upload bogus coverage
to
codecov.io
, so the team believe this is harmless. If we decide to fallbackfrom this decision , we just need to revoke the token.
Related to #6369
(Following up from #6421, but now on my fork)