-
Notifications
You must be signed in to change notification settings - Fork 551
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
Use correct Poetry config when collecting Poetry projects #447
Conversation
I still need to test this locally, hence this is a draft. |
0a5c926
to
0e3a2ac
Compare
d3dceab
to
5c369bd
Compare
@IvanZosimov Sorry for the long delay! This is finally ready for review. All tests are passing successfully, and I'm using my own branch as an action in another project. |
5c369bd
to
37385ae
Compare
I fixed the failing main workflow on Windows. Good catch. That being said, I don't understand why e2e-cache fails with Pipenv and Windows. I haven't changed anything related to it. Can it be failing randomly? |
Hi, @oranav 👋 Thank you for this PR and sorry for the delay! The problem with e2e test related to pipenv on Windows is most probably caused by recent pipenv minor tag update, I hope that they will repair it. You also have 3 failing unit-tests in Main workflow, could take a look at them? |
Thanks @IvanZosimov! It seems that I've hit an unrelated bug that happens sporadically, which causes tests to timeout in some cases. Take a look at this action for example, which has failed for the same reason. I've fixed it in this commit. In short, the cache distributor tests were looking for dependency file with their default glob ( After we run the workflows again I expect the main workflow to pass. |
Hey @IvanZosimov, can you please take a look? |
9578b65
to
7a83d62
Compare
@dsame @IvanZosimov Can we please re-run the actions? |
7a83d62
to
3d21900
Compare
Sorry again. The problem was indeed unrelated to my PR, and it seems that #535 fixed the problem (for the curious - there is no Python 2.7 for Ubuntu 22.04, and the workflow previously used I ran the workflow in my repo just in case, and it passed successfully: |
@dsame @IvanZosimov Can we please re-run the workflow? |
@oranav can you please explain the purpose of running |
@dsame It's actually the same code as before, only in a loop (that iterates over all nested projects). |
Hello @oranav! I think documentation needs to be updated as well. At the moment it says that only |
3d21900
to
919d8be
Compare
@oranav no, you'll have to test it manually. |
@oranav heads up that the compat case doesn't seem to work. In my testing, this update triggered Poetry to not be able to find the correct python version and give up (even though |
@brcrista @dsame @agucova I've tested the compat case thoroughly. Here's a summary of the results:
As you can see, the only interesting case is number 3, in which if the previous version of the workflow was run, then a corrupt cache was already saved, and the post-PR version will happily load this cache and will fail with a wrong Python version (because the virtualenv was built incorrectly). I see two options:
I'm leaning towards option 1, since option 2 solves a very esoteric case. Thoughts? |
@oranav I was on the “fail silently” option and I think it makes sense to try to repair it a posteriori, especially because that happened when the correct setup was being used. It's difficult to estimate, but I wouldn't be surprised if it was the case that there were lots of people using the action without the cache working. But yeah, changing the key doesn't seem ideal. Is it possible to just detect the edge case and warn users accordingly? |
@oranav thank you for testing that! The two things we want to avoid are, in priority order:
It looks like the interesting case there is
I see in the logs for the Pre-PR workflow:
so before the run is passing but caching is broken, and after the run is failing. Caching should be transparent: if the cache is corrupt, we should ignore the cache, invalidate it, and create a new one. How much work would it be to handle that case? Since this should only happen on upgrade, we can handle it with a new major version release of the action. But that would slow down adoption of this feature, so it's better to handle it if we can. |
When collecting Poetry projects for caching, a '**/poetry.lock' glob is used. However, in order to process the Poetry configuration, the "poetry" command is run from the repo's root directory; this causes Poetry to return an invalid configuration when there is a Poetry project inside an inner directory. Instead of running a single Poetry command, glob for the same pattern, and run a Poetry command for every discovered project.
When the default dependency path is used for cache distributors, they are looking for the dependency file in the project's root (including the source code), which leads to tests taking a significant amount of time, especially on Windows runners. We thus hit sporadic test failures. Change the test cases such that dependency files are always searched for inside of `__tests__/data`, ignoring the rest of the project.
a957cf8
to
58362bf
Compare
The virtualenv cache might contain invalid entries, such as virtualenvs built in previous, buggy versions of this action. The `poetry env use` command will recreate virtualenvs in case they are invalid, but it has to be run only *after* the cache is loaded. Refactor `CacheDistributor` a bit such that the validation (and possible recreation) of virtualenvs happens only after the cache is loaded.
58362bf
to
881ca6e
Compare
92163f3
to
4b197ad
Compare
4b197ad
to
b69ad35
Compare
Woah, I finally triaged the issue. The old action never ran Either way, we'll want to cache to be rewritten after this PR. I suggest that we'll just bump the Poetry cache distributor primary key, so users will receive a cache miss upon the first run of the new action, and from there everything will work as expected. I've pushed my changes. Can we please re-run the workflows? |
Just to be clear: I've re-run the failing case (before the change, after the change, then once again) and it looks okay now. |
Anything still missing from my side or can we proceed to merging this? 😊 |
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.
Looks good @oranav ! I think that's a good fix for the compat issue. Thanks for the contribution!
Description:
When collecting Poetry projects for caching, a
**/poetry.lock
glob is used. However, in order to process the Poetry configuration, the "poetry" command is run from the repo's root directory; this causes Poetry to return an invalid configuration when there is a Poetry project inside an inner directory.Instead of running a single Poetry command, glob for the same pattern, and configure Poetry for every discovered project.
Related issue:
#446
Check list: