fpgmaas/deptry

Random crash when building deptry wheel in functional tests on macOS

fpgmaas opened this issue · 1 comments

Describe the bug

Sometimes, one of the functional tests on MacOS fails in the CI/CD pipeline, see e.g. here. For the log output, see below.

Simply selecting 'Re-run failed jobs' usually solves the problem.

Building `deptry` wheel in build/functional_tests/deptry to use it on functional tests...
============================= test session starts ==============================
platform darwin -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0
rootdir: /Users/runner/work/deptry/deptry
configfile: pyproject.toml
plugins: cov-4.1.0, xdist-3.5.0
created: 4/4 workers
INTERNALERROR> def worker_internal_error(self, node, formatted_error):
INTERNALERROR>         """
INTERNALERROR>         pytest_internalerror() was called on the worker.
INTERNALERROR>     
INTERNALERROR>         pytest_internalerror() arguments are an excinfo and an excrepr, which can't
INTERNALERROR>         be serialized, so we go with a poor man's solution of raising an exception
INTERNALERROR>         here ourselves using the formatted message.
INTERNALERROR>         """
INTERNALERROR>         self._active_nodes.remove(node)
INTERNALERROR>         try:
INTERNALERROR> >           assert False, formatted_error
INTERNALERROR> E           AssertionError: Traceback (most recent call last):
INTERNALERROR> E               File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/_pytest/main.py", line 283, in wrap_session
INTERNALERROR> E                 config.hook.pytest_sessionstart(session=session)
INTERNALERROR> E               File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__
INTERNALERROR> E                 return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> E                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> E               File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec
INTERNALERROR> E                 return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> E                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> E               File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 138, in _multicall
INTERNALERROR> E                 raise exception.with_traceback(exception.__traceback__)
INTERNALERROR> E               File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR> E                 teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR> E                 ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> E               File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/_pytest/logging.py", line 785, in pytest_sessionstart
INTERNALERROR> E                 return (yield)
INTERNALERROR> E                         ^^^^^
INTERNALERROR> E               File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall
INTERNALERROR> E                 res = hook_impl.function(*args)
INTERNALERROR> E                       ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> E               File "/Users/runner/work/deptry/deptry/tests/functional/conftest.py", line 19, in pytest_sessionstart
INTERNALERROR> E                 subprocess.run(
INTERNALERROR> E               File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 571, in run
INTERNALERROR> E                 raise CalledProcessError(retcode, process.args,
INTERNALERROR> E             subprocess.CalledProcessError: Command '['pdm', 'build', '--no-sdist', '--dest', 'build/functional_tests/deptry']' returned non-zero exit status 1.
INTERNALERROR> E           assert False
INTERNALERROR> 
INTERNALERROR> .venv/lib/python3.12/site-packages/xdist/dsession.py:200: AssertionError
[gw3] node down: Not properly terminated

replacing crashed worker gw3
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/_pytest/main.py", line 285, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>                          ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/_pytest/main.py", line 339, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 138, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/_pytest/logging.py", line 806, in pytest_runtestloop
INTERNALERROR>     return (yield)  # Run all the tests.
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/xdist/dsession.py", line 123, in pytest_runtestloop
INTERNALERROR>     self.loop_once()
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/xdist/dsession.py", line 148, in loop_once
INTERNALERROR>     call(**kwargs)
INTERNALERROR>   File "/Users/runner/work/deptry/deptry/.venv/lib/python3.12/site-packages/xdist/dsession.py", line 238, in worker_errordown
INTERNALERROR>     self._active_nodes.remove(node)
INTERNALERROR> KeyError: <WorkerController gw3>

Although I'm not sure under which conditions this happens for now, the good news is that I'm able to reproduce locally on macOS from time to time, so this should be easier to debug that on the CI.