-
Notifications
You must be signed in to change notification settings - Fork 69
407 lines (396 loc) · 15.8 KB
/
tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
name: Tests
# Controls when the action will run.
on:
pull_request:
push:
branches: [ $default-branch ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: tests-${{ github.head_ref }}
cancel-in-progress: true
env:
SHOWCASE_VERSION: 0.35.0
PROTOC_VERSION: 3.20.2
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
# Use python 3.10 for docs to match the version for the sphinx plugin
# https://github.com/googleapis/synthtool/pull/1891
with:
python-version: "3.10"
cache: 'pip'
- name: Install nox.
run: python -m pip install nox
- name: Build the documentation.
run: nox -s docs
mypy:
strategy:
matrix:
# Run mypy on all of the supported python versions listed in setup.py
# https://github.com/python/mypy/blob/master/setup.py
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python "${{ matrix.python }}"
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python }}"
cache: 'pip'
- name: Install nox.
run: python -m pip install nox
- name: Check type annotations.
run: nox -s mypy-${{ matrix.python }}
showcase:
strategy:
# Run showcase tests on the lowest and highest supported runtimes
matrix:
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `showcase_w_rest_async` target when async rest is GA.
python: ["3.7", "3.13"]
target: [showcase, showcase_alternative_templates, showcase_w_rest_async]
logging_scope: ["", "google"]
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Python "${{ matrix.python }}"
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python }}"
cache: 'pip'
- name: Install system dependencies.
run: |
sudo apt-get update
sudo apt-get install -y curl pandoc unzip
- name: Install showcase
run: |
sudo mkdir -p /usr/src/showcase
sudo chown -R ${USER} /usr/src/
curl --location https://github.com/googleapis/gapic-showcase/releases/download/v${SHOWCASE_VERSION}/gapic-showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz --output /usr/src/showcase/showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz
cd /usr/src/showcase/
tar -xf showcase-*
./gapic-showcase run &
cd -
- name: Install nox.
run: python -m pip install nox
- name: Install protoc
run: |
sudo mkdir -p /usr/src/protoc/
sudo chown -R ${USER} /usr/src/
curl --location https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc-${PROTOC_VERSION}.zip
cd /usr/src/protoc/
unzip protoc-${PROTOC_VERSION}.zip
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
- name: Run showcase tests.
env:
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2286): Construct nox sessions with logging enabled.
GOOGLE_SDK_PYTHON_LOGGING_SCOPE: ${{ matrix.logging_scope }}
run: nox -s ${{ matrix.target }}-${{ matrix.python }}
showcase-mtls:
if: ${{ false }} # TODO(dovs): reenable when #1218 is fixed
strategy:
matrix:
target: [showcase_mtls, showcase_mtls_alternative_templates]
max-parallel: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup temp directory
run: |
sudo mkdir -p /tmp/workspace/tests/cert/
sudo chown -R ${USER} /tmp/workspace/
- name: Set up Python "3.13"
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Copy mtls files
run: cp tests/cert/mtls.* /tmp/workspace/tests/cert/
- name: Install system dependencies.
run: |
sudo apt-get update
sudo apt-get install -y curl pandoc unzip
- name: Install nox.
run: python -m pip install nox
- name: Install protoc.
run: |
sudo mkdir -p /usr/src/protoc/
sudo chown -R ${USER} /usr/src
curl --location https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc-${PROTOC_VERSION}.zip
cd /usr/src/protoc/
unzip protoc-${PROTOC_VERSION}.zip
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
cd -
- name: Run showcase tests.
run: |
sudo mkdir gapic_showcase
sudo chown ${USER} gapic_showcase
cd gapic_showcase
curl -sSL https://github.com/googleapis/gapic-showcase/releases/download/v${SHOWCASE_VERSION}/gapic-showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz | tar xz
./gapic-showcase run --mtls-ca-cert=/tmp/workspace/tests/cert/mtls.crt --mtls-cert=/tmp/workspace/tests/cert/mtls.crt --mtls-key=/tmp/workspace/tests/cert/mtls.key &
cd ..
nox -s ${{ matrix.target }}
# TODO(yon-mg): add compute unit tests
showcase-unit:
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
variant: ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
logging_scope: ["", "google"]
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Python "${{ matrix.python }}"
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python }}"
cache: 'pip'
- name: Install system dependencies.
run: |
sudo apt-get update
sudo apt-get install -y curl pandoc unzip
- name: Install protoc.
run: |
sudo mkdir -p /usr/src/protoc/
sudo chown -R ${USER} /usr/src/
curl --location https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc-${PROTOC_VERSION}.zip
cd /usr/src/protoc/
unzip protoc-${PROTOC_VERSION}.zip
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
- name: Install nox.
run: python -m pip install nox
- name: Run unit tests.
env:
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2286): Construct nox sessions with logging enabled.
GOOGLE_SDK_PYTHON_LOGGING_SCOPE: ${{ matrix.logging_scope }}
run: nox -s showcase_unit${{ matrix.variant }}-${{ matrix.python }}
showcase-unit-add-iam-methods:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python "3.13"
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Install system dependencies.
run: |
sudo apt-get update
sudo apt-get install -y curl pandoc unzip
- name: Install protoc.
run: |
sudo mkdir -p /usr/src/protoc/
sudo chown -R ${USER} /usr/src/
curl --location https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc-${PROTOC_VERSION}.zip
cd /usr/src/protoc/
unzip protoc-${PROTOC_VERSION}.zip
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
- name: Install nox.
run: python -m pip install nox
- name: Run unit tests.
run: nox -s showcase_unit_add_iam_methods
showcase-mypy:
runs-on: ubuntu-latest
strategy:
matrix:
variant: ['', _alternative_templates]
steps:
- uses: actions/checkout@v4
- name: Set up Python "3.13"
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Install system dependencies.
run: |
sudo apt-get update
sudo apt-get install -y curl pandoc unzip
- name: Install protoc.
run: |
sudo mkdir -p /usr/src/protoc/
sudo chown -R ${USER} /usr/src/
curl --location https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc-${PROTOC_VERSION}.zip
cd /usr/src/protoc/
unzip protoc-${PROTOC_VERSION}.zip
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
- name: Install nox.
run: python -m pip install nox
- name: Typecheck the generated output.
run: nox -s showcase_mypy${{ matrix.variant }}
snippetgen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python "3.13"
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Install system dependencies.
run: |
sudo apt-get update
sudo apt-get install -y curl pandoc unzip
- name: Install nox.
run: python -m pip install nox
- name: Check autogenerated snippets.
run: nox -s snippetgen
unit:
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Install pandoc
run: |
sudo apt-get update
sudo apt-get install -y pandoc gcc git
- name: Install nox.
run: |
python -m pip install nox
- name: Run unit tests.
run: nox -s unit-${{ matrix.python }}
fragment:
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
variant: ['', _alternative_templates]
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Install pandoc
run: |
sudo apt-get update
sudo apt-get install -y pandoc gcc git
- name: Install nox.
run: |
python -m pip install nox
- name: Run fragment tests.
run: nox -s fragment${{ matrix.variant }}-${{ matrix.python }}
integration:
runs-on: ubuntu-latest
container: gcr.io/gapic-images/googleapis
steps:
- uses: actions/checkout@v4
- name: Cache Bazel files
id: cache-bazel
uses: actions/cache@v4
with:
path: ~/.cache/bazel
# Note: if the container is updated, the key needs to be updated as well.
key: ${{ runner.os }}-bazel-20210105-${{ secrets.CACHE_VERSION }}
- name: Cache not found
if: steps.cache-bazel.outputs.cache-hit != 'true'
run: |
echo "No cache found."
- name: Cache found
if: steps.cache-bazel.outputs.cache-hit == 'true'
run: |
echo -n "Cache found. Cache size: "
du -sh ~/.cache/bazel
echo "If the cache seems broken, update the CACHE_VERSION secret in"
echo "https://github.com/googleapis/gapic-generator-python/settings/secrets/actions"
echo "(use any random string, any GUID will work)"
echo "and it will start over with a clean cache."
echo "The old one will disappear after 7 days."
- name: Integration Tests
run: bazelisk test //tests/integration/... --test_output=errors
goldens-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Install nox.
run: |
python -m pip install nox
- name: Run blacken and lint on the generated output.
run: |
nox -f tests/integration/goldens/asset/noxfile.py -s mypy-3.13 blacken lint
nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-3.13 blacken lint
nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-3.13 blacken lint
nox -f tests/integration/goldens/logging/noxfile.py -s mypy-3.13 blacken lint
nox -f tests/integration/goldens/redis/noxfile.py -s mypy-3.13 blacken lint
goldens-unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Install nox.
run: |
python -m pip install nox
- name: Run the `unit` nox session
# Exclude testing for asset which requires dependency google-cloud-org-policy
# in order to run unit tests
# See https://github.com/googleapis/gapic-generator-python/issues/1806
run: |
nox -f tests/integration/goldens/credentials/noxfile.py -s unit-3.13
nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-3.13
nox -f tests/integration/goldens/logging/noxfile.py -s unit-3.13
nox -f tests/integration/goldens/redis/noxfile.py -s unit-3.13
goldens-prerelease:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Install nox.
run: |
python -m pip install nox
- name: Run the prerelease_deps nox session
# Exclude testing for asset which requires dependency google-cloud-org-policy
# in order to run unit tests
# See https://github.com/googleapis/gapic-generator-python/issues/1806
run: |
nox -f tests/integration/goldens/credentials/noxfile.py -s prerelease_deps
nox -f tests/integration/goldens/eventarc/noxfile.py -s prerelease_deps
nox -f tests/integration/goldens/logging/noxfile.py -s prerelease_deps
nox -f tests/integration/goldens/redis/noxfile.py -s prerelease_deps
style-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python "3.13"
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: 'pip'
- name: Install autopep8
run: |
python -m pip install autopep8
- name: Check diff
run: |
find gapic tests -name "*.py" -not -path 'tests/**/goldens/*' | xargs autopep8 --diff --exit-code