Configure tox by EliahKagan · Pull Request #1667 · gitpython-developers/GitPython (original) (raw)

This adds a tox.ini file so that tox can be run locally to test on 3.7, 3.8, 3.9, 3.10, 3.11, and 3.12, or whichever of them are available, and also run the lint, formatting, and style checks.

Because CI also tests building the documentation, and it is convenient to be able to use tox to check all the things CI checks (albeit on just one's local platform), I have added a tox environment for that too. But because it actually writes to the build directory, I have not listed it in env_list at the top, so it doesn't run automatically--it can still be run with tox -e html. That could be improved in the future, but I think reasonable ways of doing so would involve modifying doc/Makefile to make it more configurable, and that seems outside the proper scope of this PR.

This PR does not use tox on CI. It is possible to use tox to drive tests on CI, such as with the tox-gh-actions plugin, but this does not do that, because:

So while I suspect it may eventually be a good idea to use tox on CI, I don't think it should be done until it is clearly no worse than the current approach and other readily available approaches.

My intention is also not for tox to replace other ways of running tests when developing locally. During routine development, tox may be too slow or its output too complicated, for regularly checking the status of some or all tests. Furthermore, pre-commit seems to be working great for the lint checks--and the lint tox environment I configured uses it, to as to pick up any new or changed linting tools automatically. (Also, not everyone likes tox.)

For these reasons, I have not modified the readme to replace anything with tox-based instructions. However, the readme could be modified to also talk about tox. I am not sure if that should be done either, because the users most interested in using tox are those already familiar with it, and they will notice the tox.ini. Furthermore, I think it may be best to see how it works out (for example, should it really have the environment for testing that we can build docs by actually building them?) before adding it to the readme or other project documentation. However, if you'd like tox instructions, or a mention of it, etc., added the readme, I'd be pleased to add it (as well as to make other requested changes).

Some other considerations: