-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
refactor tests and dev env #422
Conversation
* fix deprecation warnings * define dependencies once * expose all supported nix versions in nixpkgs for test * use ruff for both check and format, dropping black
* factor out duplicated code * make tests an importable package * idiomatic pytest usage * do not touch files outside of the tmp test tree and do not depend on external state (except for /nix/store ☹) * run coverage to root out dead code
drop redundant configuration
* test envs have a local gc root under ./._test_gcroot * update github workflow to run tests on a matrix of supported nix versions and ubuntu/macos * use jrmurr/direnv-nix-action in github workflow
Hah. I was just thinking that I would like to get the tests working more transparently (and figure out why they aren't running on #420?). I'll look this over soon. |
Er, I've got two more branches, https://github.com/kingarrrt/nix-direnv/tree/cleanup and https://github.com/kingarrrt/nix-direnv/tree/cached. The first is a general cleanup, the second re-implements the cache keyed on the hash of watched files. Unfortunately each builds on the last, including this one, and I can't create pull requests without a bunch of duplicate commits. I thought Github would deal with the situation but no. I'm not quite sure what to do. This was an attempt an making things easier to review... Re the failures: I hadn't realized Garnix ran Re #420: I ended up doing something similar on the |
Frankly, I think these branches are too big and leading to PRs that are much too large for easy review. I'd be telling developers at work the same thing
I am happy to review MORE pull requests, but the code here is complex enough that I don't want to review one MASSIVE pull request doing all of this as the potential for missteps in reviewing one big PR is much higher than multiple small(er) ones. I might suggest, actually, closing this one and starting with smaller PRs. It isn't completely necessary, but it does simplify PR creation, management, and review. Re: conditional manual reload script creation: We decided to ALWAYS create the manual reload script. It's simpler to do and there's no real drawback to creating the script itself. You're welcome to open a PR to re-open discussion on this, but I don't see a reason for my opinion to change yet. |
@@ -0,0 +1,37 @@ | |||
from __future__ import annotations |
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.
Do we still need this? We don't need to support python 3.7 anymore for our internal test suite.
|
||
[tool.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.
Only our test code is using python, so I don't think we need code coverage for this.
nix | ||
] ++ (with python3.pkgs; [ | ||
pytestCheckHook | ||
pytest-cov |
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.
So we might not need this?
installPhase = '' | ||
install -m400 -D direnvrc $out/share/nix-direnv/direnvrc | ||
''; | ||
|
||
passthru.tests = { | ||
lint = runCommand "lint-${finalAttrs.name}" { |
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 got rid of lint now in favor of treefmt.
pytestCheckHook | ||
pytest-cov | ||
pytest-randomly | ||
pytest-sugar |
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.
Checked the number of dependencies and it seems reasonable.
There are certainly some good things in this PR but I also would like to take this in a smaller scoped pull requests. |
I wanted to make myself familiar with these new lints, so I applied them myself in #425 That hopefully also reduce the scope of this PR. |
Understood. I'll split this down and resubmit. |
This attempts to extend and clean up the test suite and dev environment. Not complete but a good start (I think) and I hope not controversial. I was surprised that you are not dogfooding with an
.envrc
, and have added that in.The tests are now self-contained, so unaffected by external state, and equally they won't mess with your
$HOME
. The bear in the corner remains - gc tests still use the real store, which is painful.One thing this flags up is your minimum nix requirement. Nix 2.4 was removed from Nixpkgs in July/22. The lowest version you can support in Nixpkgs is 2.10, but this has it's own problems, see the last commit. Maybe time to bump the requirement?