-
Notifications
You must be signed in to change notification settings - Fork 0
416 lines (401 loc) · 16.1 KB
/
test_actions.yml
File metadata and controls
416 lines (401 loc) · 16.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
name: Test actions
on:
workflow_call:
workflow_dispatch:
jobs:
test_setup_python:
name: Test setup-python
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
# pypy3.11-7.3.20 is a workaround for https://github.com/pypy/pypy/issues/5388 - Regression in 7.3.21: OpenSSL prints verbosely
python-version: [3.9, '3.10', 3.11, 3.12, 3.13, 3.13t, 3.14, 3.14t, pypy3.10, pypy3.11-7.3.20]
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: ./setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Check Python version
run: |
import sys, sysconfig, re
match = re.search(r"(\d+)\.(\d+)(?:\.(\d+))?", "${{ matrix.python-version }}")
expected_version = tuple(int(g) for g in match.groups() if g is not None)
version = sys.version_info[:len(expected_version)]
if version != expected_version:
print(f"::error title=Test Failure::The Python version does not match. Got {version}, expected {expected_version}.")
sys.exit(1)
implementation = sys.implementation.name
expected_implementation = "pypy" if "${{ matrix.python-version }}".startswith("pypy") else "cpython"
if implementation != expected_implementation:
print(f"::error title=Test Failure::The Python implementation does not match. Got {implementation}, expected {expected_implementation}.")
sys.exit(1)
threading = "free-threading" if sysconfig.get_config_var("Py_GIL_DISABLED") else "GIL"
expected_threading = "free-threading" if "t" in "${{ matrix.python-version }}" else "GIL"
if threading != expected_threading:
print(f"::error title=Test Failure::The Python threading does not match. Got {threading}, expected {expected_threading}.")
sys.exit(1)
shell: python
test_setup_poetry:
name: Test setup-poetry
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, '3.10', 3.11, 3.12, 3.13, 3.14, 3.14t, pypy3.10, pypy3.11-7.3.20]
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: ./setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ./setup-poetry
- name: Create project
run: poetry new test-project
- name: Check that the project was created
run: |
if [ ! -f test-project/pyproject.toml ]; then
echo "::error title=Test Failure::The project file does not exist."
exit 1
fi
shell: bash
test_setup_poetry_cache_hit:
name: Test setup-poetry (cache hit)
runs-on: ${{ matrix.os }}
needs: test_setup_poetry
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, '3.10', 3.11, 3.12, 3.13, 3.14, 3.14t, pypy3.10, pypy3.11-7.3.20]
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: ./setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
id: setup-poetry
uses: ./setup-poetry
- name: Error if cache miss
if: steps.setup-poetry.outputs.cache-hit != 'true'
run: echo "::error title=Test Failure::Expected cache hit."; exit 1
shell: bash
- name: Create project
run: poetry new test-project
- name: Check that the project was created
run: |
if [ ! -f test-project/pyproject.toml ]; then
echo "::error title=Test Failure::The project file does not exist."
exit 1
fi
shell: bash
test_setup_poetry_no_cache:
name: Test setup-poetry (no cache)
runs-on: ${{ matrix.os }}
needs: test_setup_poetry
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, '3.10', 3.11, 3.12, 3.13, 3.14, 3.14t, pypy3.10, pypy3.11-7.3.20]
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: ./setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
id: setup-poetry
uses: ./setup-poetry
with:
use-cache: false
- name: Error if cache hit
if: steps.setup-poetry.outputs.cache-hit == 'true'
run: echo "::error title=Test Failure::Expected cache miss."; exit 1
shell: bash
- name: Create project
run: poetry new test-project
- name: Check that the project was created
run: |
if [ ! -f test-project/pyproject.toml ]; then
echo "::error title=Test Failure::The project file does not exist."
exit 1
fi
shell: bash
test_check_project_version:
name: Test check-project-version
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: ./setup-python
- name: Set up Poetry
uses: ./setup-poetry
- name: Create project with version 1.0.0
run: |
poetry new test-project
poetry version 1.0.0 -C test-project
- name: Check version == 1.0.0
uses: ./check-project-version
with:
project-directory: test-project
expected-version: 1.0.0
- name: Create a notice about the expected failure
run: echo "::notice title=Notice::The next step is expected to fail."
- name: Check version == 1.0.1 (expected to fail)
id: expected-failure
continue-on-error: true
uses: ./check-project-version
with:
project-directory: test-project
expected-version: 1.0.1
- name: Error if the previous step didn't fail
if: steps.expected-failure.outcome != 'failure'
run: |
echo "::error title=Test Failure::The previous step did not fail as expected."
exit 1
test_update_project_version:
name: Test update-project-version
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: ./setup-python
- name: Set up Poetry
uses: ./setup-poetry
- name: Create project with version 1.0.0
run: |
poetry new test-project
poetry version 1.0.0 -C test-project
- name: Update version to 1.0.1
uses: ./update-project-version
with:
project-directory: test-project
create-pull-request: false
version-rule: patch
use-dev-suffix: false
- name: Check version == 1.0.1
uses: ./check-project-version
with:
project-directory: test-project
expected-version: 1.0.1
- name: Update version to 1.0.2.dev0
uses: ./update-project-version
with:
project-directory: test-project
create-pull-request: false
- name: Check version == 1.0.2.dev0
uses: ./check-project-version
with:
project-directory: test-project
expected-version: 1.0.2.dev0
- name: Update version to 1.0.2.dev1
uses: ./update-project-version
with:
project-directory: test-project
create-pull-request: false
- name: Check version == 1.0.2.dev1
uses: ./check-project-version
with:
project-directory: test-project
expected-version: 1.0.2.dev1
test_analyze_project:
name: Test analyze-project
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # If there are failures, sometimes it is instructive to see which combinations passed
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, '3.10', 3.11, 3.12, 3.13, 3.14, 3.14t, pypy3.10, pypy3.11-7.3.20]
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: ./setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ./setup-poetry
- name: Analyze minimal valid project
uses: ./analyze-project
with:
project-directory: ${{ github.workspace }}/.github/test_projects/minimal
- name: Analyze ni-python-styleguide-errors project
uses: ./analyze-project
id: analyze-ni-python-styleguide-errors
continue-on-error: true
with:
project-directory: ${{ github.workspace }}/.github/test_projects/ni-python-styleguide-errors
- name: Error if the previous step didn't fail
if: steps.analyze-ni-python-styleguide-errors.outcome != 'failure'
run: |
echo "::error title=Test Failure::The previous step did not fail as expected."
exit 1
- name: Analyze mypy-errors project
uses: ./analyze-project
id: analyze-mypy-errors
continue-on-error: true
with:
project-directory: ${{ github.workspace }}/.github/test_projects/mypy-errors
- name: Error if the previous step didn't fail
if: steps.analyze-mypy-errors.outcome != 'failure'
run: |
echo "::error title=Test Failure::The previous step did not fail as expected."
exit 1
- name: Analyze pyright-errors project
uses: ./analyze-project
id: analyze-pyright-errors
continue-on-error: true
with:
project-directory: ${{ github.workspace }}/.github/test_projects/pyright-errors
- name: Error if the previous step didn't fail
if: steps.analyze-pyright-errors.outcome != 'failure'
run: |
echo "::error title=Test Failure::The previous step did not fail as expected."
exit 1
- name: Analyze only-ni-python-styleguide project
uses: ./analyze-project
with:
project-directory: ${{ github.workspace }}/.github/test_projects/only-ni-python-styleguide
- name: Analyze extras-and-dependency-groups project
uses: ./analyze-project
with:
project-directory: ${{ github.workspace }}/.github/test_projects/extras-and-dependency-groups
install-args: "--extras 'colors serialization' --with dev,docs,utils"
- name: Check for expected dependencies
run: |
echo "Checking for expected packages from extras and dependency groups..."
pip_list=$(poetry run pip list)
echo "Installed packages:"
echo "$pip_list"
# Check for extras packages
if ! echo "$pip_list" | grep -i "colorama"; then
echo "::error title=Test Failure::colorama (from colors extra) not found in pip list"
exit 1
fi
if ! echo "$pip_list" | grep -i "tomli"; then
echo "::error title=Test Failure::tomli (from serialization extra) not found in pip list"
exit 1
fi
# Check for dependency group packages
if ! echo "$pip_list" | grep -i "pytest"; then
echo "::error title=Test Failure::pytest (from dev group) not found in pip list"
exit 1
fi
if ! echo "$pip_list" | grep -i "markdown"; then
echo "::error title=Test Failure::markdown (from docs group) not found in pip list"
exit 1
fi
if ! echo "$pip_list" | grep -i "click"; then
echo "::error title=Test Failure::click (from utils group) not found in pip list"
exit 1
fi
echo "All expected packages found!"
working-directory: ${{ github.workspace }}/.github/test_projects/extras-and-dependency-groups
shell: bash
test_analyze_project_cache_hit:
name: Test analyze-project (cache hit)
needs: test_analyze_project
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, '3.10', 3.11, 3.12, 3.13, 3.14, 3.14t, pypy3.10, pypy3.11-7.3.20]
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: ./setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ./setup-poetry
- name: Analyze minimal valid project
uses: ./analyze-project
with:
project-directory: ${{ github.workspace }}/.github/test_projects/minimal
- name: Analyze ni-python-styleguide-errors project
uses: ./analyze-project
id: analyze-ni-python-styleguide-errors
continue-on-error: true
with:
project-directory: ${{ github.workspace }}/.github/test_projects/ni-python-styleguide-errors
- name: Error if the previous step didn't fail
if: steps.analyze-ni-python-styleguide-errors.outcome != 'failure'
run: |
echo "::error title=Test Failure::The previous step did not fail as expected."
exit 1
- name: Analyze mypy-errors project
uses: ./analyze-project
id: analyze-mypy-errors
continue-on-error: true
with:
project-directory: ${{ github.workspace }}/.github/test_projects/mypy-errors
- name: Error if the previous step didn't fail
if: steps.analyze-mypy-errors.outcome != 'failure'
run: |
echo "::error title=Test Failure::The previous step did not fail as expected."
exit 1
- name: Analyze pyright-errors project
uses: ./analyze-project
id: analyze-pyright-errors
continue-on-error: true
with:
project-directory: ${{ github.workspace }}/.github/test_projects/pyright-errors
- name: Error if the previous step didn't fail
if: steps.analyze-pyright-errors.outcome != 'failure'
run: |
echo "::error title=Test Failure::The previous step did not fail as expected."
exit 1
- name: Analyze only-ni-python-styleguide project
uses: ./analyze-project
with:
project-directory: ${{ github.workspace }}/.github/test_projects/only-ni-python-styleguide
test_analyze_project_repo_root:
name: Test analyze-project (repo root)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, '3.10', 3.11, 3.12, 3.13, 3.14, 3.14t, pypy3.10, pypy3.11-7.3.20]
steps:
- name: Check out repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: ./setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ./setup-poetry
- name: Copy Python project to root
run: cp -av "${{ github.workspace }}/.github/test_projects/repo_root"/* "${{ github.workspace }}"
shell: bash
- name: Analyze Python project
uses: ./analyze-project
# This job is intended to combine the test results so we don't have to list
# each matrix combination in the required status check settings. There are a
# lot of corner cases that make this harder than it should be; see See
# https://github.com/orgs/community/discussions/26822 for more info.
test_results:
name: Test Results
runs-on: ubuntu-latest
needs: [
test_setup_python,
test_setup_poetry,
test_setup_poetry_cache_hit,
test_setup_poetry_no_cache,
test_check_project_version,
test_update_project_version,
test_analyze_project,
test_analyze_project_repo_root,
]
if: ${{ !cancelled() }}
steps:
- run: exit 0