@@ -16,8 +16,40 @@ concurrency:
16
16
env :
17
17
SHOWCASE_VERSION : 0.35.0
18
18
PROTOC_VERSION : 3.20.2
19
+ OLDEST_PYTHON : 3.7
20
+ LATEST_STABLE_PYTHON : 3.13
21
+ PRE_RELEASE_PYTHON : 3.14
22
+ ALL_PYTHON : " ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']"
23
+
24
+ permissions :
25
+ contents : read
19
26
20
27
jobs :
28
+ # `all_python_setup` amd `python_config` are a workaround for a known issue where it's not possible to use environment variables outside of `steps`.
29
+ # Some jobs set up a text matrix which is outside of `steps` and environment variables can't be used directly.
30
+ # This requires a workaround based on the discussion in:
31
+ # https://github.com/actions/runner/issues/2372
32
+ # The limitation is captured here where certain job configurations don't have access to `env`
33
+ # https://docs.github.com/en/enterprise-cloud@latest/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#context-availability
34
+ all_python_setup :
35
+ runs-on : ubuntu-latest
36
+ outputs :
37
+ all_python : ${{ env.ALL_PYTHON }}
38
+ steps :
39
+ - name : Set up all python
40
+ id : all_python
41
+ run : |
42
+ echo 'all_python={{ "${{ env.ALL_PYTHON }}" }}'
43
+ python_config :
44
+ runs-on : ubuntu-latest
45
+ outputs :
46
+ oldest_python : ${{ env.OLDEST_PYTHON }}
47
+ latest_stable_python : ${{ env.LATEST_STABLE_PYTHON }}
48
+ steps :
49
+ - name : Print env variables for `python_config`
50
+ run : |
51
+ echo 'oldest_python={{ "${{ env.OLDEST_PYTHON }}" }}'
52
+ echo 'latest_stable_python={{ "${{ env.LATEST_STABLE_PYTHON }}" }}'
21
53
docs :
22
54
runs-on : ubuntu-latest
23
55
steps :
@@ -49,11 +81,15 @@ jobs:
49
81
- name : Build the documentation.
50
82
run : nox -s docfx
51
83
mypy :
84
+ needs : all_python_setup
52
85
strategy :
53
86
matrix :
54
87
# Run mypy on all of the supported python versions listed in setup.py
55
88
# https://github.com/python/mypy/blob/master/setup.py
56
- python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
89
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
90
+ exclude :
91
+ # Remove once https://github.com/googleapis/gapic-generator-python/issues/2303 is fixed
92
+ - python : ' 3.7'
57
93
runs-on : ubuntu-latest
58
94
steps :
59
95
- uses : actions/checkout@v5
@@ -62,16 +98,18 @@ jobs:
62
98
with :
63
99
python-version : " ${{ matrix.python }}"
64
100
cache : ' pip'
101
+ allow-prereleases : true
65
102
- name : Install nox.
66
103
run : python -m pip install nox
67
104
- name : Check type annotations.
68
105
run : nox -s mypy-${{ matrix.python }}
69
106
showcase :
107
+ needs : python_config
70
108
strategy :
71
109
# Run showcase tests on the lowest and highest supported runtimes
72
110
matrix :
73
111
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `showcase_w_rest_async` target when async rest is GA.
74
- python : ["3.7 ", "3.13 "]
112
+ python : ["${{ needs.python_config.outputs.oldest_python }} ", "${{ needs.python_config.outputs.latest_stable_python }} "]
75
113
target : [showcase, showcase_w_rest_async]
76
114
logging_scope : ["", "google"]
77
115
@@ -126,10 +164,10 @@ jobs:
126
164
run : |
127
165
sudo mkdir -p /tmp/workspace/tests/cert/
128
166
sudo chown -R ${USER} /tmp/workspace/
129
- - name : Set up Python "3.13"
167
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
130
168
uses : actions/setup-python@v6
131
169
with :
132
- python-version : " 3.13 "
170
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
133
171
cache : ' pip'
134
172
- name : Copy mtls files
135
173
run : cp tests/cert/mtls.* /tmp/workspace/tests/cert/
@@ -160,9 +198,10 @@ jobs:
160
198
nox -s ${{ matrix.target }}
161
199
# TODO(yon-mg): add compute unit tests
162
200
showcase-unit :
201
+ needs : all_python_setup
163
202
strategy :
164
203
matrix :
165
- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
204
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
166
205
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
167
206
variant : ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
168
207
logging_scope : ["", "google"]
@@ -177,6 +216,7 @@ jobs:
177
216
with :
178
217
python-version : " ${{ matrix.python }}"
179
218
cache : ' pip'
219
+ allow-prereleases : true
180
220
- name : Install system dependencies.
181
221
run : |
182
222
sudo apt-get update
@@ -200,10 +240,10 @@ jobs:
200
240
runs-on : ubuntu-latest
201
241
steps :
202
242
- uses : actions/checkout@v5
203
- - name : Set up Python "3.13"
243
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
204
244
uses : actions/setup-python@v6
205
245
with :
206
- python-version : " 3.13 "
246
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
207
247
cache : ' pip'
208
248
- name : Install system dependencies.
209
249
run : |
@@ -228,10 +268,10 @@ jobs:
228
268
variant : ['', _alternative_templates]
229
269
steps :
230
270
- uses : actions/checkout@v5
231
- - name : Set up Python "3.13"
271
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
232
272
uses : actions/setup-python@v6
233
273
with :
234
- python-version : " 3.13 "
274
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
235
275
cache : ' pip'
236
276
- name : Install system dependencies.
237
277
run : |
@@ -250,13 +290,14 @@ jobs:
250
290
- name : Typecheck the generated output.
251
291
run : nox -s showcase_mypy${{ matrix.variant }}
252
292
snippetgen :
293
+ needs : all_python_setup
253
294
runs-on : ubuntu-latest
254
295
steps :
255
296
- uses : actions/checkout@v5
256
- - name : Set up Python "3.13"
297
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
257
298
uses : actions/setup-python@v6
258
299
with :
259
- python-version : " 3.13 "
300
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
260
301
cache : ' pip'
261
302
- name : Install system dependencies.
262
303
run : |
@@ -267,10 +308,10 @@ jobs:
267
308
- name : Check autogenerated snippets.
268
309
run : nox -s snippetgen
269
310
unit :
311
+ needs : all_python_setup
270
312
strategy :
271
313
matrix :
272
- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
273
-
314
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
274
315
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
275
316
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
276
317
runs-on : ubuntu-22.04
@@ -279,8 +320,9 @@ jobs:
279
320
- name : Set up Python ${{ matrix.python }}
280
321
uses : actions/setup-python@v6
281
322
with :
282
- python-version : ${{ matrix.python }}
323
+ python-version : " ${{ matrix.python }}"
283
324
cache : ' pip'
325
+ allow-prereleases : true
284
326
- name : Install pandoc
285
327
run : |
286
328
sudo apt-get update
@@ -291,11 +333,11 @@ jobs:
291
333
- name : Run unit tests.
292
334
run : nox -s unit-${{ matrix.python }}
293
335
fragment :
336
+ needs : all_python_setup
294
337
strategy :
295
338
matrix :
296
- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
339
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
297
340
variant : ['', _alternative_templates]
298
-
299
341
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
300
342
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
301
343
runs-on : ubuntu-22.04
@@ -304,8 +346,9 @@ jobs:
304
346
- name : Set up Python ${{ matrix.python }}
305
347
uses : actions/setup-python@v6
306
348
with :
307
- python-version : ${{ matrix.python }}
349
+ python-version : " ${{ matrix.python }}"
308
350
cache : ' pip'
351
+ allow-prereleases : true
309
352
- name : Install pandoc
310
353
run : |
311
354
sudo apt-get update
@@ -348,29 +391,29 @@ jobs:
348
391
runs-on : ubuntu-latest
349
392
steps :
350
393
- uses : actions/checkout@v5
351
- - name : Set up Python 3.13
394
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
352
395
uses : actions/setup-python@v6
353
396
with :
354
- python-version : " 3.13 "
397
+ python-version : ${{ env.LATEST_STABLE_PYTHON }}
355
398
cache : ' pip'
356
399
- name : Install nox.
357
400
run : |
358
401
python -m pip install nox
359
402
- name : Run blacken and lint on the generated output.
360
403
run : |
361
- nox -f tests/integration/goldens/asset/noxfile.py -s mypy-3.13 blacken lint
362
- nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-3.13 blacken lint
363
- nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-3.13 blacken lint
364
- nox -f tests/integration/goldens/logging/noxfile.py -s mypy-3.13 blacken lint
365
- nox -f tests/integration/goldens/redis/noxfile.py -s mypy-3.13 blacken lint
404
+ nox -f tests/integration/goldens/asset/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
405
+ nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
406
+ nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
407
+ nox -f tests/integration/goldens/logging/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
408
+ nox -f tests/integration/goldens/redis/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
366
409
goldens-unit :
367
410
runs-on : ubuntu-latest
368
411
steps :
369
412
- uses : actions/checkout@v5
370
- - name : Set up Python 3.13
413
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
371
414
uses : actions/setup-python@v6
372
415
with :
373
- python-version : " 3.13 "
416
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
374
417
cache : ' pip'
375
418
- name : Install nox.
376
419
run : |
@@ -380,19 +423,20 @@ jobs:
380
423
# in order to run unit tests
381
424
# See https://github.com/googleapis/gapic-generator-python/issues/1806
382
425
run : |
383
- nox -f tests/integration/goldens/credentials/noxfile.py -s unit-3.13
384
- nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-3.13
385
- nox -f tests/integration/goldens/logging/noxfile.py -s unit-3.13
386
- nox -f tests/integration/goldens/redis/noxfile.py -s unit-3.13
426
+ nox -f tests/integration/goldens/credentials/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
427
+ nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
428
+ nox -f tests/integration/goldens/logging/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
429
+ nox -f tests/integration/goldens/redis/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
387
430
goldens-prerelease :
388
431
runs-on : ubuntu-latest
389
432
steps :
390
433
- uses : actions/checkout@v5
391
- - name : Set up Python 3.13
434
+ - name : Set up Python ${{ env.PRE_RELEASE_PYTHON }}
392
435
uses : actions/setup-python@v6
393
436
with :
394
- python-version : " 3.13 "
437
+ python-version : " ${{ env.PRE_RELEASE_PYTHON }} "
395
438
cache : ' pip'
439
+ allow-prereleases : true
396
440
- name : Install nox.
397
441
run : |
398
442
python -m pip install nox
@@ -409,10 +453,10 @@ jobs:
409
453
runs-on : ubuntu-latest
410
454
steps :
411
455
- uses : actions/checkout@v5
412
- - name : Set up Python "3.13"
456
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
413
457
uses : actions/setup-python@v6
414
458
with :
415
- python-version : " 3.13 "
459
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
416
460
cache : ' pip'
417
461
- name : Install nox.
418
462
run : |
0 commit comments