ymyzk / tox-gh-actions

Seamless integration of tox into GitHub Actions for tox 3 and 4
MIT License
246 stars 25 forks source link

`tox-gh-actions` selects too many environments #124

Closed pharmpy-dev-123 closed 1 year ago

pharmpy-dev-123 commented 2 years ago

I have configured tox so that I can run tox -e unit for unit tests and tox -e unit-cover for unit tests with coverage. It is impossible for me to use tox-gh-actions to run only tox -e unit if both unit and unit-cover are listed in envlist (because there are some GHA workflows in which I need coverage, and others in which I do not need it). If I try to filter by factors, tox-gh-actions selects both environments and runs them sequentially. Is there a solution other than not using tox-gh-actions?

ymyzk commented 2 years ago

Hello, thanks for asking a question. I guess your tox.ini is something like the following and running tox with tox-gh-actions runs both unit and unit-cover.

[tox]
envlist = unit, unit-cover, <maybe other envs?>

[gh-actions]
python =
    3.10: unit

[testenv]

I cannot come up with a clean solution but I can propose a few workarounds.

Option 1: If your tox.ini is simple and doesn't have many other envs, you can specify the list of environments you want to execute explicitly like tox -e unit. This will disable tox-gh-actions' environment overrides but you can still enjoy other features of tox-gh-actions such as log line grouping. https://github.com/ymyzk/tox-gh-actions/tree/v2.10.0#overriding-environments-to-run

Option 2: Renaming the name of the tox environment can be another option. For example, you can rename unit to something like unit-only so that tox-gh-actions won't be confused.