问题
I am using Tox as a wrapper around all the python code quality tools like flake8, mypy and pytest. I also invoke Tox from Jenkins.
Currently, for every git push
we
- create a fresh Conda environment holding python=3.7 and tox
- invoke tox, which will recreate all virtual environments freshly
- remove .tox/ and the Conda environment
Due to this, running tox takes 2 seconds locally but 90 seconds in Jenkins.
I now wonder whether we are to cautious. Would it be ok to leave the .tox/ cache folder alone in Jenkin? It might be important that we have just deps = -rrequirements-dev.txt
in [testenv]
.
Are there other means to speed up testing with tox?
回答1:
Reading the tox documentation on "Dependency changes and tracking", it seems changes in a requirements.txt
file do not trigger the rebuild of the virtual environment. So it looks like you should indeed delete the .tox
directory or at least use the -r, --recreate
option of tox (which might be more efficient).
Maybe you could give tox plugins such as tox-auto-env, or tox-pip-extensions a try.
Don't know about the necessity of rebuilding the conda environment though.
回答2:
There is a plugin for Tox named detox
which enables parallel processing of tox
pipelines. Recent versions of tox
(I have Python 3.7.3 and tox 3.14.0) directly supply this feature.
Using tox --parallel auto
in the Jenkins file drops the time needed from 90 seconds to 20. For my needs this is good enough and I can avoid any worries about caching issues now.
来源:https://stackoverflow.com/questions/58604782/how-reliable-is-tox-caching