ngi-nix / ngipkgs

Nix packages and services for projects supported through the NGI program
https://ngi-nix.github.io/ngipkgs
MIT License
35 stars 18 forks source link

Libervia-backend #87

Open augustebaum opened 1 year ago

augustebaum commented 1 year ago

Source code: https://repos.goffi.org/libervia-backend/

Part of #4

alejandrosame commented 1 year ago

@goffi-contrib: while running test for libervia-backend we get the following error:

============================= test session starts ==============================
platform linux -- Python 3.10.12, pytest-7.4.0, pluggy-1.2.0
rootdir: /build/hg-archive
collecting ... 
collected 0 items / 1 error                                                    

==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
...
tests/e2e/conftest.py:29: in <module>
    from sh import li
E   ImportError: cannot import name 'li' from 'sh' (/nix/store/4mk9i1wbxxyixglf87smv0v14yz0389p-python3.10-sh-2.0.2/lib/python3.10/site-packages/sh.py)
=========================== short test summary info ============================
ERROR  - ImportError: cannot import name 'li' from 'sh' (/nix/store/4mk9i1wbxxyixglf...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.18s ===============================
/nix/store/3pfjacvdg9f491lfqc9qb2d0nknx73fb-stdenv-linux/setup: line 1596: pop_var_context: head of shell_variables not a function context

The sh we are pulling from is https://pypi.org/project/sh/ at version 2.0.2, which doesn't seem a compatible package/version.

Which sh library should we use to make this test work?

jfly commented 1 year ago

@alejandrosame, sh works via magic, if you do something like from sh import foo, it'll expect to find a foo binary somewhere on your PATH. The way to interpret this error is that the tests expect there to be a li binary somewhere on your PATH, and there isn't. It looks like that li binary is provided by libervia-backend itself, see its pyproject.toml here.

augustebaum commented 1 year ago

Woah, black magic indeed. Thanks!

goffi-contrib commented 1 year ago

Hello,

those tests using sh are the end-to-end tests, they need to be launched with the run_e2e.py. It is documented at https://libervia.org/__b/doc/backend/contributing/testing.html . They use docker images and mount the source inside the containers, there is normally nothing to install for them. However due to big architectural changes recently, they are currently broken, I'll fix them soon (I mostly need to update the docker images in /docker, this will also fix the local demo image).

Beside that, the tests in tests/unit are unit tests and can be run directly with pytest as long as you have a dev env installed.

I've moved recently to Hatch, and to run the dev env, you can use hatch -e dev shell. However, I realize the the pytest modules are currently missing in my pyproject.toml, I'll fix that soon too.

Sorry for the temporarily broken things, it's a huge project, and it's difficult to keep everything running immediately when I'm doing big structural changes.

augustebaum commented 1 year ago

Closed for now, see https://github.com/ngi-nix/ngipkgs/issues/4#issuecomment-1786916017

As of writing this the most recent work on this project can be found at the libervia-backend branch. Current diff with main: https://github.com/ngi-nix/ngipkgs/compare/7b928f2b92e55c4bcd4d218118c5f17d561f4364...30c69276c87349011f1209d711864528e62970f3.