-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
gh-94759: Collect C-level coverage using llvm-cov #94760
base: main
Are you sure you want to change the base?
Conversation
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 will be great to have! Publishing to github pages is interesting and is as good a place to start as any.
It is unfortunate that GitHub doesn't support rendering coverage metadata on top of their existing source tree view and within PR code views.
run: | | ||
llvm-profdata-12 merge -sparse python*.profraw -o python.profdata | ||
llvm-cov-12 show -format=html -output-dir=cpython-coverage -instr-profile=python.profdata -show-branches=count -show-regions python . | ||
- name: Publish coverage-report |
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.
Does every run clobber the previous run's report? What about CI runs on PRs and CI runs from release branches? Can this be configured to commit the coverage results into a branch in the repo matching the reponame+branchname? Or do branches not render in gh-pages? in which case it'd need to be subdirectories in the repo.
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.
Currently, this clobbers the previous run. That is easily changed with a flag, but then we could run into Github repository size limits (each result is around 100MB of HTML). It's probably possible to keep the last N commits, but the tool I'm using to publish doesn't support that directly.
This is currently configured to just run on the main
branch once a day. We could do multiple branches that publish to subdirectories if you think there's a good use case for that. (Github pages only publishes a single branch, but subdirectories would work).
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 we would get some funding to run a persistent VM with public hostname from ... let's say Azure, then it would be trivial to create a buildbot worker and serve the LCOV results from HTTP server. They are static HTTP and JS files on the file system after all. Just saying :)
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 don't mind main
branch only and once a day. Anyone working on coverage is presumably doing their own local coverage runs while creating PRs.
Regarding a buildbot configured to host the results, while I could simply set one up it'd probably make more sense for mdboom to do that and be an admin given who's driving this work. :)
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.
Yeah, I'd be happy to admin that if it comes to it. I think it's fine to go with the Github Action here as an MVP, and if the amount of history or frequency of runs isn't good enough, we can revisit migrating to our own VM down the road.
What is the benefit to run the suit daily? If the report is used as a guide for additions into the tests, a weekly run seems to be enough. |
If it's daily then it's up-to-date more than the weekly. More up-to-date is better than less up-to-date 😉. There's also the benefit that people will have a better idea of what to work on in terms of coverage than not as someone may put in a lot of work for something that's already been fixed earlier in the week. Not to say that a weekly coverage run isn't good as well, but daily is just better if we can make it happen. |
Is there any particular reasons why you are using clang and custom instructions for LCOV instead of |
Which one produces more useful output? (I really don't care which we use even though everything I do at work is clang/llvm based - I just want line and branch coverage data) |
@tiran the idea of using clang comes from faster-cpython/ideas#426 where I believe branch coverage was considered the big win. Maybe |
GCC and LCOV can do branch coverge, too. I'll have a branch ready by tomorrow. I would welcome to have LLVM coverage support in Makefile, too. |
It was an attempt to get branch coverage, not realizing lcov could do it. I still think llvm-cov displays branches within subexpressions in a more readable way, however. I don't know if using gcov for collection + llvm-cov for output would give us the best of both worlds. (Using gcc for the collection would be preferable, probably, since that's what we test with on Linux). |
It doesn't look like this is possible. There is an @brettcannon wrote:
@tiran wrote:
I think that's a good idea, but a fair chunk of fiddly work. The Makefile doesn't have any direct support for building with clang on Linux. It works if you set |
Can you have the |
I just refactored this so there is a new Makefile target
I hadn't thought of this -- it's probably doable. Given that you have to completely reconfigure to switch between each "mode" that probably makes sense. |
I've updated this to automatically choose lcov or llvm-cov depending on the compiler in use. |
eb15335
to
58e38af
Compare
6ba9b68
to
0001577
Compare
9863146
to
87df0f2
Compare
08812bc
to
c9b23a1
Compare
@erlend-aasland wrote:
I tried this and unfortunately it created a bunch of co-authored commits for everything that had happened in the meantime and then requested review from ~20 codeowners. I went back to rebasing/force pushing for a cleaner review of the actually relevant commits. Going to read the relevant parts of the devguide for next time... |
Co-authored-by: Christian Heimes <[email protected]>
c9b23a1
to
ceb32ee
Compare
Are there any additional comments on this? |
There's a process for this now. Adding LLVM support to |
This adds a Github Action to collect C-level coverage and publish it to a Github Pages repository.
You can see an example coverage output.
There are two admin things that would need to happen for this to work:
python
organization for the results, e.g.cpython-c-coverage