-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Test sdist contents instead of Git checkout in CI #2541
Test sdist contents instead of Git checkout in CI #2541
Conversation
We already test the sdist contents, see https://github.com/python-trio/trio/blob/master/ci.sh#L131-L148 which has the advantage of also working locally. I'll close preemptively but feel free to reopen. |
I had missed that you want to allow others to test using only the sdist, but including a random certificate in our sdist seems wrong even if that mean downstream won't be able to test LSP support. (Maybe others disagree, in which case I will be happy to reopen.) |
@pquentin well, the tests need to be usable if they are included in sdist. If you don't like the certificate, maybe we could exclude it and have some way to skip said tests, keeping the rest in a good shape. After all, the downstreams are usually Linux-based anyway. OTOH, if a “random certificate” is a prerequisite for tests, it's not really “random” but is a part of the testing setup. I'll reopen this for now to get more visibility. I firmly believe that sdists should ship everything necessary to run tests and be self-contained in general. Otherwise, an implicit dependency on Git may appear, and it won't be noticeable in many envs. |
In fact, this PR demonstrates that a part of the pre-requisites is indeed missing from the sdist. |
While I generally like the approach of testing the artifacts instead of the source, there's a basic hazard that I think this doesn't address. Or maybe I looked too quickly. What if some tests are just missing or get skipped etc? I would expect some verification that the artifact has all the proper tests compared to the source checkout. |
@altendky that's a good point. I usually use I've given some thought to what you said. My first instinct was to add a CI check that would retrieve the number of executed tests from the JUnit output that pytest produces and ensure that it's sufficiently big. Then, I remembered seeing a pytest plugin that allows specifying a minimum number of tests required to succeed for the test session to be successful. Never used this one personally, though. The more I thought about it, the more I realized that the solution is on the surface — the coverage metric would drop dramatically if the tests stop being executed. Specifically, the test directory should report 100% coverage. I recall earlier discussions in the community on whether to measure coverage on the tests themselves, and nedbat even has a blog post explaining that this is important. I've gone to https://app.codecov.io/gh/python-trio/trio/tree/master/trio/tests and, to my surprise, its coverage is at 96.03% — that's no good! Looking inside, I see that there's a few reasons that things are not covered:
Digging deeper, I see
This is from https://github.com/python-trio/trio/actions/runs/3958687617/jobs/6780554545#step:4:1660. There are some problems with how this is set up:
The solution would be simple — install Codecov GitHub App into the repo and make coverage required check. Configure coverage to demand 100% on the test directory, at least. Use the official up-to-date uploader (directly in the script, through the action in GHA). This will make sure that the tests are included and executed, IMO. In conjunction with explicitly adding them to |
Thanks for digging into this and for identifying some other points to work on. |
So WDYT about improving packaging along the way? |
I'm not particularly involved here at this point so I won't promise to provide reviews or such, but I am quite used to ending up multiple layers deep in fixing stuff to get PRs through. I would personally suggest doing it as separate PRs though and not putting it all in this one. tl;dr, sounds great! |
Yeah, I didn't mean to imply that it'd be included in this PR. I'm pretty much fanatic about making PRs and commits atomics. |
UPD: this has recently been fixed by making use of the official codecov action. |
81ec287
to
3d9e30f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2541 +/- ##
=======================================
Coverage 99.62% 99.62%
=======================================
Files 124 124
Lines 18381 18381
Branches 1226 1226
=======================================
Hits 18312 18312
Misses 47 47
Partials 22 22 |
I think maybe the formatting check can/should be excluded from this transition, and have that be tested against the Git content. I don't see any reason for downstream users to run formatting checks, and saves on having to bundle a couple files - including |
I am curious about the status of this change, it sounds like it would be useful from the points you mentioned. |
@jakkdl there's school of thought preaching that sdists should be as close to Git source as possible. And I also prefer this way — it's easier to maintain, for one. In my projects, @CoolCat467 it fell off my radar. I thought it was kinda ready but couldn't get enough people on board to get approvals. Maybe, I'll resurrect it some time... |
b57f6b8
to
e179702
Compare
Without arguing that checks are needed, I saw this pop up in my notifications and figured I would include the silly little thing I did elsewhere to compare source vs. installed tests. https://github.com/Chia-Network/chia-blockchain/blob/6dfcd511fe99c3da2795aadd1c898d019518041c/.github/workflows/test-single.yml#L208 Basically just leaning on pytest's |
@altendky oh, interesting. That may be a sanity check for the FWIW, I was just rebasing this as it was stale for a while. |
e179702
to
e00989f
Compare
bf144f6
to
eefbdc2
Compare
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.
As far as I can tell this makes sense, but to be honest not super familiar with how uploading sdists works in practice, but most everything looks like it should work
bc05128
to
ef04096
Compare
This patch helps make sure that sdist contents is enough to run tests downstream. It also includes a smoke test for whether all the tests present in Git have been included into the sdist. Suggested by Kyle Altendorf [[1]] [[2]]. [1]: python-trio#2541 (comment) [2]: https://github.com/Chia-Network/chia-blockchain/blob/6dfcd51/.github/workflows/test-single.yml#L208-L243
ef04096
to
fce0812
Compare
@altendky I've implemented your suggestion and scheduled merging. |
This patch helps make sure that sdist contents is enough to run tests downstream.