Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tox v4 and add action to generate lockfile #168

Open
coretl opened this issue Jun 14, 2024 · 3 comments
Open

Support tox v4 and add action to generate lockfile #168

coretl opened this issue Jun 14, 2024 · 3 comments

Comments

@coretl
Copy link
Contributor

coretl commented Jun 14, 2024

At the moment we use tox to:

  • Run specific tox envs in CI and locally, like tox -e docs to invoke sphinx with the right args including for autobuild
  • Run tox -p to do the tasks that CI will run, but in parallel in a single terminal under a single version of python
  • Do this without making a venv for each env with tox-direct

We considered using nox, but it doesn't have a parallel option at the moment as per wntrblm/nox#544

We would like to add the ability to do something like tox -e lock to generate dev-requirements.txt as specified in DiamondLightSource/blueapi#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
Copy link
Contributor

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
Copy link
Contributor Author

coretl commented Jun 14, 2024

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
Copy link
Contributor

possibly, will test soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants