Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 2e86878

Browse files
committed
build: clean up github action
1 parent 9310dd9 commit 2e86878

File tree

1 file changed

+55
-32
lines changed

1 file changed

+55
-32
lines changed

.github/workflows/tests.yaml

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,23 @@ concurrency:
1616
env:
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

2025
jobs:
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+
2136
docs:
2237
runs-on: ubuntu-latest
2338
steps:
@@ -34,11 +49,15 @@ jobs:
3449
- name: Build the documentation.
3550
run: nox -s docs
3651
mypy:
52+
needs: all_python_setup
3753
strategy:
3854
matrix:
3955
# Run mypy on all of the supported python versions listed in setup.py
4056
# https://github.com/python/mypy/blob/master/setup.py
41-
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
57+
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
58+
exclude:
59+
# Remove once https://github.com/googleapis/gapic-generator-python/issues/2303 is fixed
60+
- python: 3.7
4261
runs-on: ubuntu-latest
4362
steps:
4463
- uses: actions/checkout@v4
@@ -56,7 +75,7 @@ jobs:
5675
# Run showcase tests on the lowest and highest supported runtimes
5776
matrix:
5877
# 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"]
78+
python: ["${{ OLDEST_PYTHON }}", "${{ LATEST_STABLE_PYTHON }}"]
6079
target: [showcase, showcase_w_rest_async]
6180
logging_scope: ["", "google"]
6281

@@ -111,10 +130,10 @@ jobs:
111130
run: |
112131
sudo mkdir -p /tmp/workspace/tests/cert/
113132
sudo chown -R ${USER} /tmp/workspace/
114-
- name: Set up Python "3.13"
133+
- name: Set up Python ${{ LATEST_STABLE_PYTHON }}
115134
uses: actions/setup-python@v5
116135
with:
117-
python-version: "3.13"
136+
python-version: ${{ LATEST_STABLE_PYTHON }}
118137
cache: 'pip'
119138
- name: Copy mtls files
120139
run: cp tests/cert/mtls.* /tmp/workspace/tests/cert/
@@ -145,9 +164,10 @@ jobs:
145164
nox -s ${{ matrix.target }}
146165
# TODO(yon-mg): add compute unit tests
147166
showcase-unit:
167+
needs: all_python_setup
148168
strategy:
149169
matrix:
150-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
170+
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
151171
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
152172
variant: ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
153173
logging_scope: ["", "google"]
@@ -185,10 +205,10 @@ jobs:
185205
runs-on: ubuntu-latest
186206
steps:
187207
- uses: actions/checkout@v4
188-
- name: Set up Python "3.13"
208+
- name: Set up Python ${{ NEWEST_STABLE_PYTHON }}
189209
uses: actions/setup-python@v5
190210
with:
191-
python-version: "3.13"
211+
python-version: "${{ vars.NEWEST_STABLE_PYTHON }}"
192212
cache: 'pip'
193213
- name: Install system dependencies.
194214
run: |
@@ -213,10 +233,10 @@ jobs:
213233
variant: ['', _alternative_templates]
214234
steps:
215235
- uses: actions/checkout@v4
216-
- name: Set up Python "3.13"
236+
- name: Set up Python ${{ NEWEST_STABLE_PYTHON }}
217237
uses: actions/setup-python@v5
218238
with:
219-
python-version: "3.13"
239+
python-version: "${{ vars.NEWEST_STABLE_PYTHON }}"
220240
cache: 'pip'
221241
- name: Install system dependencies.
222242
run: |
@@ -235,13 +255,14 @@ jobs:
235255
- name: Typecheck the generated output.
236256
run: nox -s showcase_mypy${{ matrix.variant }}
237257
snippetgen:
258+
needs: all_python_setup
238259
runs-on: ubuntu-latest
239260
steps:
240261
- uses: actions/checkout@v4
241-
- name: Set up Python "3.13"
262+
- name: Set up Python ${{ LATEST_STABLE_PYTHON }}
242263
uses: actions/setup-python@v5
243264
with:
244-
python-version: "3.13"
265+
python-version: ${{ LATEST_STABLE_PYTHON }}
245266
cache: 'pip'
246267
- name: Install system dependencies.
247268
run: |
@@ -252,10 +273,10 @@ jobs:
252273
- name: Check autogenerated snippets.
253274
run: nox -s snippetgen
254275
unit:
276+
needs: all_python_setup
255277
strategy:
256278
matrix:
257-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
258-
279+
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
259280
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
260281
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
261282
runs-on: ubuntu-22.04
@@ -264,7 +285,7 @@ jobs:
264285
- name: Set up Python ${{ matrix.python }}
265286
uses: actions/setup-python@v5
266287
with:
267-
python-version: ${{ matrix.python }}
288+
python-version: "${{ matrix.python }}"
268289
cache: 'pip'
269290
- name: Install pandoc
270291
run: |
@@ -276,9 +297,10 @@ jobs:
276297
- name: Run unit tests.
277298
run: nox -s unit-${{ matrix.python }}
278299
fragment:
300+
needs: all_python_setup
279301
strategy:
280302
matrix:
281-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
303+
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
282304
variant: ['', _alternative_templates]
283305

284306
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
@@ -333,29 +355,30 @@ jobs:
333355
runs-on: ubuntu-latest
334356
steps:
335357
- uses: actions/checkout@v4
336-
- name: Set up Python 3.13
358+
- name: Set up Python ${{ LATEST_STABLE_PYTHON }}[-1]
337359
uses: actions/setup-python@v5
338360
with:
339-
python-version: "3.13"
361+
python-version: ${{ LATEST_STABLE_PYTHON }}[-1]
340362
cache: 'pip'
341363
- name: Install nox.
342364
run: |
343365
python -m pip install nox
344366
- name: Run blacken and lint on the generated output.
345367
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
368+
nox -f tests/integration/goldens/asset/noxfile.py -s mypy-${{ LATEST_STABLE_PYTHON }} blacken lint
369+
nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-${{ LATEST_STABLE_PYTHON }} blacken lint
370+
nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-${{ LATEST_STABLE_PYTHON }} blacken lint
371+
nox -f tests/integration/goldens/logging/noxfile.py -s mypy-${{ LATEST_STABLE_PYTHON }} blacken lint
372+
nox -f tests/integration/goldens/redis/noxfile.py -s mypy-${{ LATEST_STABLE_PYTHON }} blacken lint
351373
goldens-unit:
374+
needs: all_python_setup
352375
runs-on: ubuntu-latest
353376
steps:
354377
- uses: actions/checkout@v4
355-
- name: Set up Python 3.13
378+
- name: Set up Python ${{ LATEST_STABLE_PYTHON }}
356379
uses: actions/setup-python@v5
357380
with:
358-
python-version: "3.13"
381+
python-version: ${{ LATEST_STABLE_PYTHON }}
359382
cache: 'pip'
360383
- name: Install nox.
361384
run: |
@@ -365,18 +388,18 @@ jobs:
365388
# in order to run unit tests
366389
# See https://github.com/googleapis/gapic-generator-python/issues/1806
367390
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
391+
nox -f tests/integration/goldens/credentials/noxfile.py -s unit-${{ LATEST_STABLE_PYTHON }}
392+
nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-${{ LATEST_STABLE_PYTHON }}
393+
nox -f tests/integration/goldens/logging/noxfile.py -s unit-${{ LATEST_STABLE_PYTHON }}
394+
nox -f tests/integration/goldens/redis/noxfile.py -s unit-${{ LATEST_STABLE_PYTHON }}
372395
goldens-prerelease:
373396
runs-on: ubuntu-latest
374397
steps:
375398
- uses: actions/checkout@v4
376-
- name: Set up Python 3.13
399+
- name: Set up Python ${{ LATEST_STABLE_PYTHON }}
377400
uses: actions/setup-python@v5
378401
with:
379-
python-version: "3.13"
402+
python-version: ${{ LATEST_STABLE_PYTHON }}
380403
cache: 'pip'
381404
- name: Install nox.
382405
run: |
@@ -394,10 +417,10 @@ jobs:
394417
runs-on: ubuntu-latest
395418
steps:
396419
- uses: actions/checkout@v4
397-
- name: Set up Python "3.13"
420+
- name: Set up Python ${{ LATEST_STABLE_PYTHON }}
398421
uses: actions/setup-python@v5
399422
with:
400-
python-version: "3.13"
423+
python-version: ${{ LATEST_STABLE_PYTHON }}
401424
cache: 'pip'
402425
- name: Install nox.
403426
run: |

0 commit comments

Comments
 (0)