@@ -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']"
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 :
@@ -34,11 +66,15 @@ jobs:
34
66
- name : Build the documentation.
35
67
run : nox -s docs
36
68
mypy :
69
+ needs : all_python_setup
37
70
strategy :
38
71
matrix :
39
72
# Run mypy on all of the supported python versions listed in setup.py
40
73
# https://github.com/python/mypy/blob/master/setup.py
41
- python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
74
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
75
+ exclude :
76
+ # Remove once https://github.com/googleapis/gapic-generator-python/issues/2303 is fixed
77
+ - python : ' 3.7'
42
78
runs-on : ubuntu-latest
43
79
steps :
44
80
- uses : actions/checkout@v4
@@ -52,11 +88,12 @@ jobs:
52
88
- name : Check type annotations.
53
89
run : nox -s mypy-${{ matrix.python }}
54
90
showcase :
91
+ needs : python_config
55
92
strategy :
56
93
# Run showcase tests on the lowest and highest supported runtimes
57
94
matrix :
58
95
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `showcase_w_rest_async` target when async rest is GA.
59
- python : ["3.7 ", "3.13 "]
96
+ python : ["${{ needs.python_config.outputs.oldest_python }} ", "${{ needs.python_config.outputs.latest_stable_python }} "]
60
97
target : [showcase, showcase_w_rest_async]
61
98
logging_scope : ["", "google"]
62
99
@@ -111,10 +148,10 @@ jobs:
111
148
run : |
112
149
sudo mkdir -p /tmp/workspace/tests/cert/
113
150
sudo chown -R ${USER} /tmp/workspace/
114
- - name : Set up Python "3.13"
151
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
115
152
uses : actions/setup-python@v5
116
153
with :
117
- python-version : " 3.13 "
154
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
118
155
cache : ' pip'
119
156
- name : Copy mtls files
120
157
run : cp tests/cert/mtls.* /tmp/workspace/tests/cert/
@@ -145,9 +182,10 @@ jobs:
145
182
nox -s ${{ matrix.target }}
146
183
# TODO(yon-mg): add compute unit tests
147
184
showcase-unit :
185
+ needs : all_python_setup
148
186
strategy :
149
187
matrix :
150
- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
188
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
151
189
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
152
190
variant : ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
153
191
logging_scope : ["", "google"]
@@ -185,10 +223,10 @@ jobs:
185
223
runs-on : ubuntu-latest
186
224
steps :
187
225
- uses : actions/checkout@v4
188
- - name : Set up Python "3.13"
226
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
189
227
uses : actions/setup-python@v5
190
228
with :
191
- python-version : " 3.13 "
229
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
192
230
cache : ' pip'
193
231
- name : Install system dependencies.
194
232
run : |
@@ -213,10 +251,10 @@ jobs:
213
251
variant : ['', _alternative_templates]
214
252
steps :
215
253
- uses : actions/checkout@v4
216
- - name : Set up Python "3.13"
254
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
217
255
uses : actions/setup-python@v5
218
256
with :
219
- python-version : " 3.13 "
257
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
220
258
cache : ' pip'
221
259
- name : Install system dependencies.
222
260
run : |
@@ -235,13 +273,14 @@ jobs:
235
273
- name : Typecheck the generated output.
236
274
run : nox -s showcase_mypy${{ matrix.variant }}
237
275
snippetgen :
276
+ needs : all_python_setup
238
277
runs-on : ubuntu-latest
239
278
steps :
240
279
- uses : actions/checkout@v4
241
- - name : Set up Python "3.13"
280
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
242
281
uses : actions/setup-python@v5
243
282
with :
244
- python-version : " 3.13 "
283
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
245
284
cache : ' pip'
246
285
- name : Install system dependencies.
247
286
run : |
@@ -252,10 +291,10 @@ jobs:
252
291
- name : Check autogenerated snippets.
253
292
run : nox -s snippetgen
254
293
unit :
294
+ needs : all_python_setup
255
295
strategy :
256
296
matrix :
257
- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
258
-
297
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
259
298
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
260
299
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
261
300
runs-on : ubuntu-22.04
@@ -264,7 +303,7 @@ jobs:
264
303
- name : Set up Python ${{ matrix.python }}
265
304
uses : actions/setup-python@v5
266
305
with :
267
- python-version : ${{ matrix.python }}
306
+ python-version : " ${{ matrix.python }}"
268
307
cache : ' pip'
269
308
- name : Install pandoc
270
309
run : |
@@ -276,9 +315,10 @@ jobs:
276
315
- name : Run unit tests.
277
316
run : nox -s unit-${{ matrix.python }}
278
317
fragment :
318
+ needs : all_python_setup
279
319
strategy :
280
320
matrix :
281
- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
321
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
282
322
variant : ['', _alternative_templates]
283
323
284
324
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
@@ -289,7 +329,7 @@ jobs:
289
329
- name : Set up Python ${{ matrix.python }}
290
330
uses : actions/setup-python@v5
291
331
with :
292
- python-version : ${{ matrix.python }}
332
+ python-version : " ${{ matrix.python }}"
293
333
cache : ' pip'
294
334
- name : Install pandoc
295
335
run : |
@@ -333,29 +373,29 @@ jobs:
333
373
runs-on : ubuntu-latest
334
374
steps :
335
375
- uses : actions/checkout@v4
336
- - name : Set up Python 3.13
376
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
337
377
uses : actions/setup-python@v5
338
378
with :
339
- python-version : " 3.13 "
379
+ python-version : ${{ env.LATEST_STABLE_PYTHON }}
340
380
cache : ' pip'
341
381
- name : Install nox.
342
382
run : |
343
383
python -m pip install nox
344
384
- name : Run blacken and lint on the generated output.
345
385
run : |
346
- nox -f tests/integration/goldens/asset/noxfile.py -s mypy-3.13 blacken lint
347
- nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-3.13 blacken lint
348
- nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-3.13 blacken lint
349
- nox -f tests/integration/goldens/logging/noxfile.py -s mypy-3.13 blacken lint
350
- nox -f tests/integration/goldens/redis/noxfile.py -s mypy-3.13 blacken lint
386
+ nox -f tests/integration/goldens/asset/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
387
+ nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
388
+ nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
389
+ nox -f tests/integration/goldens/logging/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
390
+ nox -f tests/integration/goldens/redis/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
351
391
goldens-unit :
352
392
runs-on : ubuntu-latest
353
393
steps :
354
394
- uses : actions/checkout@v4
355
- - name : Set up Python 3.13
395
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
356
396
uses : actions/setup-python@v5
357
397
with :
358
- python-version : " 3.13 "
398
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
359
399
cache : ' pip'
360
400
- name : Install nox.
361
401
run : |
@@ -365,19 +405,20 @@ jobs:
365
405
# in order to run unit tests
366
406
# See https://github.com/googleapis/gapic-generator-python/issues/1806
367
407
run : |
368
- nox -f tests/integration/goldens/credentials/noxfile.py -s unit-3.13
369
- nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-3.13
370
- nox -f tests/integration/goldens/logging/noxfile.py -s unit-3.13
371
- nox -f tests/integration/goldens/redis/noxfile.py -s unit-3.13
408
+ nox -f tests/integration/goldens/credentials/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
409
+ nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
410
+ nox -f tests/integration/goldens/logging/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
411
+ nox -f tests/integration/goldens/redis/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
372
412
goldens-prerelease :
373
413
runs-on : ubuntu-latest
374
414
steps :
375
415
- uses : actions/checkout@v4
376
- - name : Set up Python 3.13
416
+ - name : Set up Python ${{ env.PRE_RELEASE_PYTHON }}
377
417
uses : actions/setup-python@v5
378
418
with :
379
- python-version : " 3.13 "
419
+ python-version : " ${{ env.PRE_RELEASE_PYTHON }} "
380
420
cache : ' pip'
421
+ allow-prereleases : true
381
422
- name : Install nox.
382
423
run : |
383
424
python -m pip install nox
@@ -394,10 +435,10 @@ jobs:
394
435
runs-on : ubuntu-latest
395
436
steps :
396
437
- uses : actions/checkout@v4
397
- - name : Set up Python "3.13"
438
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
398
439
uses : actions/setup-python@v5
399
440
with :
400
- python-version : " 3.13 "
441
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
401
442
cache : ' pip'
402
443
- name : Install nox.
403
444
run : |
0 commit comments