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

Commit a07d3e1

Browse files
committed
wip
1 parent 9310dd9 commit a07d3e1

1 file changed

Lines changed: 60 additions & 32 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ env:
1818
PROTOC_VERSION: 3.20.2
1919

2020
jobs:
21+
all_python_setup:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
all_python: ${{ steps.all_python_setup.outputs.all_python }}
25+
steps:
26+
- name: Set up all python
27+
id: all_python
28+
run: |
29+
echo 'all_python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]' >> $GITHUB_OUTPUT
2130
docs:
2231
runs-on: ubuntu-latest
2332
steps:
@@ -34,11 +43,15 @@ jobs:
3443
- name: Build the documentation.
3544
run: nox -s docs
3645
mypy:
46+
needs: all_python_setup
3747
strategy:
3848
matrix:
3949
# Run mypy on all of the supported python versions listed in setup.py
4050
# https://github.com/python/mypy/blob/master/setup.py
41-
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
51+
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
52+
exclude:
53+
# Remove once https://github.com/googleapis/gapic-generator-python/issues/2303 is fixed
54+
- python: 3.7
4255
runs-on: ubuntu-latest
4356
steps:
4457
- uses: actions/checkout@v4
@@ -52,11 +65,12 @@ jobs:
5265
- name: Check type annotations.
5366
run: nox -s mypy-${{ matrix.python }}
5467
showcase:
68+
needs: all_python_setup
5569
strategy:
5670
# Run showcase tests on the lowest and highest supported runtimes
5771
matrix:
5872
# 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"]
73+
python: ["${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[0]", "${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]"]
6074
target: [showcase, showcase_w_rest_async]
6175
logging_scope: ["", "google"]
6276

@@ -100,6 +114,7 @@ jobs:
100114
run: nox -s ${{ matrix.target }}-${{ matrix.python }}
101115
showcase-mtls:
102116
if: ${{ false }} # TODO(dovs): reenable when #1218 is fixed
117+
needs: all_python_setup
103118
strategy:
104119
matrix:
105120
target: [showcase_mtls]
@@ -111,10 +126,10 @@ jobs:
111126
run: |
112127
sudo mkdir -p /tmp/workspace/tests/cert/
113128
sudo chown -R ${USER} /tmp/workspace/
114-
- name: Set up Python "3.13"
129+
- name: Set up Python ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
115130
uses: actions/setup-python@v5
116131
with:
117-
python-version: "3.13"
132+
python-version: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
118133
cache: 'pip'
119134
- name: Copy mtls files
120135
run: cp tests/cert/mtls.* /tmp/workspace/tests/cert/
@@ -145,9 +160,10 @@ jobs:
145160
nox -s ${{ matrix.target }}
146161
# TODO(yon-mg): add compute unit tests
147162
showcase-unit:
163+
needs: all_python_setup
148164
strategy:
149165
matrix:
150-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
166+
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
151167
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
152168
variant: ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
153169
logging_scope: ["", "google"]
@@ -182,13 +198,14 @@ jobs:
182198
GOOGLE_SDK_PYTHON_LOGGING_SCOPE: ${{ matrix.logging_scope }}
183199
run: nox -s showcase_unit${{ matrix.variant }}-${{ matrix.python }}
184200
showcase-unit-add-iam-methods:
201+
needs: all_python_setup
185202
runs-on: ubuntu-latest
186203
steps:
187204
- uses: actions/checkout@v4
188-
- name: Set up Python "3.13"
205+
- name: Set up Python ${{ vars.NEWEST_STABLE_PYTHON }}
189206
uses: actions/setup-python@v5
190207
with:
191-
python-version: "3.13"
208+
python-version: "${{ vars.NEWEST_STABLE_PYTHON }}"
192209
cache: 'pip'
193210
- name: Install system dependencies.
194211
run: |
@@ -207,16 +224,21 @@ jobs:
207224
- name: Run unit tests.
208225
run: nox -s showcase_unit_add_iam_methods
209226
showcase-mypy:
227+
needs: all_python_setup
210228
runs-on: ubuntu-latest
211229
strategy:
212230
matrix:
213231
variant: ['', _alternative_templates]
214232
steps:
215233
- uses: actions/checkout@v4
216-
- name: Set up Python "3.13"
234+
- name: Set env
235+
run: |
236+
export PYTHON_NEWEST_VERSION=$(echo '${{ needs.all_python_setup.outputs.all_python }}' | jq -Rc 'split(",")'[-1])
237+
echo "PYTHON_NEWEST_VERSION=${PYTHON_NEWEST_VERSION}" >> $GITHUB_ENV
238+
- name: Set up Newest Stable Python
217239
uses: actions/setup-python@v5
218240
with:
219-
python-version: "3.13"
241+
python-version: ${{ env.PYTHON_NEWEST_VERSION }}
220242
cache: 'pip'
221243
- name: Install system dependencies.
222244
run: |
@@ -235,13 +257,14 @@ jobs:
235257
- name: Typecheck the generated output.
236258
run: nox -s showcase_mypy${{ matrix.variant }}
237259
snippetgen:
260+
needs: all_python_setup
238261
runs-on: ubuntu-latest
239262
steps:
240263
- uses: actions/checkout@v4
241-
- name: Set up Python "3.13"
264+
- name: Set up Python ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
242265
uses: actions/setup-python@v5
243266
with:
244-
python-version: "3.13"
267+
python-version: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
245268
cache: 'pip'
246269
- name: Install system dependencies.
247270
run: |
@@ -252,10 +275,10 @@ jobs:
252275
- name: Check autogenerated snippets.
253276
run: nox -s snippetgen
254277
unit:
278+
needs: all_python_setup
255279
strategy:
256280
matrix:
257-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
258-
281+
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
259282
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
260283
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
261284
runs-on: ubuntu-22.04
@@ -264,7 +287,7 @@ jobs:
264287
- name: Set up Python ${{ matrix.python }}
265288
uses: actions/setup-python@v5
266289
with:
267-
python-version: ${{ matrix.python }}
290+
python-version: "${{ matrix.python }}"
268291
cache: 'pip'
269292
- name: Install pandoc
270293
run: |
@@ -276,9 +299,10 @@ jobs:
276299
- name: Run unit tests.
277300
run: nox -s unit-${{ matrix.python }}
278301
fragment:
302+
needs: all_python_setup
279303
strategy:
280304
matrix:
281-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
305+
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
282306
variant: ['', _alternative_templates]
283307

284308
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
@@ -330,32 +354,34 @@ jobs:
330354
run: bazelisk test //tests/integration/... --test_output=errors
331355

332356
goldens-lint:
357+
needs: all_python_setup
333358
runs-on: ubuntu-latest
334359
steps:
335360
- uses: actions/checkout@v4
336-
- name: Set up Python 3.13
361+
- name: Set up Python ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
337362
uses: actions/setup-python@v5
338363
with:
339-
python-version: "3.13"
364+
python-version: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
340365
cache: 'pip'
341366
- name: Install nox.
342367
run: |
343368
python -m pip install nox
344369
- name: Run blacken and lint on the generated output.
345370
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
371+
nox -f tests/integration/goldens/asset/noxfile.py -s mypy-${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1] blacken lint
372+
nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1] blacken lint
373+
nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1] blacken lint
374+
nox -f tests/integration/goldens/logging/noxfile.py -s mypy-${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1] blacken lint
375+
nox -f tests/integration/goldens/redis/noxfile.py -s mypy-${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1] blacken lint
351376
goldens-unit:
377+
needs: all_python_setup
352378
runs-on: ubuntu-latest
353379
steps:
354380
- uses: actions/checkout@v4
355-
- name: Set up Python 3.13
381+
- name: Set up Python ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
356382
uses: actions/setup-python@v5
357383
with:
358-
python-version: "3.13"
384+
python-version: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
359385
cache: 'pip'
360386
- name: Install nox.
361387
run: |
@@ -365,18 +391,19 @@ jobs:
365391
# in order to run unit tests
366392
# See https://github.com/googleapis/gapic-generator-python/issues/1806
367393
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
394+
nox -f tests/integration/goldens/credentials/noxfile.py -s unit-${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
395+
nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
396+
nox -f tests/integration/goldens/logging/noxfile.py -s unit-${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
397+
nox -f tests/integration/goldens/redis/noxfile.py -s unit-${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
372398
goldens-prerelease:
399+
needs: all_python_setup
373400
runs-on: ubuntu-latest
374401
steps:
375402
- uses: actions/checkout@v4
376-
- name: Set up Python 3.13
403+
- name: Set up Python ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
377404
uses: actions/setup-python@v5
378405
with:
379-
python-version: "3.13"
406+
python-version: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
380407
cache: 'pip'
381408
- name: Install nox.
382409
run: |
@@ -391,13 +418,14 @@ jobs:
391418
nox -f tests/integration/goldens/logging/noxfile.py -s prerelease_deps
392419
nox -f tests/integration/goldens/redis/noxfile.py -s prerelease_deps
393420
lint:
421+
needs: all_python_setup
394422
runs-on: ubuntu-latest
395423
steps:
396424
- uses: actions/checkout@v4
397-
- name: Set up Python "3.13"
425+
- name: Set up Python ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
398426
uses: actions/setup-python@v5
399427
with:
400-
python-version: "3.13"
428+
python-version: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}[-1]
401429
cache: 'pip'
402430
- name: Install nox.
403431
run: |

0 commit comments

Comments
 (0)