@@ -16,8 +16,39 @@ 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
+ ALL_PYTHON : " ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']"
22
+
23
+ permissions :
24
+ contents : read
19
25
20
26
jobs :
27
+ # `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`.
28
+ # Some jobs set up a text matrix which is outside of `steps` and environment variables can't be used directly.
29
+ # This requires a workaround based on the discussion in:
30
+ # https://github.com/actions/runner/issues/2372
31
+ # The limitation is captured here where certain job configurations don't have access to `env`
32
+ # https://docs.github.com/en/enterprise-cloud@latest/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#context-availability
33
+ all_python_setup :
34
+ runs-on : ubuntu-latest
35
+ outputs :
36
+ all_python : ${{ env.ALL_PYTHON }}
37
+ steps :
38
+ - name : Set up all python
39
+ id : all_python
40
+ run : |
41
+ echo 'all_python={{ "${{ env.ALL_PYTHON }}" }}'
42
+ python_config :
43
+ runs-on : ubuntu-latest
44
+ outputs :
45
+ oldest_python : ${{ env.OLDEST_PYTHON }}
46
+ latest_stable_python : ${{ env.LATEST_STABLE_PYTHON }}
47
+ steps :
48
+ - name : Print env variables for `python_config`
49
+ run : |
50
+ echo 'oldest_python={{ "${{ env.OLDEST_PYTHON }}" }}'
51
+ echo 'latest_stable_python={{ "${{ env.LATEST_STABLE_PYTHON }}" }}'
21
52
docs :
22
53
runs-on : ubuntu-latest
23
54
steps :
@@ -34,11 +65,15 @@ jobs:
34
65
- name : Build the documentation.
35
66
run : nox -s docs
36
67
mypy :
68
+ needs : all_python_setup
37
69
strategy :
38
70
matrix :
39
71
# Run mypy on all of the supported python versions listed in setup.py
40
72
# https://github.com/python/mypy/blob/master/setup.py
41
- python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
73
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
74
+ exclude :
75
+ # Remove once https://github.com/googleapis/gapic-generator-python/issues/2303 is fixed
76
+ - python : ' 3.7'
42
77
runs-on : ubuntu-latest
43
78
steps :
44
79
- uses : actions/checkout@v4
@@ -52,11 +87,12 @@ jobs:
52
87
- name : Check type annotations.
53
88
run : nox -s mypy-${{ matrix.python }}
54
89
showcase :
90
+ needs : python_config
55
91
strategy :
56
92
# Run showcase tests on the lowest and highest supported runtimes
57
93
matrix :
58
94
# 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 "]
95
+ python : ["${{ needs.python_config.outputs.oldest_python }} ", "${{ needs.python_config.outputs.latest_stable_python }} "]
60
96
target : [showcase, showcase_w_rest_async]
61
97
logging_scope : ["", "google"]
62
98
@@ -111,10 +147,10 @@ jobs:
111
147
run : |
112
148
sudo mkdir -p /tmp/workspace/tests/cert/
113
149
sudo chown -R ${USER} /tmp/workspace/
114
- - name : Set up Python "3.13"
150
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
115
151
uses : actions/setup-python@v5
116
152
with :
117
- python-version : " 3.13 "
153
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
118
154
cache : ' pip'
119
155
- name : Copy mtls files
120
156
run : cp tests/cert/mtls.* /tmp/workspace/tests/cert/
@@ -145,9 +181,10 @@ jobs:
145
181
nox -s ${{ matrix.target }}
146
182
# TODO(yon-mg): add compute unit tests
147
183
showcase-unit :
184
+ needs : all_python_setup
148
185
strategy :
149
186
matrix :
150
- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
187
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
151
188
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
152
189
variant : ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
153
190
logging_scope : ["", "google"]
@@ -185,10 +222,10 @@ jobs:
185
222
runs-on : ubuntu-latest
186
223
steps :
187
224
- uses : actions/checkout@v4
188
- - name : Set up Python "3.13"
225
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
189
226
uses : actions/setup-python@v5
190
227
with :
191
- python-version : " 3.13 "
228
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
192
229
cache : ' pip'
193
230
- name : Install system dependencies.
194
231
run : |
@@ -213,10 +250,10 @@ jobs:
213
250
variant : ['', _alternative_templates]
214
251
steps :
215
252
- uses : actions/checkout@v4
216
- - name : Set up Python "3.13"
253
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
217
254
uses : actions/setup-python@v5
218
255
with :
219
- python-version : " 3.13 "
256
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
220
257
cache : ' pip'
221
258
- name : Install system dependencies.
222
259
run : |
@@ -235,13 +272,14 @@ jobs:
235
272
- name : Typecheck the generated output.
236
273
run : nox -s showcase_mypy${{ matrix.variant }}
237
274
snippetgen :
275
+ needs : all_python_setup
238
276
runs-on : ubuntu-latest
239
277
steps :
240
278
- uses : actions/checkout@v4
241
- - name : Set up Python "3.13"
279
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
242
280
uses : actions/setup-python@v5
243
281
with :
244
- python-version : " 3.13 "
282
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
245
283
cache : ' pip'
246
284
- name : Install system dependencies.
247
285
run : |
@@ -252,10 +290,10 @@ jobs:
252
290
- name : Check autogenerated snippets.
253
291
run : nox -s snippetgen
254
292
unit :
293
+ needs : all_python_setup
255
294
strategy :
256
295
matrix :
257
- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
258
-
296
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
259
297
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
260
298
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
261
299
runs-on : ubuntu-22.04
@@ -264,7 +302,7 @@ jobs:
264
302
- name : Set up Python ${{ matrix.python }}
265
303
uses : actions/setup-python@v5
266
304
with :
267
- python-version : ${{ matrix.python }}
305
+ python-version : " ${{ matrix.python }}"
268
306
cache : ' pip'
269
307
- name : Install pandoc
270
308
run : |
@@ -276,9 +314,10 @@ jobs:
276
314
- name : Run unit tests.
277
315
run : nox -s unit-${{ matrix.python }}
278
316
fragment :
317
+ needs : all_python_setup
279
318
strategy :
280
319
matrix :
281
- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
320
+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
282
321
variant : ['', _alternative_templates]
283
322
284
323
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
@@ -289,7 +328,7 @@ jobs:
289
328
- name : Set up Python ${{ matrix.python }}
290
329
uses : actions/setup-python@v5
291
330
with :
292
- python-version : ${{ matrix.python }}
331
+ python-version : " ${{ matrix.python }}"
293
332
cache : ' pip'
294
333
- name : Install pandoc
295
334
run : |
@@ -333,29 +372,29 @@ jobs:
333
372
runs-on : ubuntu-latest
334
373
steps :
335
374
- uses : actions/checkout@v4
336
- - name : Set up Python 3.13
375
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
337
376
uses : actions/setup-python@v5
338
377
with :
339
- python-version : " 3.13 "
378
+ python-version : ${{ env.LATEST_STABLE_PYTHON }}
340
379
cache : ' pip'
341
380
- name : Install nox.
342
381
run : |
343
382
python -m pip install nox
344
383
- name : Run blacken and lint on the generated output.
345
384
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
385
+ nox -f tests/integration/goldens/asset/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
386
+ nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
387
+ nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
388
+ nox -f tests/integration/goldens/logging/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
389
+ nox -f tests/integration/goldens/redis/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
351
390
goldens-unit :
352
391
runs-on : ubuntu-latest
353
392
steps :
354
393
- uses : actions/checkout@v4
355
- - name : Set up Python 3.13
394
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
356
395
uses : actions/setup-python@v5
357
396
with :
358
- python-version : " 3.13 "
397
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
359
398
cache : ' pip'
360
399
- name : Install nox.
361
400
run : |
@@ -365,18 +404,18 @@ jobs:
365
404
# in order to run unit tests
366
405
# See https://github.com/googleapis/gapic-generator-python/issues/1806
367
406
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
407
+ nox -f tests/integration/goldens/credentials/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
408
+ nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
409
+ nox -f tests/integration/goldens/logging/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
410
+ nox -f tests/integration/goldens/redis/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
372
411
goldens-prerelease :
373
412
runs-on : ubuntu-latest
374
413
steps :
375
414
- uses : actions/checkout@v4
376
- - name : Set up Python 3.13
415
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
377
416
uses : actions/setup-python@v5
378
417
with :
379
- python-version : " 3.13 "
418
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
380
419
cache : ' pip'
381
420
- name : Install nox.
382
421
run : |
@@ -394,10 +433,10 @@ jobs:
394
433
runs-on : ubuntu-latest
395
434
steps :
396
435
- uses : actions/checkout@v4
397
- - name : Set up Python "3.13"
436
+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
398
437
uses : actions/setup-python@v5
399
438
with :
400
- python-version : " 3.13 "
439
+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
401
440
cache : ' pip'
402
441
- name : Install nox.
403
442
run : |
0 commit comments