DiamondLightSource / python-copier-template

Diamond's opinionated copier template for pure Python projects managed by pip
Apache License 2.0
5 stars 2 forks source link

Support tox v4 and add action to generate lockfile #168

Open coretl opened 4 months ago

coretl commented 4 months ago

At the moment we use tox to:

We considered using nox, but it doesn't have a parallel option at the moment as per https://github.com/wntrblm/nox/issues/544

We would like to add the ability to do something like tox -e lock to generate dev-requirements.txt as specified in https://github.com/DiamondLightSource/blueapi/pull/499

To do this we should should update to tox 4 and work out what changes are needed to support the current workflow, and also work out how to add a lock command that will not be run by the equivalent of tox -p

stan-dot commented 4 months ago

for the extra job something like this could work:

# tox must currently be configured via an embedded ini string
# See: https://github.com/tox-dev/tox/issues/999
[tool.tox]
legacy_tox_ini = """
[tox]
skipsdist=True
envlist = pre-commit,type-checking,tests,docs

[testenv:{pre-commit,type-checking,tests,docs}]
# Don't create a virtualenv for the command, requires tox-direct plugin
direct = True
passenv = *
allowlist_externals =
    pytest
    pre-commit
    mypy
    sphinx-build
    sphinx-autobuild
commands =
    pre-commit: pre-commit run --all-files {posargs}
    type-checking: mypy src tests {posargs}
    tests: pytest --cov=blueapi --cov-report term --cov-report xml:cov.xml {posargs}
    docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html

[testenv:custom-job]
direct = True
passenv = *
commands =
    # Replace this line with whatever command this job should run
    echo Running custom job tasks {posargs}
"""
coretl commented 4 months ago

interesting, so does that mean that if you don't add it to the envlist then it won't run when you do tox -p?

stan-dot commented 4 months ago

possibly, will test soon