-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Add a "shared cache" directory #476
Conversation
Add an "{envdir}/.shared" directory, and create an API for accesing to it.
Don't raise an exception.
Move the "shared cache" API inside of nox.sessions.Session
Ok. At this point, I have |
Any suggestions? |
Looks like a great start. Some suggestions:
|
Convert the "shared cache" path into a property. Now, it returns a "pathlib.Path".
@theacodes I made your suggestions. Now, I don't know if I have to do something to enable the access to |
Why are the |
Any suggestions here? |
@DiddiLeija You are failing test coverage for the newly added code:
Just need to add tests and cover the new source lines added |
Make a test for the recent changes.
(It's currently a busy time for me as I'm putting together 500 synth modules to ship out, so I'll get to this soon) |
No problem, I understand how does it feels 😄. Review it whenever you want. |
Hi @DiddiLeija thanks for the contribution. You're pretty close! I've checked out your PR locally and have played around with it.
def test_create_tmp_twice(self):
session, runner = self.make_session_and_runner()
with tempfile.TemporaryDirectory() as root:
runner.global_config.envdir = root # Here we explicitly set the envdir
runner.venv.bin = bin
session.create_tmp()
tmpdir = session.create_tmp()
assert session.env["TMPDIR"] == tmpdir
assert tmpdir.startswith(root) You should add the following line at the start of def test_properties(self):
session, runner = self.make_session_and_runner()
runner.global_config.envdir = ".test" # Set the envdir explicitly, the name doesn't matter
...
# code below I would also make one other change: Because # code above
...
assert session.cache_dir == os.path.join(runner.envdir, ".shared") Instead use: # code above
...
assert session.cache_dir == pathlib.Path(runner.envdir).joinpath(".shared") With these changes, the tests should be passing. |
Thanks @FollowTheProcess. I will follow your suggestions. |
Use the "pathlib.Path" methods to reduce the variable usage.
Make some modifications to the tests.
I hope this is going to work. |
Fix an import error.
I think this PR is ready (at least, there aren't great changes to do). |
Hmm... it seems like the tests are looking for |
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.
Hmm... it seems like the tests are looking for
.test/test/.shared
. But I think it should be.test/.shared
, right?
You're right, my bad for not spotting this, it actually took me a while to figure out myself.
The sessions envdir
is cleaned up and joined with the session name by default as all other sessions will want to access their individual envdirs
e.g. .nox/tests
or .nox/lint
. Because what we want here is access to the root .nox
directory in order to create .nox/.shared
we have to make a few changes to the cache_dir
property and it's tests to allow this (see my review comments).
Use the parent directory to create the cache dir.
Use a tempfile to test the session properties.
@FollowTheProcess Done. |
Cool, looks like you unindented the Remember you should always run tests and formatting etc locally first before pushing up 👍🏻 running |
Just want to get another maintainer to take a look at this and make sure they're happy before merging in. cc @theacodes @dhermes |
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.
LGTM
Should the directory be named It's a cheap change now, and it would remove a mental translation step ( |
Yep, makes total sense to me. Agree with your suggestions in the review too. @DiddiLeija do you want to implement these tweaks or are you happy for us to just fix this up real quick? |
This avoids some unnecessary path manipulations, and using the parent directory of a virtualenv which does not necessarily exist (`PassthroughEnv` does not create a virtualenv). Co-authored-by: Claudio Jolowicz <[email protected]>
Of course I can do this simple change ;) |
Use ".cache" instead of ".shared".
Use ".cache" instead of ".shared".
Ok. I made your suggestions. |
Cool! Thanks for the contribution @DiddiLeija 🎉 |
Thanks to you, @FollowTheProcess, @theacodes, @dhermes and @cjolowicz for all your help! |
Closes #72. Add an
{envdir}/.shared
directory (like @dhermes suggested), and create an API for accesing to it.I'm a bit new to the concept, so tell me if this is what you want :)
CC @theacodes @cjolowicz