-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[10159] Fix codecov.io reporting. Move codecov.io / coveralls reporting outside of tox environments. #1574
Conversation
|
The builds are now reported for both GHA and Azure https://codecov.io/gh/twisted/twisted/commit/4794ef2b15244904655b4c9dd20eae352fe88ae4/build |
| @@ -1 +0,0 @@ | |||
| repo_token: "JFDTIRUVOQ8jCM3zcajrZALlpKXyiXGAX" | |||
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.
This should be private.
For now, I have moved it inside each CI config. In this way we don't need to install pyyaml just to read this line.
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 it were 'private' it wouldn't be available to PRs from forks so we wouldn't get coverage on them. (for some definition of private)
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 it doesn't speed anything up then I'm not clear how it is better to repeat the (little bit of) code in two CI configurations than to just have it in tox.ini. Though sure, it doesn't presently seem to be actually the same between the two since GHA uses the Python uploader and AP uses the bash uploader. :[
There are some minor changes requested, but at this point mostly I'm interested in some discussion.
.github/workflows/test.yaml
Outdated
|
|
||
| - name: Publish coveralls | ||
| # We want to publish coverage even on failure. | ||
| if: contains(matrix['tox-env'], 'withcov') || failure() |
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.
Won't this publish on failure even if withcov isn't in the tox env? I do see this already existed a few lines up.
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.
true. Thanks!
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.
My point was that this should only publish if withcov was specified. I don't know how to do this in a simple way, and I haven't thought through the not-simple way. So, just always doing it and ignoring any potential errors when there's no coverage data (which apparently there either aren't or they have already been dealt with, what with the passing CI (or we don't exercise this case)) may be the best that's worth doing anyways. And that's what we have now.
I guess the tl;dr is that I think if: always() is 'wrong' but maybe GHA isn't friendly enough for it to be worth making it right.
.github/workflows/test.yaml
Outdated
| run: tox -e coverage-prepare,codecov-push,coveralls-push | ||
| run: | | ||
| python -m coverage xml -o coverage.xml -i | ||
| python -m codecov -n 'lnx-${{ matrix.python-version }}-${{ matrix.tox-env }}${{ matrix.noipv6 }}' -X search -X gcov -f coverage.xml |
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.
My understanding is that Codecov prefers use of the bash uploader.
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 headup and the review.
I though that I have moved to bash, and this is why I haven't left another comment. My bad.
I will update this to use the bash uploader
from https://github.com/codecov/example-python
Q: What's the difference between the codecov-bash and codecov-python uploader?
A: As far as python is concerned, nothing. You may choose to use either uploader. Codecov recommends using the bash uploader when possible as it supports more unique repository setups.
azure-pipelines/run_test_steps.yml
Outdated
| # A minimum dept of 2 is required, as for PR head is the auto-merge commit | ||
| # and we need the last commit from PR to report the coverage. |
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.
This is very possibly a topic for a separate PR, but what about just skipping the automatic merge commit and checking out the actual branch instead? It's not like the automatic merge commit actually keeps the CI report up to date with the target branch. Relatedly, having dropped the requirement that branches are up to date seems a bit hazardous.
| # A minimum dept of 2 is required, as for PR head is the auto-merge commit | |
| # and we need the last commit from PR to report the coverage. | |
| # A minimum depth of 2 is required, as the default is the auto-merge commit | |
| # and we need the last commit from the PR to report the coverage. |
What code actually looks back up to the parent to use this? Maybe this relates to the long-standing complaints about sometimes getting wrong delta coverage reports?
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 typo fixes.
Note that this is an issue with Azure Pipelines and not GitHub actions ... so we need different docs and I don't think there is this option
The codecov bash script in Azure needs this.
Running the test on branch HEAD vs merge-commit should be debated outside of this PR.
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.
Sorry, too much GHA on my mind. Thanks for the correction. I would expect that AP has some variable that could be used to specify the branch instead of the merge commit. But agreed, no need for a debate here.
azure-pipelines/run_test_steps.yml
Outdated
| - bash: | | ||
| python -m coverage xml -o coverage.xml -i | ||
| bash <(curl -s https://codecov.io/bash) -X search -X gcov -f coverage.xml -v -n "${{ parameters.platform }}-${{ parameters.pythonVersion }}-alldeps-withcov" | ||
| displayName: 'Generate XMl and report codecov.io' |
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.
Capitalization and may as well match above I guess...
| displayName: 'Generate XMl and report codecov.io' | |
| displayName: 'Generate XML and publish to Codecov' |
|
Thanks @altendky for the review
On Azure we need special handling for coveralls... and for azure we also need 2 separate tox env -- to fake CircleCI only for Covealls and not for Codecov. I tried to move the code to tox.ini but I found the result e bigger mess. The CI configuration already complicated enough with job matrix on GHA and templates in Azure, and the env VARS that need to be created inside the CI YAML config and then passed to TOX. You can give it a try if you want. and bash version from tox |
|
Codecov project fails due to
|
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 detailed response. Everything looks to be addressed except maybe one bit. The use of the the Python vs. bash codecov uploader on GHA. If you did consider that and decline to change, alrighty. :] No need to hold up on that.
I'll trust your call on the coverage issues.
|
Thanks @altendky for the review. It looks like the merge commit is still pushed... but after some time, codecov.io removes it and merges it with the main PR commit. So I am not sure if depth=2 is required. But it looks like it takes a lot of time for codecov.io to send to final report... and I think that this is due to pypy reports that are sent that late. It's funny, as now the GitHub Actions reports are not visible. so... still WIP. I will ping you over IRC when things are ready for another check Thanks! |
| @@ -48,13 +47,14 @@ jobs: | |||
| # end to end functional test usage for non-distributed trial runs. | |||
| - python-version: 3.6.7 | |||
| tox-env: nodeps-withcov-posix | |||
| trial-args: '' | |||
| trial-args: '-j 4' | |||
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.
this is a drive-by fix, as parallel coverage should be enabled here.
It was accidentally disabled thinking that if left empty it will use the default.
| # `noipv6` is created to make sure all is OK on an OS which doesn't | ||
| # have IPv6 available. | ||
| # Any supported Python version is OK for this job. | ||
| - python-version: 3.6 | ||
| tox-env: alldeps-withcov-posix | ||
| noipv6: -noipv6 | ||
| trial-args: '-j 4' |
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.
this is a drive-by fix, as parallel coverage should be enabled here.
It was accidentally disabled thinking that if missing it will use the default.
|
I think that this should be merged as it is as it already has enough improvements. Coveralls fixes
Codecov
General changes
|
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.
I'll say that I'm feeling pretty itchy about all this. But, given the discussion, I feel like that's just the way it is going to be regardless because of the multiple CI systems * the multiple coverage presenters * the myriad oddities. Oh well, it's mutable, let's go for it.
|
Thanks for the review... This is not over yet :) Part 2 at #1543 |


Scope and purpose
Reporting coverage to codecov.io and coveralls should only be needed for CI.
For CI we already have python virtual env created.
That venv can be reused for codecov/coveralls operations so that we don't need to add tox extra complexity for those calls.
It should also make the tox.ini cleaner and move the coverage publish code closer to where it's used.
Coverage reporting also broken with codecov reports for windows linux and mac not merged.
Coveralls reports are not normalized.
Changes
There is a problem with codecov.io reporting as the coverage is reported for the PR auto-merge commit.
I saw this error for GitHub Coverage and Azure Coverage.
The error is
fetch-depth: 2was enabled for codecov bash uploaded.Generating XML+ codecov.io publish was taking 40 seconds with the most time taken by XML generation.
Only coveralls publish was also taking 40 seconds.
If coveralls is not used by Twisted devs we can stop publishing it and save 40 seconds with each build.
With coverage publishing handling moved outside of tox.ini there is no speed improvement.
I still prefer the coverage publishing outside of tox as I find it easier to understand how things works.
The coverage config was updated to normalize the path and ignore the trial temp file.
The CI steps were updated to show the status of the local coverage... to help debugging.
Any errors generated during coverage reporting are ignored.
The idea is to reduce random failures.
Once we have the other CI jobs with a solid green we can look at requiring strict rules.
Contributor Checklist:
tox -e lintto format my patch to meet the Twisted Coding Standard#character).reviewto the keywords field in Trac, and putting a link to this PR in the comment; it shows up in https://twisted.reviews/ now.The first line is automatically generated by GitHub based on PR ID and branch name.
The other lines generated by GitHub should be replaced.