@@ -16,8 +16,37 @@ 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+
22+ permissions :
23+ contents : read
1924
2025jobs :
26+ all_python_setup :
27+ runs-on : ubuntu-latest
28+ outputs :
29+ all_python : ${{ steps.all_python_setup.outputs.all_python }}
30+ steps :
31+ - name : Set up all python
32+ id : all_python
33+ run : |
34+ echo 'all_python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]' >> $GITHUB_OUTPUT
35+ # This section is a workaround for a known issue where it's not possible to use environment variables outside of `steps`.
36+ # Some jobs set up a text matrix which is outside of `steps` and environment variables can't be used directly.
37+ # This requires a workaround based on the discussion in:
38+ # https://github.com/actions/runner/issues/2372
39+ # The limitation is captured here where
40+ # https://docs.github.com/en/enterprise-cloud@latest/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#context-availability
41+ python_config :
42+ runs-on : ubuntu-latest
43+ outputs :
44+ oldest_python : {{ "${{ env.OLDEST_PYTHON }}" }}
45+ latest_stable_python : {{ "${{ env.LATEST_STABLE_PYTHON }}" }}
46+ steps :
47+ - run : |
48+ echo ${{ env.OLDEST_PYTHON }}
49+ echo ${{ env.LATEST_STABLE_PYTHON }}
2150 docs :
2251 runs-on : ubuntu-latest
2352 steps :
@@ -34,11 +63,15 @@ jobs:
3463 - name : Build the documentation.
3564 run : nox -s docs
3665 mypy :
66+ needs : all_python_setup
3767 strategy :
3868 matrix :
3969 # Run mypy on all of the supported python versions listed in setup.py
4070 # https://github.com/python/mypy/blob/master/setup.py
41- python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
71+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
72+ exclude :
73+ # Remove once https://github.com/googleapis/gapic-generator-python/issues/2303 is fixed
74+ - python : 3.7
4275 runs-on : ubuntu-latest
4376 steps :
4477 - uses : actions/checkout@v4
@@ -52,11 +85,12 @@ jobs:
5285 - name : Check type annotations.
5386 run : nox -s mypy-${{ matrix.python }}
5487 showcase :
88+ needs : python_config
5589 strategy :
5690 # Run showcase tests on the lowest and highest supported runtimes
5791 matrix :
5892 # 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 "]
93+ python : ["${{ oldest_python }} ", "${{ latest_stable_python }} "]
6094 target : [showcase, showcase_w_rest_async]
6195 logging_scope : ["", "google"]
6296
@@ -111,10 +145,10 @@ jobs:
111145 run : |
112146 sudo mkdir -p /tmp/workspace/tests/cert/
113147 sudo chown -R ${USER} /tmp/workspace/
114- - name : Set up Python "3.13"
148+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
115149 uses : actions/setup-python@v5
116150 with :
117- python-version : " 3.13 "
151+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
118152 cache : ' pip'
119153 - name : Copy mtls files
120154 run : cp tests/cert/mtls.* /tmp/workspace/tests/cert/
@@ -145,9 +179,10 @@ jobs:
145179 nox -s ${{ matrix.target }}
146180 # TODO(yon-mg): add compute unit tests
147181 showcase-unit :
182+ needs : all_python_setup
148183 strategy :
149184 matrix :
150- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
185+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
151186 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
152187 variant : ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
153188 logging_scope : ["", "google"]
@@ -185,10 +220,10 @@ jobs:
185220 runs-on : ubuntu-latest
186221 steps :
187222 - uses : actions/checkout@v4
188- - name : Set up Python "3.13"
223+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
189224 uses : actions/setup-python@v5
190225 with :
191- python-version : " 3.13 "
226+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
192227 cache : ' pip'
193228 - name : Install system dependencies.
194229 run : |
@@ -213,10 +248,10 @@ jobs:
213248 variant : ['', _alternative_templates]
214249 steps :
215250 - uses : actions/checkout@v4
216- - name : Set up Python "3.13"
251+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
217252 uses : actions/setup-python@v5
218253 with :
219- python-version : " 3.13 "
254+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
220255 cache : ' pip'
221256 - name : Install system dependencies.
222257 run : |
@@ -235,13 +270,14 @@ jobs:
235270 - name : Typecheck the generated output.
236271 run : nox -s showcase_mypy${{ matrix.variant }}
237272 snippetgen :
273+ needs : all_python_setup
238274 runs-on : ubuntu-latest
239275 steps :
240276 - uses : actions/checkout@v4
241- - name : Set up Python "3.13"
277+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
242278 uses : actions/setup-python@v5
243279 with :
244- python-version : " 3.13 "
280+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
245281 cache : ' pip'
246282 - name : Install system dependencies.
247283 run : |
@@ -252,10 +288,10 @@ jobs:
252288 - name : Check autogenerated snippets.
253289 run : nox -s snippetgen
254290 unit :
291+ needs : all_python_setup
255292 strategy :
256293 matrix :
257- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
258-
294+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
259295 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
260296 # Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
261297 runs-on : ubuntu-22.04
@@ -264,7 +300,7 @@ jobs:
264300 - name : Set up Python ${{ matrix.python }}
265301 uses : actions/setup-python@v5
266302 with :
267- python-version : ${{ matrix.python }}
303+ python-version : " ${{ matrix.python }}"
268304 cache : ' pip'
269305 - name : Install pandoc
270306 run : |
@@ -276,9 +312,10 @@ jobs:
276312 - name : Run unit tests.
277313 run : nox -s unit-${{ matrix.python }}
278314 fragment :
315+ needs : all_python_setup
279316 strategy :
280317 matrix :
281- python : ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
318+ python : ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
282319 variant : ['', _alternative_templates]
283320
284321 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
@@ -289,7 +326,7 @@ jobs:
289326 - name : Set up Python ${{ matrix.python }}
290327 uses : actions/setup-python@v5
291328 with :
292- python-version : ${{ matrix.python }}
329+ python-version : " ${{ matrix.python }}"
293330 cache : ' pip'
294331 - name : Install pandoc
295332 run : |
@@ -333,29 +370,29 @@ jobs:
333370 runs-on : ubuntu-latest
334371 steps :
335372 - uses : actions/checkout@v4
336- - name : Set up Python 3.13
373+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
337374 uses : actions/setup-python@v5
338375 with :
339- python-version : " 3.13 "
376+ python-version : ${{ env.LATEST_STABLE_PYTHON }}
340377 cache : ' pip'
341378 - name : Install nox.
342379 run : |
343380 python -m pip install nox
344381 - name : Run blacken and lint on the generated output.
345382 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
383+ nox -f tests/integration/goldens/asset/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
384+ nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
385+ nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
386+ nox -f tests/integration/goldens/logging/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
387+ nox -f tests/integration/goldens/redis/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
351388 goldens-unit :
352389 runs-on : ubuntu-latest
353390 steps :
354391 - uses : actions/checkout@v4
355- - name : Set up Python 3.13
392+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
356393 uses : actions/setup-python@v5
357394 with :
358- python-version : " 3.13 "
395+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
359396 cache : ' pip'
360397 - name : Install nox.
361398 run : |
@@ -365,18 +402,18 @@ jobs:
365402 # in order to run unit tests
366403 # See https://github.com/googleapis/gapic-generator-python/issues/1806
367404 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
405+ nox -f tests/integration/goldens/credentials/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
406+ nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
407+ nox -f tests/integration/goldens/logging/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
408+ nox -f tests/integration/goldens/redis/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
372409 goldens-prerelease :
373410 runs-on : ubuntu-latest
374411 steps :
375412 - uses : actions/checkout@v4
376- - name : Set up Python 3.13
413+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
377414 uses : actions/setup-python@v5
378415 with :
379- python-version : " 3.13 "
416+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
380417 cache : ' pip'
381418 - name : Install nox.
382419 run : |
@@ -394,10 +431,10 @@ jobs:
394431 runs-on : ubuntu-latest
395432 steps :
396433 - uses : actions/checkout@v4
397- - name : Set up Python "3.13"
434+ - name : Set up Python ${{ env.LATEST_STABLE_PYTHON }}
398435 uses : actions/setup-python@v5
399436 with :
400- python-version : " 3.13 "
437+ python-version : " ${{ env.LATEST_STABLE_PYTHON }} "
401438 cache : ' pip'
402439 - name : Install nox.
403440 run : |
0 commit comments