-
Notifications
You must be signed in to change notification settings - Fork 579
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
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!
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.
src/setup-python.ts
The file sets up the Python environment with caching capabilities.
No code appears suspicious or malicious; it primarily uses core modules and standard libraries.
package.json
The file defines dependencies, scripts, and metadata for the project.
Dependencies and scripts appear standard and necessary for the project.
src/utils.ts
This file includes utility functions for handling system-specific tasks and managing versions.
No code appears suspicious or malicious; it includes standard utility functions.
src/cache.ts
Failed to retrieve the file 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.
Changes Made:
Added a basedir parameter to set the current working directory for the poetry command.
Potential Issues:
No apparent malicious code. The changes ensure the command runs in the correct directory context.
Summary:
The changes introduced in the functions are aimed at improving the handling of multiple Poetry projects by dynamically identifying and processing their configurations.
No suspicious or malicious code patterns were identified.
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.
chwers
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.
README.md
Changes Made:
Updated documentation to explain that for poetry, the action will cache virtualenv directories for each poetry project found.
Potential Issues: No issues identified; the change clarifies the caching behavior for poetry.
tests/cache-restore.test.ts
Changes Made:
Added imports for path and State.
Corrected a typo from saveSatetSpy to saveStateSpy.
Updated test cases to include new paths and hash values.
Enhanced test cases to verify that saveState is called with the correct cache paths.
Potential Issues: No issues identified; the changes improve test coverage and fix typos.
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.
More tuning. hf =)
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.
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.
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.
Simplified the condition check by removing the explicit comparison to true.
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: