Skip to content

Commit 3db018a

Browse files
committed
exclude noxfile.py from templates
1 parent 8ff91ac commit 3db018a

File tree

2 files changed

+110
-197
lines changed

2 files changed

+110
-197
lines changed

noxfile.py

Lines changed: 109 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2024 Google LLC
3+
# Copyright 2023 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -162,28 +162,14 @@ def install_unittest_dependencies(session, *constraints):
162162
session.install("-e", ".", *constraints)
163163

164164

165-
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
166-
@nox.parametrize(
167-
"protobuf_implementation",
168-
["python", "upb", "cpp"],
169-
)
170-
def unit(session, protobuf_implementation):
165+
def default(session, tests_path):
171166
# Install all test dependencies, then install this package in-place.
172167

173-
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
174-
session.skip("cpp implementation is not supported in python 3.11+")
175-
176168
constraints_path = str(
177169
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
178170
)
179171
install_unittest_dependencies(session, "-c", constraints_path)
180172

181-
# TODO(https://github.com/googleapis/synthtool/issues/1976):
182-
# Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
183-
# The 'cpp' implementation requires Protobuf<4.
184-
if protobuf_implementation == "cpp":
185-
session.install("protobuf<4")
186-
187173
# Run py.test against the unit tests.
188174
session.run(
189175
"py.test",
@@ -197,12 +183,112 @@ def unit(session, protobuf_implementation):
197183
"--cov-fail-under=0",
198184
tests_path,
199185
*session.posargs,
200-
env={
201-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
202-
},
203186
)
204187

205188

189+
def prerelease(session, tests_path):
190+
constraints_path = str(
191+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
192+
)
193+
194+
# PyArrow prerelease packages are published to an alternative PyPI host.
195+
# https://arrow.apache.org/docs/python/install.html#installing-nightly-packages
196+
session.install(
197+
"--extra-index-url",
198+
"https://pypi.fury.io/arrow-nightlies/",
199+
"--prefer-binary",
200+
"--pre",
201+
"--upgrade",
202+
"pyarrow",
203+
)
204+
# Avoid pandas==2.2.0rc0 as this version causes PyArrow to fail. Once newer
205+
# prerelease comes out, this constraint can be removed. See
206+
# https://github.com/googleapis/python-db-dtypes-pandas/issues/234
207+
session.install(
208+
"--extra-index-url",
209+
"https://pypi.anaconda.org/scipy-wheels-nightly/simple",
210+
"--prefer-binary",
211+
"--pre",
212+
"--upgrade",
213+
"pandas!=2.2.0rc0",
214+
)
215+
session.install(
216+
"mock",
217+
"asyncmock",
218+
"pytest",
219+
"pytest-cov",
220+
"pytest-asyncio",
221+
"-c",
222+
constraints_path,
223+
)
224+
225+
# Because we test minimum dependency versions on the minimum Python
226+
# version, the first version we test with in the unit tests sessions has a
227+
# constraints file containing all dependencies and extras.
228+
with open(
229+
CURRENT_DIRECTORY
230+
/ "testing"
231+
/ f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt",
232+
encoding="utf-8",
233+
) as constraints_file:
234+
constraints_text = constraints_file.read()
235+
236+
# Ignore leading whitespace and comment lines.
237+
deps = [
238+
match.group(1)
239+
for match in re.finditer(
240+
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
241+
)
242+
]
243+
244+
# We use --no-deps to ensure that pre-release versions aren't overwritten
245+
# by the version ranges in setup.py.
246+
session.install(*deps)
247+
session.install("--no-deps", "-e", ".")
248+
249+
# Print out prerelease package versions.
250+
session.run("python", "-m", "pip", "freeze")
251+
252+
# Run py.test against the unit tests.
253+
session.run(
254+
"py.test",
255+
"--quiet",
256+
f"--junitxml={os.path.split(tests_path)[-1]}_prerelease_{session.python}_sponge_log.xml",
257+
"--cov=db_dtypes",
258+
"--cov=tests/unit",
259+
"--cov-append",
260+
"--cov-config=.coveragerc",
261+
"--cov-report=",
262+
"--cov-fail-under=0",
263+
tests_path,
264+
*session.posargs,
265+
)
266+
267+
268+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
269+
def compliance(session):
270+
"""Run the compliance test suite."""
271+
default(session, os.path.join("tests", "compliance"))
272+
273+
274+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
275+
def compliance_prerelease(session):
276+
"""Run the compliance test suite with prerelease dependencies."""
277+
prerelease(session, os.path.join("tests", "compliance"))
278+
279+
280+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
281+
def unit(session):
282+
"""Run the unit test suite."""
283+
default(session, os.path.join("tests", "unit"))
284+
285+
286+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
287+
def unit_prerelease(session):
288+
"""Run the unit test suite with prerelease dependencies."""
289+
prerelease(session, os.path.join("tests", "unit"))
290+
291+
206292
def install_systemtest_dependencies(session, *constraints):
207293
# Use pre-release gRPC for system tests.
208294
# Exclude version 1.52.0rc1 which has a known issue.
@@ -371,16 +457,9 @@ def docfx(session):
371457

372458

373459
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
374-
@nox.parametrize(
375-
"protobuf_implementation",
376-
["python", "upb", "cpp"],
377-
)
378-
def prerelease_deps(session, protobuf_implementation):
460+
def prerelease_deps(session):
379461
"""Run all tests with prerelease versions of dependencies installed."""
380462

381-
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
382-
session.skip("cpp implementation is not supported in python 3.11+")
383-
384463
# Install all dependencies
385464
session.install("-e", ".[all, tests, tracing]")
386465
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
@@ -415,9 +494,9 @@ def prerelease_deps(session, protobuf_implementation):
415494
"protobuf",
416495
# dependency of grpc
417496
"six",
418-
"grpc-google-iam-v1",
419497
"googleapis-common-protos",
420-
"grpcio",
498+
# Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163
499+
"grpcio!=1.52.0rc1",
421500
"grpcio-status",
422501
"google-api-core",
423502
"google-auth",
@@ -443,13 +522,7 @@ def prerelease_deps(session, protobuf_implementation):
443522
session.run("python", "-c", "import grpc; print(grpc.__version__)")
444523
session.run("python", "-c", "import google.auth; print(google.auth.__version__)")
445524

446-
session.run(
447-
"py.test",
448-
"tests/unit",
449-
env={
450-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
451-
},
452-
)
525+
session.run("py.test", "tests/unit")
453526

454527
system_test_path = os.path.join("tests", "system.py")
455528
system_test_folder_path = os.path.join("tests", "system")
@@ -462,9 +535,6 @@ def prerelease_deps(session, protobuf_implementation):
462535
f"--junitxml=system_{session.python}_sponge_log.xml",
463536
system_test_path,
464537
*session.posargs,
465-
env={
466-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
467-
},
468538
)
469539
if os.path.exists(system_test_folder_path):
470540
session.run(
@@ -473,7 +543,4 @@ def prerelease_deps(session, protobuf_implementation):
473543
f"--junitxml=system_{session.python}_sponge_log.xml",
474544
system_test_folder_path,
475545
*session.posargs,
476-
env={
477-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
478-
},
479546
)

owlbot.py

Lines changed: 1 addition & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"pandas": "https://pandas.pydata.org/pandas-docs/stable/"
3535
},
3636
)
37-
s.move(templated_files, excludes=["docs/multiprocessing.rst", "README.rst", ".github/workflows/unittest.yml"])
37+
s.move(templated_files, excludes=["docs/multiprocessing.rst", "README.rst", ".github/workflows/unittest.yml", "noxfile.py"])
3838

3939
# ----------------------------------------------------------------------------
4040
# Fixup files
@@ -44,160 +44,6 @@
4444
[".coveragerc"], "google/cloud/__init__.py", "db_dtypes/requirements.py",
4545
)
4646

47-
s.replace(
48-
["noxfile.py"], r"[\"']google[\"']", '"db_dtypes"',
49-
)
50-
51-
s.replace(
52-
["noxfile.py"], r"import shutil", "import re\nimport shutil",
53-
)
54-
55-
s.replace(
56-
["noxfile.py"], "--cov=google", "--cov=db_dtypes",
57-
)
58-
59-
# There are no system tests for this package.
60-
old_sessions = """
61-
"unit",
62-
"system",
63-
"cover",
64-
"lint",
65-
"""
66-
67-
new_sessions = """
68-
"lint",
69-
"unit",
70-
"unit_prerelease",
71-
"compliance",
72-
"compliance_prerelease",
73-
"cover",
74-
"""
75-
76-
s.replace(["noxfile.py"], old_sessions, new_sessions)
77-
78-
# Add compliance tests.
79-
s.replace(
80-
["noxfile.py"], r"def default\(session\):", "def default(session, tests_path):"
81-
)
82-
s.replace(["noxfile.py"], r'os.path.join\("tests", "unit"\),', "tests_path,")
83-
s.replace(
84-
["noxfile.py"],
85-
r'f"--junitxml=unit_{session.python}_sponge_log.xml",',
86-
r'f"--junitxml={os.path.split(tests_path)[-1]}_{session.python}_sponge_log.xml",',
87-
)
88-
s.replace(
89-
["noxfile.py"],
90-
r'''
91-
@nox.session\(python=UNIT_TEST_PYTHON_VERSIONS\)
92-
def unit\(session\):
93-
"""Run the unit test suite."""
94-
default\(session\)
95-
''',
96-
r'''
97-
def prerelease(session, tests_path):
98-
constraints_path = str(
99-
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
100-
)
101-
102-
# PyArrow prerelease packages are published to an alternative PyPI host.
103-
# https://arrow.apache.org/docs/python/install.html#installing-nightly-packages
104-
session.install(
105-
"--extra-index-url",
106-
"https://pypi.fury.io/arrow-nightlies/",
107-
"--prefer-binary",
108-
"--pre",
109-
"--upgrade",
110-
"pyarrow",
111-
)
112-
# Avoid pandas==2.2.0rc0 as this version causes PyArrow to fail. Once newer
113-
# prerelease comes out, this constraint can be removed. See
114-
# https://github.com/googleapis/python-db-dtypes-pandas/issues/234
115-
session.install(
116-
"--extra-index-url",
117-
"https://pypi.anaconda.org/scipy-wheels-nightly/simple",
118-
"--prefer-binary",
119-
"--pre",
120-
"--upgrade",
121-
"pandas!=2.2.0rc0",
122-
)
123-
session.install(
124-
"mock",
125-
"asyncmock",
126-
"pytest",
127-
"pytest-cov",
128-
"pytest-asyncio",
129-
"-c",
130-
constraints_path,
131-
)
132-
133-
# Because we test minimum dependency versions on the minimum Python
134-
# version, the first version we test with in the unit tests sessions has a
135-
# constraints file containing all dependencies and extras.
136-
with open(
137-
CURRENT_DIRECTORY
138-
/ "testing"
139-
/ f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt",
140-
encoding="utf-8",
141-
) as constraints_file:
142-
constraints_text = constraints_file.read()
143-
144-
# Ignore leading whitespace and comment lines.
145-
deps = [
146-
match.group(1)
147-
for match in re.finditer(
148-
r"^\\s*(\\S+)(?===\\S+)", constraints_text, flags=re.MULTILINE
149-
)
150-
]
151-
152-
# We use --no-deps to ensure that pre-release versions aren't overwritten
153-
# by the version ranges in setup.py.
154-
session.install(*deps)
155-
session.install("--no-deps", "-e", ".")
156-
157-
# Print out prerelease package versions.
158-
session.run("python", "-m", "pip", "freeze")
159-
160-
# Run py.test against the unit tests.
161-
session.run(
162-
"py.test",
163-
"--quiet",
164-
f"--junitxml={os.path.split(tests_path)[-1]}_prerelease_{session.python}_sponge_log.xml",
165-
"--cov=db_dtypes",
166-
"--cov=tests/unit",
167-
"--cov-append",
168-
"--cov-config=.coveragerc",
169-
"--cov-report=",
170-
"--cov-fail-under=0",
171-
tests_path,
172-
*session.posargs,
173-
)
174-
175-
176-
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
177-
def compliance(session):
178-
"""Run the compliance test suite."""
179-
default(session, os.path.join("tests", "compliance"))
180-
181-
182-
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
183-
def compliance_prerelease(session):
184-
"""Run the compliance test suite with prerelease dependencies."""
185-
prerelease(session, os.path.join("tests", "compliance"))
186-
187-
188-
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
189-
def unit(session):
190-
"""Run the unit test suite."""
191-
default(session, os.path.join("tests", "unit"))
192-
193-
194-
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
195-
def unit_prerelease(session):
196-
"""Run the unit test suite with prerelease dependencies."""
197-
prerelease(session, os.path.join("tests", "unit"))
198-
''',
199-
)
200-
20147
# ----------------------------------------------------------------------------
20248
# Samples templates
20349
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)