Skip to content

Commit 6b1db50

Browse files
committed
add samples testing to noxfile.py
1 parent 6e9ecd9 commit 6b1db50

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

packages/google-cloud-bigquery-storage/noxfile.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,34 @@ def system(session):
335335
*session.posargs,
336336
)
337337

338+
# Maunally added samples tests.
339+
# TODO: remove tests after samples are migrated to https://github.com/GoogleCloudPlatform/python-docs-samples
340+
samples_tests = ["pyarrow", "quickstart", "snippets", "to_dataframe"]
341+
for name in samples_tests:
342+
_run_samples_test(session, name)
343+
344+
345+
# Maunally added samples tests helper function.
346+
# TODO(https://github.com/googleapis/google-cloud-python/issues/14417): remove tests after samples are migrated to https://github.com/GoogleCloudPlatform/python-docs-samples
347+
def _run_samples_test(session, name):
348+
samples_path = os.path.join("samples", name)
349+
samples_requirements_path = os.path.join("samples", name, "requirements.txt")
350+
test_requirements_path = os.path.join("samples", name, "requirements-test.txt")
351+
352+
# Install dependencies.
353+
if os.path.exists(samples_requirements_path):
354+
session.install("-r", samples_requirements_path)
355+
356+
if os.path.exists(test_requirements_path):
357+
session.install("-r", test_requirements_path)
358+
359+
session.run(
360+
"pytest",
361+
f"--junitxml=system_{session.python}_sponge_log.xml",
362+
*session.posargs,
363+
samples_path,
364+
)
365+
338366

339367
@nox.session(python=DEFAULT_PYTHON_VERSION)
340368
def cover(session):

scripts/client-post-processing/bigquery-storage-integration.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,55 @@ replacements:
6262
"unit",
6363
"system-3.13",
6464
count: 1
65+
- paths: [
66+
packages/google-cloud-bigquery-storage/noxfile.py,
67+
]
68+
before: |
69+
if system_test_folder_exists:
70+
\ session.run\(
71+
\ "py.test",
72+
\ "--quiet",
73+
\ f"--junitxml=system_{session.python}_sponge_log.xml",
74+
\ system_test_folder_path,
75+
\ \*session.posargs,
76+
\ \)\n\n
77+
\@nox.session\(python=DEFAULT_PYTHON_VERSION\)
78+
after: |
79+
if system_test_folder_exists:
80+
session.run(
81+
"py.test",
82+
"--quiet",
83+
f"--junitxml=system_{session.python}_sponge_log.xml",
84+
system_test_folder_path,
85+
*session.posargs,
86+
)
87+
88+
# Maunally added samples tests.
89+
# TODO: remove tests after samples are migrated to https://github.com/GoogleCloudPlatform/python-docs-samples
90+
samples_tests = ["pyarrow", "quickstart", "snippets", "to_dataframe"]
91+
for name in samples_tests:
92+
_run_samples_test(session, name)
93+
94+
95+
# Maunally added samples tests helper function.
96+
# TODO(https://github.com/googleapis/google-cloud-python/issues/14417): remove tests after samples are migrated to https://github.com/GoogleCloudPlatform/python-docs-samples
97+
def _run_samples_test(session, name):
98+
samples_path = os.path.join("samples", name)
99+
samples_requirements_path = os.path.join("samples", name, "requirements.txt")
100+
test_requirements_path = os.path.join("samples", name, "requirements-test.txt")
101+
102+
# Install dependencies.
103+
if os.path.exists(samples_requirements_path):
104+
session.install("-r", samples_requirements_path)
105+
106+
if os.path.exists(test_requirements_path):
107+
session.install("-r", test_requirements_path)
108+
109+
session.run(
110+
"pytest",
111+
f"--junitxml=system_{session.python}_sponge_log.xml",
112+
*session.posargs,
113+
samples_path,
114+
)\n\n
115+
@nox.session(python=DEFAULT_PYTHON_VERSION)
116+
count: 1

0 commit comments

Comments
 (0)