Closed rdmolony closed 1 month ago
I'm not sure if the start-postgres
workaround is a good idea.
I'm having a bit of trouble trying to figure out how to run start-mysql
or start-postgres
outside of devenv up
. Ideally, I'd like to run individual process like I might using docker-compose run postgres
, so that I can just spin up the database in CI & run tests against it
If interested see example GitHub Action runs here https://github.com/rdmolony/devenv-django/pull/1 against branch https://github.com/rdmolony/devenv-django/tree/reproduce-github-actions-passing-on-failing-test
I refactored to use devenv up
as per https://github.com/rdmolony/devenv-django/pull/2 as this generalises to services other than postgres
required to spin up prior to running tests
Adapted https://github.com/cachix/devenv/blob/dfd9c4857c4e4b910b4270c6a35af9f9ba824917/examples/python-poetry/devenv.nix so using languages.python.poetry.enable
to initialise poetry
I feel like we need to expose wait_for_db from devenv itself for this example to get really small.
I'd love to merge this, but I'd like to make it minimal.
Can we get rid of some of the stuff that's not really required (like gitignore, CI, etc).
Let me know if you need anything further here or upstream re wait_for_db
!
We now have wait_for_port
: https://devenv.sh/tests/
I simplified the example, it's much simpler via wait_for_port
, however, it now throws ...
Having upgraded to
devenv 1.0.2 (x86_64-linux)
rowan@Windows:/mnt/c/Users/New User/Code/third-party/devenv/examples/python-django$ devenv test
• Overriding .devenv to .devenv.dPJ3fscqlnMO
• Building tests ...
error:
… while evaluating the attribute 'config'
at «github:cachix/devenv-nixpkgs/06fb0f1c643aee3ae6838dda3b37ef0abc3c763b»/lib/modules.nix:322:9:
321| options = checked options;
322| config = checked (removeAttrs config [ "_module" ]);
| ^
323| _module = checked (config._module);
… while calling the 'seq' builtin
at «github:cachix/devenv-nixpkgs/06fb0f1c643aee3ae6838dda3b37ef0abc3c763b»/lib/modules.nix:322:18:
321| options = checked options;
322| config = checked (removeAttrs config [ "_module" ]);
| ^
323| _module = checked (config._module);
… while calling the 'throw' builtin
at «github:cachix/devenv-nixpkgs/06fb0f1c643aee3ae6838dda3b37ef0abc3c763b»/lib/modules.nix:298:18:
297| ''
298| else throw baseMsg
| ^
299| else null;
error:
error: The option `devenv.dotfile' does not exist. Definition values:
- In `<unknown-file>': "/mnt/c/Users/New User/Code/third-party/devenv/examples/python-django/.devenv.dPJ3fscqlnMO"
✖ Command produced the following output:
✔ Building tests in 15.2s.
Error: × Command `/nix/store/l24rmcpdnachwhz4rjwb9d89m3gxfy5n-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty
│ false --option eval-cache false --keep-going --max-jobs 2 build .#devenv.test --no-link --print-out-paths` failed with with exit code 1
I previously used .env
to store SECRET_KEY
for Django
, however, I have since moved this to an environment variable in devenv.nix
& still I see this thrown. I don't understand it.
You need to delete your devenv.lock
in that folder
Thanks @domenkozar, the tests pass now, however, the behaviour doesn't match what I expect. I changed examples/python-django/myapp/test.py
to a failing test & devenv test
still shows Tests passed :)
-
(I switched self.assertEquals(1,1)
to self.assertEquals(1,2)
)
Can you fix conflicts?
I rebased on main
(dangerous tool!) & then realised that it was my bad that devenv.lock
was out of sync. All good now
Thank you!
Hey there,
I created an example of using
devenv
alongsideDjango
viapoetry
including running unit tests by starting the database in the background.Let me know if you find this useful & if so, if you have any feedback
There's also a corresponding repo - https://github.com/rdmolony/devenv-django