How reliable is Tox' caching?

风流意气都作罢 提交于 2020-05-14 09:14:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!