Skip to content

Commit 4590103

Browse files
chore(python): add license header to auto-label.yaml (#640)
chore: refactor noxfile.py Source-Link: googleapis/synthtool@eb78c98 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 96819e8 commit 4590103

3 files changed

Lines changed: 102 additions & 24 deletions

File tree

packages/google-cloud-pubsub/.github/.OwlBot.lock.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce
17-
# created: 2022-04-01T01:42:03.609279246Z
16+
digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163
17+
# created: 2022-04-06T10:30:21.687684602Z
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
114
requestsize:
215
enabled: true

packages/google-cloud-pubsub/noxfile.py

Lines changed: 87 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,44 @@
2020
import os
2121
import pathlib
2222
import shutil
23+
import warnings
2324

2425
import nox
2526

26-
2727
BLACK_VERSION = "black==22.3.0"
2828
BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
2929

3030
MYPY_VERSION = "mypy==0.910"
3131

3232
DEFAULT_PYTHON_VERSION = "3.8"
33-
SYSTEM_TEST_PYTHON_VERSIONS = ["3.10"]
33+
3434
UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]
35+
UNIT_TEST_STANDARD_DEPENDENCIES = [
36+
"mock",
37+
"asyncmock",
38+
"pytest",
39+
"pytest-cov",
40+
"pytest-asyncio",
41+
]
42+
UNIT_TEST_EXTERNAL_DEPENDENCIES = []
43+
UNIT_TEST_LOCAL_DEPENDENCIES = []
44+
UNIT_TEST_DEPENDENCIES = []
45+
UNIT_TEST_EXTRAS = []
46+
UNIT_TEST_EXTRAS_BY_PYTHON = {}
47+
48+
SYSTEM_TEST_PYTHON_VERSIONS = ["3.10"]
49+
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
50+
"mock",
51+
"pytest",
52+
"google-cloud-testutils",
53+
]
54+
SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [
55+
"psutil",
56+
]
57+
SYSTEM_TEST_LOCAL_DEPENDENCIES = []
58+
SYSTEM_TEST_DEPENDENCIES = []
59+
SYSTEM_TEST_EXTRAS = []
60+
SYSTEM_TEST_EXTRAS_BY_PYTHON = {}
3561

3662
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
3763

@@ -131,23 +157,41 @@ def lint_setup_py(session):
131157
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
132158

133159

160+
def install_unittest_dependencies(session, *constraints):
161+
standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES
162+
session.install(*standard_deps, *constraints)
163+
164+
if UNIT_TEST_EXTERNAL_DEPENDENCIES:
165+
warnings.warn(
166+
"'unit_test_external_dependencies' is deprecated. Instead, please "
167+
"use 'unit_test_dependencies' or 'unit_test_local_dependencies'.",
168+
DeprecationWarning,
169+
)
170+
session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints)
171+
172+
if UNIT_TEST_LOCAL_DEPENDENCIES:
173+
session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints)
174+
175+
if UNIT_TEST_EXTRAS_BY_PYTHON:
176+
extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, [])
177+
elif UNIT_TEST_EXTRAS:
178+
extras = UNIT_TEST_EXTRAS
179+
else:
180+
extras = []
181+
182+
if extras:
183+
session.install("-e", f".[{','.join(extras)}]", *constraints)
184+
else:
185+
session.install("-e", ".", *constraints)
186+
187+
134188
def default(session):
135189
# Install all test dependencies, then install this package in-place.
136190

137191
constraints_path = str(
138192
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
139193
)
140-
session.install(
141-
"mock",
142-
"asyncmock",
143-
"pytest",
144-
"pytest-cov",
145-
"pytest-asyncio",
146-
"-c",
147-
constraints_path,
148-
)
149-
150-
session.install("-e", ".", "-c", constraints_path)
194+
install_unittest_dependencies(session, "-c", constraints_path)
151195

152196
# Run py.test against the unit tests.
153197
session.run(
@@ -171,6 +215,35 @@ def unit(session):
171215
default(session)
172216

173217

218+
def install_systemtest_dependencies(session, *constraints):
219+
220+
# Use pre-release gRPC for system tests.
221+
session.install("--pre", "grpcio")
222+
223+
session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints)
224+
225+
if SYSTEM_TEST_EXTERNAL_DEPENDENCIES:
226+
session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints)
227+
228+
if SYSTEM_TEST_LOCAL_DEPENDENCIES:
229+
session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints)
230+
231+
if SYSTEM_TEST_DEPENDENCIES:
232+
session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints)
233+
234+
if SYSTEM_TEST_EXTRAS_BY_PYTHON:
235+
extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, [])
236+
elif SYSTEM_TEST_EXTRAS:
237+
extras = SYSTEM_TEST_EXTRAS
238+
else:
239+
extras = []
240+
241+
if extras:
242+
session.install("-e", f".[{','.join(extras)}]", *constraints)
243+
else:
244+
session.install("-e", ".", *constraints)
245+
246+
174247
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
175248
def system(session):
176249
"""Run the system test suite."""
@@ -193,15 +266,7 @@ def system(session):
193266
if not system_test_exists and not system_test_folder_exists:
194267
session.skip("System tests were not found")
195268

196-
# Use pre-release gRPC for system tests.
197-
session.install("--pre", "grpcio")
198-
199-
# Install all test dependencies, then install this package into the
200-
# virtualenv's dist-packages.
201-
session.install(
202-
"mock", "pytest", "google-cloud-testutils", "psutil", "-c", constraints_path
203-
)
204-
session.install("-e", ".", "-c", constraints_path)
269+
install_systemtest_dependencies(session, "-c", constraints_path)
205270

206271
# Run py.test against the system tests.
207272
if system_test_exists:

0 commit comments

Comments
 (0)