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

Redundant matrix strategy in .github/workflows/tests.yml #116

Open
gustavgransbo opened this issue Jul 5, 2020 · 3 comments
Open

Redundant matrix strategy in .github/workflows/tests.yml #116

gustavgransbo opened this issue Jul 5, 2020 · 3 comments

Comments

@gustavgransbo
Copy link

Thanks for a great blog-series and repo!

I noticed that the matrix strategy python-version: ['3.7', '3.8'] in .github/workflows/tests.yml is redundant, since nox will take care of testing both versions anyway.

@cjolowicz
Copy link
Owner

Thank you for the feedback! Yes, I have observed this as well.

I would avoid relying on additional Python versions being available in the runner image. The ubuntu-latest image is a moving target, and may not have the same Python versions installed in the future. Even if you were to pin the image to a specific release, it is better to be explicit about the Python versions your jobs should run on, and use only the version specified with the setup-python action.

Since Nox 2020.5.24, there is a --python option which lets you restrict runs to a specific Python version. So in theory, you could do this:

- run: nox --python=${{ matrix.python-version }}

Unfortunately, this will run all sessions that have the specified Python version, even when they are not listed in nox.options.sessions. So it makes sense to include the Nox session in the matrix as well. You can see an example of this in the Tests workflow of the Hypermodern Python Cookiecutter.

@gustavgransbo
Copy link
Author

Thank you for the elaborate answer!

Including the session in the matrix is a great idea, which I will most likely opt for in my personal project. Thanks!

@Winand
Copy link

Winand commented Feb 5, 2023

Unfortunately, this will run all sessions that have the specified Python version, even when they are not listed in nox.options.sessions

I've just checked with Nox 2022.11.21 (on Windows); nox -p 3.8 runs only sessions listed in nox.options.sessions which have 3.8 specified

I think it can also help with missing interpreters on CI. Nox 2022.11.21 gives error on CI in that case (it was a warning earlier). See wntrblm/nox#567
So I've had to add nox --no-error-on-missing-interpreters flag
Update: --python flag works fine

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

No branches or pull requests

3 participants