Open msto opened 3 months ago
The advantage of using GHA to do this is we get multiple concurrent jobs. I don't think that would be the case with tox.
@nh13 tox works well for this and will run multiple GHA jobs as expected:
Here's an example from a personal OSS project:
And the associated pyproject.toml
config:
[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = True
envlist = py312,py311,py310,py39,py38
[gh-actions]
python =
3.12: py312
3.11: py311
3.10: py310
3.9: py39
3.8: py38
[testenv]
allowlist_externals = poetry
commands =
poetry install -v
poetry run pytest toolkit/ tests/
"""
Tox has a feature request to update their config syntax to proper TOML (instead of ini-style) but at least it's all in the pyproject.toml
and not in another dotfile.
What I do locally is use pyenv, a very simple Python version management tool, to install all versions of Python on my local. I think of this as the environment layer between the system Python (which you should not touch) and deeper environments like venvs and conda environments. Of course, depending on your personal preferences, you can get multiple Python versions installed in other ways.
Once I have those Pythons, then I have the option of running poetry run pytest
to run the whole test suite with whatever Python version poetry finds as default, or if I have tox installed, simply running tox
and then I get parallel testing over all versions of Python. This emulates GHA quite well.
GHA does this, but it'd be more convenient if tests and checks could be run without pushing and the overhead of GHA