24
24
runs-on : ubuntu-latest
25
25
timeout-minutes : 20
26
26
steps :
27
- - name : Check out code from GitHub
27
+ - &checkout
28
+ name : Check out code from GitHub
28
29
29
- - name : Set up Python ${{ env.DEFAULT_PYTHON }}
30
+ - &setup-python-default
31
+ name : Set up Python ${{ env.DEFAULT_PYTHON }}
30
32
id : python
31
33
32
34
with :
38
40
echo "key=base-venv-${{ env.CACHE_VERSION }}-${{
39
41
hashFiles('pyproject.toml', 'requirements_dev.txt',
40
42
'requirements_full.txt', 'requirements_minimal.txt') }}" >> $GITHUB_OUTPUT
41
- - name : Restore Python virtual environment
43
+ - &cache-python
44
+ name : Restore Python virtual environment
42
45
id : cache-venv
43
46
44
47
with :
51
54
run : |
52
55
python -m venv venv
53
56
. venv/bin/activate
54
- python -m pip install -U pip setuptools wheel
57
+ python -m pip install -U pip
55
58
pip install -U -r requirements_full.txt
56
59
- name : Generate pre-commit restore key
57
60
id : generate-pre-commit-key
@@ -82,12 +85,11 @@ jobs:
82
85
strategy :
83
86
fail-fast : false
84
87
matrix :
85
- python-version : ["3.10", "3.11", "3.12", "3.13", "3.14"]
88
+ python-version : &matrix-python-version ["3.10", "3.11", "3.12", "3.13", "3.14"]
86
89
outputs :
87
90
python-key : ${{ steps.generate-python-key.outputs.key }}
88
91
steps :
89
- - name : Check out code from GitHub
90
-
92
+ - *checkout
91
93
- name : Set up Python ${{ matrix.python-version }}
92
94
id : python
93
95
@@ -106,14 +108,7 @@ jobs:
106
108
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
107
109
hashFiles('pyproject.toml', 'requirements_dev.txt',
108
110
'requirements_full.txt', 'requirements_minimal.txt') }}" >> $GITHUB_OUTPUT
109
- - name : Restore Python virtual environment
110
- id : cache-venv
111
-
112
- with :
113
- path : venv
114
- key : >-
115
- ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
116
- steps.generate-python-key.outputs.key }}
111
+ - *cache-python
117
112
- name : Create Python virtual environment
118
113
if : steps.cache-venv.outputs.cache-hit != 'true'
119
114
run : |
@@ -127,7 +122,7 @@ jobs:
127
122
. venv/bin/activate
128
123
pytest --cov
129
124
- name : Upload coverage artifact
130
-
125
+ uses :
&actions-upload-artifact actions/[email protected]
131
126
with :
132
127
name : coverage-linux-${{ matrix.python-version }}
133
128
path : .coverage
@@ -137,7 +132,7 @@ jobs:
137
132
name : tests / run / ${{ matrix.python-version }} / Windows
138
133
runs-on : windows-latest
139
134
timeout-minutes : 20
140
- needs : tests-linux
135
+ needs : [ tests-linux]
141
136
strategy :
142
137
fail-fast : false
143
138
matrix :
@@ -147,9 +142,9 @@ jobs:
147
142
run : echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
148
143
# Workaround to set correct temp directory on Windows
149
144
# https://github.com/actions/virtual-environments/issues/712
150
- - name : Check out code from GitHub
151
-
152
- - name : Set up Python ${{ matrix.python-version }}
145
+ - *checkout
146
+ - &setup-python-matrix
147
+ name : Set up Python ${{ matrix.python-version }}
153
148
id : python
154
149
155
150
with :
@@ -162,28 +157,21 @@ jobs:
162
157
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
163
158
hashFiles('pyproject.toml', 'requirements_dev.txt',
164
159
'requirements_full.txt', 'requirements_minimal.txt') }}" >> $GITHUB_OUTPUT
165
- - name : Restore Python virtual environment
166
- id : cache-venv
167
-
168
- with :
169
- path : venv
170
- key : >-
171
- ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
172
- steps.generate-python-key.outputs.key }}
160
+ - *cache-python
173
161
- name : Create Python virtual environment
174
162
if : steps.cache-venv.outputs.cache-hit != 'true'
175
163
run : |
176
164
python -m venv venv
177
165
. venv\\Scripts\\activate
178
- python -m pip install -U pip setuptools wheel
166
+ python -m pip install -U pip
179
167
pip install -U -r requirements_full.txt
180
168
pip install -e .
181
169
- name : Run pytest
182
170
run : |
183
171
. venv\\Scripts\\activate
184
172
pytest --cov
185
173
- name : Upload coverage artifact
186
- uses : actions/ upload-artifact@v4.6.2
174
+ uses : * actions- upload-artifact
187
175
with :
188
176
name : coverage-windows-${{ matrix.python-version }}
189
177
path : .coverage
@@ -199,42 +187,29 @@ jobs:
199
187
# We only test on the lowest and highest supported PyPy versions
200
188
python-version : ["pypy3.10"]
201
189
steps :
202
- - name : Check out code from GitHub
203
-
204
- - name : Set up Python ${{ matrix.python-version }}
205
- id : python
206
-
207
- with :
208
- python-version : ${{ matrix.python-version }}
209
- check-latest : true
190
+ - *checkout
191
+ - *setup-python-matrix
210
192
- name : Generate partial Python venv restore key
211
193
id : generate-python-key
212
194
run : >-
213
195
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
214
196
hashFiles('pyproject.toml', 'requirements_minimal.txt')
215
197
}}" >> $GITHUB_OUTPUT
216
- - name : Restore Python virtual environment
217
- id : cache-venv
218
-
219
- with :
220
- path : venv
221
- key : >-
222
- ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
223
- steps.generate-python-key.outputs.key }}
198
+ - *cache-python
224
199
- name : Create Python virtual environment
225
200
if : steps.cache-venv.outputs.cache-hit != 'true'
226
201
run : |
227
202
python -m venv venv
228
203
. venv/bin/activate
229
- python -m pip install -U pip setuptools wheel
204
+ python -m pip install -U pip
230
205
pip install -U -r requirements_minimal.txt
231
206
pip install -e .
232
207
- name : Run pytest
233
208
run : |
234
209
. venv/bin/activate
235
210
pytest --cov
236
211
- name : Upload coverage artifact
237
- uses : actions/ upload-artifact@v4.6.2
212
+ uses : * actions- upload-artifact
238
213
with :
239
214
name : coverage-pypy-${{ matrix.python-version }}
240
215
path : .coverage
@@ -246,14 +221,8 @@ jobs:
246
221
timeout-minutes : 10
247
222
needs : ["tests-linux", "tests-windows", "tests-pypy"]
248
223
steps :
249
- - name : Check out code from GitHub
250
-
251
- - name : Set up Python 3.13
252
- id : python
253
-
254
- with :
255
- python-version : " 3.13"
256
- check-latest : true
224
+ - *checkout
225
+ - *setup-python-default
257
226
- name : Install dependencies
258
227
run : pip install -U -r requirements_minimal.txt
259
228
- name : Download all coverage artifacts
@@ -262,7 +231,7 @@ jobs:
262
231
run : |
263
232
coverage combine coverage-linux*/.coverage
264
233
coverage xml -o coverage-linux.xml
265
- - uses : codecov/codecov-action@v5
234
+ - uses : &actions-codecov codecov/codecov-action@v5
266
235
with :
267
236
token : ${{ secrets.CODECOV_TOKEN }}
268
237
fail_ci_if_error : true
@@ -273,7 +242,7 @@ jobs:
273
242
run : |
274
243
coverage combine coverage-windows*/.coverage
275
244
coverage xml -o coverage-windows.xml
276
- - uses : codecov/codecov-action@v5
245
+ - uses : *actions-codecov
277
246
with :
278
247
token : ${{ secrets.CODECOV_TOKEN }}
279
248
fail_ci_if_error : true
@@ -284,7 +253,7 @@ jobs:
284
253
run : |
285
254
coverage combine coverage-pypy*/.coverage
286
255
coverage xml -o coverage-pypy.xml
287
- - uses : codecov/codecov-action@v5
256
+ - uses : *actions-codecov
288
257
with :
289
258
token : ${{ secrets.CODECOV_TOKEN }}
290
259
fail_ci_if_error : true
0 commit comments