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

Use tox plugin to consolidate tox environments #1354

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wshanks
Copy link
Contributor

@wshanks wshanks commented Jan 8, 2024

This change adds a tox plugin in toxfile.py which allows for sets of commands to be mapped to names in the test environment configuration. Additionally, a command line option is added to tox which allows one of these command sets to be selected by name and run in place of the default commands entry. With this alternative commands feature, several of the test environments that were in tox.ini were consolidated into three remaining environments with different sets of commands. The remaining environments are:

  • The main Python test environment used for tests, linting, etc.
  • The docs environment, needed because of a Sphinx bug that prevents a development install of qiskit-experiments from working on macOS.
  • The test environment that uses the Qiskit main branch instead of the released package.

This change adds a tox plugin in `toxfile.py` which allows for sets of
commands to be mapped to names in the test environment configuration.
Additionally, a command line option is added to `tox` which allows one
of these command sets to be selected by name and run in place of the
default `commands` entry. With this alternative commands feature,
several of the test environments that were in `tox.ini` were
consolidated into three remaining environments with different sets of
commands. The remaining environments are:

* The main Python test environment used for tests, linting, etc.
* The docs environment, needed because of a Sphinx bug that prevents a
  development install of `qiskit-experiments` from working on macOS.
* The test environment that uses the Qiskit `main` branch instead of the
  released package.
@wshanks
Copy link
Contributor Author

wshanks commented Jan 8, 2024

This is a draft for now to see what other developers think. It allows combining most of our tox environments into a small set. Alternatively, we could still consider switching to nox (#1122) or hatch (which I saw in its latest release notes now supports working with projects that don't use hatchling for the build backend so it could work with qiskit-experiments' setuptools backend). I feel like the approach here does a decent job keeping the number of environments small and the syntax is not that different from hatch (I am not as familiar with nox). We could change the syntax as well. I don't feel too strongly about it.

@wshanks
Copy link
Contributor Author

wshanks commented Jan 8, 2024

This is also marked as a draft because the contributing guide needs to be updated. I didn't want to do that before we decided if we wanted to make this change.

@wshanks
Copy link
Contributor Author

wshanks commented Jan 8, 2024

The envlist entry also needs to be updated since there is no lint environment now. I wonder if it should just be removed (require -e to be used) or should be set to py. I don't think it is common to use the default value and run the tests on all versions of Python?

That is one downside of the change with this plugin -- you can't really run multiple things at once. I don't think that is common for qiskit-experiments. The tests already max out parallelization so there is not much benefit to running multiple things at once and it's not that bad to call tox multiple times. We could change the plugin so specifying mulitple --alts would combine all the commands into one big set.

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

Successfully merging this pull request may close these issues.

None yet

1 participant