@@ -16,8 +16,40 @@ concurrency:
1616env :
1717 SHOWCASE_VERSION : 0.35.0
1818 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
1926
2027jobs :
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 }}" }}'
2153 docs :
2254 runs-on : ubuntu-latest
2355 steps :
@@ -49,11 +81,15 @@ jobs:
4981 - name : Build the documentation.
5082 run : nox -s docfx
5183 mypy :
84+ needs : all_python_setup
5285 strategy :
5386 matrix :
5487 # Run mypy on all of the supported python versions listed in setup.py
5588 # 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'
5793 runs-on : ubuntu-latest
5894 steps :
5995 - uses : actions/checkout@v5
@@ -62,16 +98,18 @@ jobs:
6298 with :
6399 python-version : " ${{ matrix.python }}"
64100 cache : ' pip'
101+ allow-prereleases : true
65102 - name : Install nox.
66103 run : python -m pip install nox
67104 - name : Check type annotations.
68105 run : nox -s mypy-${{ matrix.python }}
69106 showcase :
107+ needs : python_config
70108 strategy :
71109 # Run showcase tests on the lowest and highest supported runtimes
72110 matrix :
73111 # 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 }} "]
75113 target : [showcase, showcase_w_rest_async]
76114 logging_scope : ["", "google"]
77115
@@ -126,10 +164,10 @@ jobs:
126164 run : |
127165 sudo mkdir -p /tmp/workspace/tests/cert/
128166 sudo chown -R ${USER} /tmp/workspace/
129- - name : Set up Python "3.13"
167+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
130168 uses : actions/setup-python@v6
131169 with :
132- python-version : " 3.13 "
170+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
133171 cache : ' pip'
134172 - name : Copy mtls files
135173 run : cp tests/cert/mtls.* /tmp/workspace/tests/cert/
@@ -160,9 +198,10 @@ jobs:
160198 nox -s ${{ matrix.target }}
161199 # TODO(yon-mg): add compute unit tests
162200 showcase-unit :
201+ needs : all_python_setup
163202 strategy :
164203 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) }}
166205 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
167206 variant : ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
168207 logging_scope : ["", "google"]
@@ -177,6 +216,7 @@ jobs:
177216 with :
178217 python-version : " ${{ matrix.python }}"
179218 cache : ' pip'
219+ allow-prereleases : true
180220 - name : Install system dependencies.
181221 run : |
182222 sudo apt-get update
@@ -200,10 +240,10 @@ jobs:
200240 runs-on : ubuntu-latest
201241 steps :
202242 - uses : actions/checkout@v5
203- - name : Set up Python "3.13"
243+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
204244 uses : actions/setup-python@v6
205245 with :
206- python-version : " 3.13 "
246+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
207247 cache : ' pip'
208248 - name : Install system dependencies.
209249 run : |
@@ -228,10 +268,10 @@ jobs:
228268 variant : ['', _alternative_templates]
229269 steps :
230270 - uses : actions/checkout@v5
231- - name : Set up Python "3.13"
271+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
232272 uses : actions/setup-python@v6
233273 with :
234- python-version : " 3.13 "
274+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
235275 cache : ' pip'
236276 - name : Install system dependencies.
237277 run : |
@@ -250,13 +290,14 @@ jobs:
250290 - name : Typecheck the generated output.
251291 run : nox -s showcase_mypy${{ matrix.variant }}
252292 snippetgen :
293+ needs : all_python_setup
253294 runs-on : ubuntu-latest
254295 steps :
255296 - uses : actions/checkout@v5
256- - name : Set up Python "3.13"
297+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
257298 uses : actions/setup-python@v6
258299 with :
259- python-version : " 3.13 "
300+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
260301 cache : ' pip'
261302 - name : Install system dependencies.
262303 run : |
@@ -267,10 +308,10 @@ jobs:
267308 - name : Check autogenerated snippets.
268309 run : nox -s snippetgen
269310 unit :
311+ needs : all_python_setup
270312 strategy :
271313 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) }}
274315 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
275316 # Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
276317 runs-on : ubuntu-22.04
@@ -279,8 +320,9 @@ jobs:
279320 - name : Set up Python ${{ matrix.python }}
280321 uses : actions/setup-python@v6
281322 with :
282- python-version : ${{ matrix.python }}
323+ python-version : " ${{ matrix.python }}"
283324 cache : ' pip'
325+ allow-prereleases : true
284326 - name : Install pandoc
285327 run : |
286328 sudo apt-get update
@@ -291,11 +333,11 @@ jobs:
291333 - name : Run unit tests.
292334 run : nox -s unit-${{ matrix.python }}
293335 fragment :
336+ needs : all_python_setup
294337 strategy :
295338 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) }}
297340 variant : ['', _alternative_templates]
298-
299341 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
300342 # Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
301343 runs-on : ubuntu-22.04
@@ -304,8 +346,9 @@ jobs:
304346 - name : Set up Python ${{ matrix.python }}
305347 uses : actions/setup-python@v6
306348 with :
307- python-version : ${{ matrix.python }}
349+ python-version : " ${{ matrix.python }}"
308350 cache : ' pip'
351+ allow-prereleases : true
309352 - name : Install pandoc
310353 run : |
311354 sudo apt-get update
@@ -348,29 +391,29 @@ jobs:
348391 runs-on : ubuntu-latest
349392 steps :
350393 - uses : actions/checkout@v5
351- - name : Set up Python 3.13
394+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
352395 uses : actions/setup-python@v6
353396 with :
354- python-version : " 3.13 "
397+ python-version : ${{ env.LATEST_STABLE_PYTHON }}
355398 cache : ' pip'
356399 - name : Install nox.
357400 run : |
358401 python -m pip install nox
359402 - name : Run blacken and lint on the generated output.
360403 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
366409 goldens-unit :
367410 runs-on : ubuntu-latest
368411 steps :
369412 - uses : actions/checkout@v5
370- - name : Set up Python 3.13
413+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
371414 uses : actions/setup-python@v6
372415 with :
373- python-version : " 3.13 "
416+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
374417 cache : ' pip'
375418 - name : Install nox.
376419 run : |
@@ -380,19 +423,20 @@ jobs:
380423 # in order to run unit tests
381424 # See https://github.com/googleapis/gapic-generator-python/issues/1806
382425 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 }}
387430 goldens-prerelease :
388431 runs-on : ubuntu-latest
389432 steps :
390433 - uses : actions/checkout@v5
391- - name : Set up Python 3.13
434+ - name : Set up Python ${{ env.PRE_RELEASE_PYTHON }}
392435 uses : actions/setup-python@v6
393436 with :
394- python-version : " 3.13 "
437+ python-version : " ${{ env.PRE_RELEASE_PYTHON }} "
395438 cache : ' pip'
439+ allow-prereleases : true
396440 - name : Install nox.
397441 run : |
398442 python -m pip install nox
@@ -409,10 +453,10 @@ jobs:
409453 runs-on : ubuntu-latest
410454 steps :
411455 - uses : actions/checkout@v5
412- - name : Set up Python "3.13"
456+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
413457 uses : actions/setup-python@v6
414458 with :
415- python-version : " 3.13 "
459+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
416460 cache : ' pip'
417461 - name : Install nox.
418462 run : |
0 commit comments