Skip to content

Commit a75de96

Browse files
committed
feat: allow defining a python version list for GHA action
1 parent a5d2014 commit a75de96

File tree

4 files changed

+77
-9
lines changed

4 files changed

+77
-9
lines changed

.github/workflows/ci.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,22 @@ jobs:
3333
runs-on: ${{ matrix.os }}
3434
strategy:
3535
matrix:
36-
os: [ubuntu-18.04, ubuntu-20.04, windows-2019, windows-2022, macos-10.15, macos-11, macos-12]
36+
os: [ubuntu-18.04, windows-2019, macos-10.15]
3737
steps:
3838
- uses: actions/checkout@v2
3939
- uses: ./
4040
- run: nox --non-interactive --error-on-missing-interpreter --session github_actions_default_tests
41+
action-all-tests:
42+
runs-on: ${{ matrix.os }}
43+
strategy:
44+
matrix:
45+
os: [ubuntu-18.04, windows-2019, macos-10.15]
46+
steps:
47+
- uses: actions/checkout@v2
48+
- uses: ./
49+
with:
50+
python-versions: "['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', 'pypy3.7', 'pypy3.8', 'pypy3.9']"
51+
- run: nox --non-interactive --error-on-missing-interpreter --session github_actions_all_tests
4152
lint:
4253
runs-on: ubuntu-20.04
4354
steps:

action.yml

+35-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Setup Nox
2-
description: 'Prepares all python versions for nox'
2+
description: "Prepares all python versions for nox"
3+
inputs:
4+
python-versions:
5+
description: "List of python versions to install"
6+
required: true
7+
default: "['3.7', '3.8', '3.9', '3.10', 'pypy3.7', 'pypy3.8', 'pypy3.9']"
38
branding:
49
icon: package
510
color: blue
@@ -10,27 +15,54 @@ runs:
1015
- uses: actions/setup-python@v3
1116
with:
1217
python-version: "pypy-3.7"
18+
if: ${{ contains(fromJSON(inputs.python-versions), 'pypy3.7') }}
1319
- uses: actions/setup-python@v3
1420
with:
1521
python-version: "pypy-3.8"
22+
if: ${{ contains(fromJSON(inputs.python-versions), 'pypy3.8') }}
1623
- uses: actions/setup-python@v3
1724
with:
1825
python-version: "pypy-3.9"
26+
if: ${{ contains(fromJSON(inputs.python-versions), 'pypy3.9') }}
1927

28+
- uses: actions/setup-python@v3
29+
with:
30+
python-version: "2.7"
31+
if: ${{ contains(fromJSON(inputs.python-versions), '2.7') }}
32+
- uses: actions/setup-python@v3
33+
with:
34+
python-version: "3.5"
35+
if: ${{ contains(fromJSON(inputs.python-versions), '3.5') }}
36+
- uses: actions/setup-python@v3
37+
with:
38+
python-version: "3.6"
39+
if: ${{ contains(fromJSON(inputs.python-versions), '3.6') }}
2040
- uses: actions/setup-python@v3
2141
with:
2242
python-version: "3.7"
43+
if: ${{ contains(fromJSON(inputs.python-versions), '3.7') }}
2344
- uses: actions/setup-python@v3
2445
with:
2546
python-version: "3.8"
47+
if: ${{ contains(fromJSON(inputs.python-versions), '3.8') }}
2648
- uses: actions/setup-python@v3
2749
with:
2850
python-version: "3.9"
51+
if: ${{ contains(fromJSON(inputs.python-versions), '3.9') }}
2952
- uses: actions/setup-python@v3
3053
with:
3154
python-version: "3.10"
55+
# used to install nox
56+
# if: ${{ contains(fromJSON(inputs.python-versions), '3.10') }}
57+
- id: nox-python
58+
run: echo "::set-output name=exe::$(which python)"
59+
shell: bash
60+
61+
- uses: actions/setup-python@v3
62+
with:
63+
python-version: "3.11-dev"
64+
if: ${{ contains(fromJSON(inputs.python-versions), '3.11') }}
3265

3366
- name: "Install nox"
34-
# --python "$(which python)" => always use the last setup-python version to install nox.
35-
run: pipx install --python "$(which python)" '${{ github.action_path }}'
67+
run: pipx install --python '${{ steps.nox-python.outputs.exe }}' '${{ github.action_path }}'
3668
shell: bash

docs/tutorial.rst

+9-5
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ If you want to run ``nox`` within `GitHub Actions`_, you can use the ``wntrblm/n
3535
3636
# setup nox with all active CPython and PyPY versions provided by
3737
# the GitHub Actions environment i.e.
38-
# CPython 3.7 -> 3.10, PyPy 3.7 -> 3.9
38+
# python-versions: "['3.7', '3.8', '3.9', '3.10', 'pypy3.7', 'pypy3.8', 'pypy3.9']"
3939
- uses: wntrblm/nox
4040
41-
# You can also safely combine this with setup-python
41+
# setup nox only for a given list of python versions
42+
# The supported set of versions is the one below,
43+
# you must choose from this subset
4244
- uses: wntrblm/nox
43-
- uses: actions/setup-python@v3
4445
with:
45-
python-version: "2.7"
46+
python-versions: "['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', 'pypy3.7', 'pypy3.8', 'pypy3.9']"
47+
48+
# You can also safely combine this with setup-python
49+
- uses: wntrblm/nox
4650
- uses: actions/setup-python@v3
4751
with:
48-
python-version: "3.11-dev"
52+
python-version: "3.11.0-alpha.7"
4953
5054
.. _pip: https://pip.readthedocs.org
5155
.. _user site: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site

noxfile.py

+21
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,24 @@ def _check_python_version(session):
136136
def github_actions_default_tests(session):
137137
"""Check default versions installed by the nox GHA Action"""
138138
_check_python_version(session)
139+
140+
141+
# The following sessions are only to be run in CI to check the nox GHA action
142+
@nox.session(
143+
python=[
144+
"2.7",
145+
"3.5",
146+
"3.6",
147+
"3.7",
148+
"3.8",
149+
"3.9",
150+
"3.10",
151+
"3.11",
152+
"pypy3.7",
153+
"pypy3.8",
154+
"pypy3.9",
155+
]
156+
)
157+
def github_actions_all_tests(session):
158+
"""Check all versions installed by the nox GHA Action"""
159+
_check_python_version(session)

0 commit comments

Comments
 (0)