4646 with :
4747 env-already-initialized : false
4848
49+ # Used to determine which python versions to test against.
50+ # noxfile.py is the source of truth, which in turn draws from
51+ # pyproject.toml's `project.requires-python` and `project.classifers`.
52+ python-versions :
53+ runs-on : ubuntu-latest
54+ outputs :
55+ min-python : ${{ steps.set-matrix.outputs.min-python }}
56+ docs : ${{ steps.set-matrix.outputs.docs }}
57+ libcst : ${{ steps.set-matrix.outputs.libcst }}
58+ pyright : ${{ steps.set-matrix.outputs.tests }}
59+ tests : ${{ steps.set-matrix.outputs.tests }}
60+ steps :
61+ - uses : actions/checkout@v4
62+ - name : Set up environment
63+ uses : ./.github/actions/setup-env
64+ with :
65+ python-version : 3.8
66+
67+ - name : Determine Python versions to test and lint against
68+ id : set-matrix
69+ run : |
70+ echo min-python=$(nox -s test --list --json | jq -rc '[.[].python][0]') | tee --append $GITHUB_OUTPUT
71+ echo docs=$(nox -s docs --list --json | jq -rc '.[].python') | tee --append $GITHUB_OUTPUT
72+ echo libcst=$(nox -s codemod --list --json | jq -rc '[.[].python][0]') | tee --append $GITHUB_OUTPUT
73+ echo tests=$(nox -s test --list --json | jq -c '[.[].python]') | tee --append $GITHUB_OUTPUT
4974 lint :
5075 runs-on : ubuntu-latest
5176 steps :
@@ -62,27 +87,30 @@ jobs:
6287 # readthedocs (see .readthedocs.yml) here for consistency
6388 runs-on : ubuntu-24.04
6489 needs :
90+ - python-versions
6591 - lock-dependencies
6692 - lint
6793 steps :
6894 - uses : actions/checkout@v4
6995
7096 - name : Set up environment
97+ id : setup-env
7198 uses : ./.github/actions/setup-env
7299 with :
73- python-version : 3.8
100+ python-version : ${{ needs.python-versions.outputs.docs }}
74101
75102 - name : Run sphinx-build
76- run : nox -s docs -- --keep-going -W -w $GITHUB_STEP_SUMMARY
103+ run : nox --force-python ${{ steps.setup-env.outputs.python-version }} - s docs -- --keep-going -W -w $GITHUB_STEP_SUMMARY
77104
78105 pyright :
79106 runs-on : ubuntu-latest
80107 needs :
108+ - python-versions
81109 - lock-dependencies
82110 - lint
83111 strategy :
84112 matrix :
85- python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"]
113+ python-version : ${{ fromJson(needs.python-versions.outputs.pyright) }}
86114 experimental : [false]
87115 fail-fast : false
88116 continue-on-error : ${{ matrix.experimental }}
@@ -100,31 +128,35 @@ jobs:
100128 python-version : ${{ matrix.python-version }}
101129
102130 - name : Install dependencies
103- run : pdm install -d -Gspeed -Gdocs -Gvoice
131+ # `--no-venv` to install in the main pdm venv instead of nox's pyright-specific one
132+ # because nox uses pdm internally to install, this means that the venv that is used is
133+ # the one that pdm would create in project: `.venv`
134+ run : |
135+ nox -s pyright --no-venv --install-only --force-python ${{ steps.setup-env.outputs.python-version }}
104136
105137 - name : Add .venv/bin to PATH
106138 run : dirname "$(pdm info --python)" >> $GITHUB_PATH
107139
108140 - name : Set pyright version
141+ id : pyright-version
109142 run : |
110- PYRIGHT_VERSION="$(pdm run python -c 'import pyright; print(pyright.__pyright_version__)')"
111- echo "PYRIGHT_VERSION=$PYRIGHT_VERSION" >> $GITHUB_ENV
143+ echo "pyright-version=$(pdm run python -c 'import pyright; print(pyright.__pyright_version__)')" >> $GITHUB_OUTPUT
112144
113145 - name : Run pyright (Linux)
114146 uses :
jakebailey/[email protected] 115147 id : pyright-linux
116148 with :
117- version : ${{ env.PYRIGHT_VERSION }}
149+ version : ${{ steps.pyright-version.outputs.pyright-version }}
118150 python-version : ${{ steps.setup-env.outputs.python-version }}
119151 python-platform : " Linux"
120- annotate : ${{ matrix.python-version == '3.8' }} # only add comments for one version
152+ annotate : ${{ matrix.python-version == needs.python-versions.outputs.min-python }} # only add comments for one version
121153 warnings : true
122154
123155 - name : Run pyright (Windows)
124156 uses :
jakebailey/[email protected] 125157 if : always() && (steps.pyright-linux.outcome == 'success' || steps.pyright-linux.outcome == 'failure')
126158 with :
127- version : ${{ env.PYRIGHT_VERSION }}
159+ version : ${{ steps.pyright-version.outputs.pyright-version }}
128160 python-version : ${{ steps.setup-env.outputs.python-version }}
129161 python-platform : " Windows"
130162 annotate : false # only add comments for one platform (see above)
@@ -133,6 +165,7 @@ jobs:
133165 misc :
134166 runs-on : ubuntu-latest
135167 needs :
168+ - python-versions
136169 - lock-dependencies
137170 - lint
138171 steps :
@@ -142,7 +175,7 @@ jobs:
142175 id : setup
143176 uses : ./.github/actions/setup-env
144177 with :
145- python-version : 3.8
178+ python-version : ${{ needs.python-versions.outputs.min-python }}
146179
147180 - name : Run slotscheck
148181 if : (success() || failure()) && steps.setup.outcome == 'success'
@@ -167,15 +200,17 @@ jobs:
167200 codemod :
168201 runs-on : ubuntu-latest
169202 needs :
203+ - python-versions
170204 - lock-dependencies
171205 - lint
172206 steps :
173207 - uses : actions/checkout@v4
174208
175209 - name : Set up environment
210+ id : setup
176211 uses : ./.github/actions/setup-env
177212 with :
178- python-version : 3.8
213+ python-version : ${{ needs.python-versions.outputs.libcst }}
179214
180215 # run the libcst parsers and check for changes
181216 - name : libcst codemod
@@ -200,12 +235,13 @@ jobs:
200235 pytest :
201236 runs-on : ${{ matrix.os }}
202237 needs :
238+ - python-versions
203239 - lock-dependencies
204240 - lint
205241 strategy :
206242 matrix :
207- python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"]
208243 os : ["windows-latest", "ubuntu-latest", "macos-latest"]
244+ python-version : ${{ fromJson(needs.python-versions.outputs.tests) }}
209245 experimental : [false]
210246 fail-fast : true
211247 continue-on-error : ${{ matrix.experimental }}
@@ -218,12 +254,9 @@ jobs:
218254 with :
219255 python-version : ${{ matrix.python-version }}
220256
221- - name : Install dependencies
222- run : pdm install -dG test # needed for coverage
223-
224- - name : Test package install
257+ - name : Install nox environment
225258 run : |
226- python -m pip install .
259+ nox -s test --no-venv -- install-only --force-python ${{ steps.setup-env.outputs.python-version }}
227260
228261 - name : Run pytest
229262 id : run_tests
@@ -232,14 +265,14 @@ jobs:
232265 TZ : " America/New_York"
233266 run : |
234267 echo "$GITHUB_STEP_SUMMARY_HEADER" | sed "s/#name#/Test Summary/" >> $GITHUB_STEP_SUMMARY
235- nox --force-python ${{ steps.setup-env.outputs.python-version }} -s test -- --color=no --cov-report= | tee -a $GITHUB_STEP_SUMMARY
268+ pdm run nox --no-venv -s test -- --color=no --cov-report= | tee -a $GITHUB_STEP_SUMMARY
236269 echo "$GITHUB_STEP_SUMMARY_FOOTER" >> $GITHUB_STEP_SUMMARY
237270
238271 - name : Print Coverage Output
239272 if : always() && (steps.run_tests.outcome == 'success' || steps.run_tests.outcome == 'failure')
240273 run : |
241274 echo "$GITHUB_STEP_SUMMARY_HEADER" | sed "s/#name#/Coverage Summary/" >> $GITHUB_STEP_SUMMARY
242- pdm run coverage report | tee -a $GITHUB_STEP_SUMMARY
275+ pdm run nox --no-venv -s coverage -- report | tee -a $GITHUB_STEP_SUMMARY
243276 echo "$GITHUB_STEP_SUMMARY_FOOTER" >> $GITHUB_STEP_SUMMARY
244277
245278 # thanks to aiohttp for this part of the workflow
0 commit comments