Skip to content

Commit 3390cf4

Browse files
authored
chore: add core-deps-from-source nox session to assorted packages (#16752)
This PR adds the core_deps_from_source session to bigframes to test against core dependencies installed from source in the monorepo.
1 parent 8495d3f commit 3390cf4

7 files changed

Lines changed: 244 additions & 22 deletions

File tree

packages/bigframes/noxfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
PYTEST_VERSION,
6262
"pytest-cov",
6363
"pytest-timeout",
64+
"pluggy",
6465
]
6566
UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
6667
UNIT_TEST_DEPENDENCIES: List[str] = []

packages/db-dtypes/noxfile.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,49 @@ def docfx(session):
485485

486486

487487
@nox.session(python=DEFAULT_PYTHON_VERSION)
488-
def core_deps_from_source(session):
488+
@nox.parametrize(
489+
"protobuf_implementation",
490+
["python", "upb"],
491+
)
492+
def core_deps_from_source(session, protobuf_implementation):
489493
"""Run all tests with core dependencies installed from source
490494
rather than pulling the dependencies from PyPI.
491495
"""
492-
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
493-
# Add core deps from source tests
494-
session.skip("Core deps from source tests are not yet supported")
496+
constraints_path = str(
497+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
498+
)
499+
install_unittest_dependencies(session, "-c", constraints_path)
500+
501+
core_dependencies_from_source = [
502+
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
503+
"google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core",
504+
"google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth",
505+
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
506+
"proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus",
507+
]
508+
509+
for dep in core_dependencies_from_source:
510+
session.install(dep, "--no-deps", "--ignore-installed")
511+
print(f"Installed {dep}")
512+
513+
tests_path = os.path.join("tests", "unit")
514+
session.run(
515+
"py.test",
516+
"--quiet",
517+
"-W default::FutureWarning",
518+
f"--junitxml=unit_{session.python}_sponge_log.xml",
519+
"--cov=db_dtypes",
520+
"--cov=tests/unit",
521+
"--cov-append",
522+
"--cov-config=.coveragerc",
523+
"--cov-report=",
524+
"--cov-fail-under=0",
525+
tests_path,
526+
*session.posargs,
527+
env={
528+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
529+
},
530+
)
495531

496532

497533
@nox.session(python=DEFAULT_PYTHON_VERSION)

packages/google-cloud-documentai-toolbox/noxfile.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,43 @@ def mypy(session):
509509

510510

511511
@nox.session(python=DEFAULT_PYTHON_VERSION)
512-
def core_deps_from_source(session):
513-
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
514-
# Enable this test once this bug is fixed.
515-
session.skip("Temporarily skip core_deps_from_source. See issue 16014")
512+
@nox.parametrize(
513+
"protobuf_implementation",
514+
["python", "upb"],
515+
)
516+
def core_deps_from_source(session, protobuf_implementation):
517+
"""Run all tests with core dependencies installed from source"""
518+
constraints_path = str(
519+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
520+
)
521+
install_unittest_dependencies(session, "-c", constraints_path)
522+
523+
core_dependencies_from_source = [
524+
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
525+
"google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core",
526+
"google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth",
527+
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
528+
"proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus",
529+
]
530+
531+
for dep in core_dependencies_from_source:
532+
session.install(dep, "--no-deps", "--ignore-installed")
533+
print(f"Installed {dep}")
534+
535+
tests_path = os.path.join("tests", "unit")
536+
session.run(
537+
"py.test",
538+
"--quiet",
539+
f"--junitxml=unit_{session.python}_sponge_log.xml",
540+
"--cov=google",
541+
"--cov=tests/unit",
542+
"--cov-append",
543+
"--cov-config=.coveragerc",
544+
"--cov-report=",
545+
"--cov-fail-under=0",
546+
tests_path,
547+
*session.posargs,
548+
env={
549+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
550+
},
551+
)

packages/google-cloud-ndb/noxfile.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,46 @@ def system_default(session):
444444

445445

446446
@nox.session(python=DEFAULT_INTERPRETER)
447-
def core_deps_from_source(session):
448-
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
449-
# Enable this test once this bug is fixed.
450-
session.skip("Temporarily skip core_deps_from_source. See issue 16014")
447+
@nox.parametrize(
448+
"protobuf_implementation",
449+
["python", "upb"],
450+
)
451+
def core_deps_from_source(session, protobuf_implementation):
452+
"""Run all tests with core dependencies installed from source"""
453+
constraints_path = str(
454+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
455+
)
456+
install_unittest_dependencies(session, "-c", constraints_path)
457+
458+
core_dependencies_from_source = [
459+
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
460+
"google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core",
461+
"google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth",
462+
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
463+
"proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus",
464+
]
465+
466+
for dep in core_dependencies_from_source:
467+
session.install(dep, "--no-deps", "--ignore-installed")
468+
print(f"Installed {dep}")
469+
470+
tests_path = os.path.join("tests", "unit")
471+
session.run(
472+
"py.test",
473+
"--quiet",
474+
f"--junitxml=unit_{session.python}_sponge_log.xml",
475+
"--cov=google",
476+
"--cov=tests/unit",
477+
"--cov-append",
478+
"--cov-config=.coveragerc",
479+
"--cov-report=",
480+
"--cov-fail-under=0",
481+
tests_path,
482+
*session.posargs,
483+
env={
484+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
485+
},
486+
)
451487

452488

453489
@nox.session(python=DEFAULT_INTERPRETER)

packages/pandas-gbq/noxfile.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,47 @@ def mypy(session):
533533

534534

535535
@nox.session(python=DEFAULT_PYTHON_VERSION)
536-
def core_deps_from_source(session):
536+
@nox.parametrize(
537+
"protobuf_implementation",
538+
["python", "upb"],
539+
)
540+
@_calculate_duration
541+
def core_deps_from_source(session, protobuf_implementation):
537542
"""Run all tests with core dependencies installed from source
538543
rather than pulling the dependencies from PyPI.
539544
"""
540-
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
541-
# Add core deps from source tests
542-
session.skip("Core deps from source tests are not yet supported")
545+
constraints_path = str(
546+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
547+
)
548+
install_unittest_dependencies(session, "-c", constraints_path)
549+
550+
core_dependencies_from_source = [
551+
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
552+
"google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core",
553+
"google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth",
554+
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
555+
"proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus",
556+
]
557+
558+
for dep in core_dependencies_from_source:
559+
session.install(dep, "--no-deps", "--ignore-installed")
560+
print(f"Installed {dep}")
561+
562+
tests_path = os.path.join("tests", "unit")
563+
session.run(
564+
"py.test",
565+
"--quiet",
566+
"-W default::PendingDeprecationWarning",
567+
f"--junitxml=unit_{session.python}_sponge_log.xml",
568+
"--cov=pandas_gbq",
569+
"--cov=tests/unit",
570+
"--cov-append",
571+
"--cov-config=.coveragerc",
572+
"--cov-report=",
573+
"--cov-fail-under=0",
574+
tests_path,
575+
*session.posargs,
576+
env={
577+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
578+
},
579+
)

packages/sqlalchemy-bigquery/noxfile.py

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,53 @@ def mypy(session):
697697

698698

699699
@nox.session(python=DEFAULT_PYTHON_VERSION)
700-
def core_deps_from_source(session):
700+
@nox.parametrize(
701+
"protobuf_implementation",
702+
["python", "upb"],
703+
)
704+
@_calculate_duration
705+
def core_deps_from_source(session, protobuf_implementation):
701706
"""Run all tests with core dependencies installed from source
702707
rather than pulling the dependencies from PyPI.
703708
"""
704-
# TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
705-
# Add core deps from source tests
706-
session.skip("Core deps from source tests are not yet supported")
709+
constraints_path = str(
710+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
711+
)
712+
install_unittest_dependencies(session, "-c", constraints_path)
713+
714+
# Mimic unit session install target
715+
if session.python in ["3.11", "3.12", "3.13", "3.14"]:
716+
install_target = ".[geography,alembic,tests,bqstorage]"
717+
else:
718+
install_target = ".[all]"
719+
session.install("-e", install_target, "-c", constraints_path)
720+
721+
core_dependencies_from_source = [
722+
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
723+
"google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core",
724+
"google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth",
725+
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
726+
"proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus",
727+
]
728+
729+
for dep in core_dependencies_from_source:
730+
session.install(dep, "--no-deps", "--ignore-installed")
731+
print(f"Installed {dep}")
732+
733+
tests_path = os.path.join("tests", "unit")
734+
session.run(
735+
"py.test",
736+
"--quiet",
737+
f"--junitxml=unit_{session.python}_sponge_log.xml",
738+
"--cov=sqlalchemy_bigquery",
739+
"--cov=tests/unit",
740+
"--cov-append",
741+
"--cov-config=.coveragerc",
742+
"--cov-report=",
743+
"--cov-fail-under=0",
744+
tests_path,
745+
*session.posargs,
746+
env={
747+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
748+
},
749+
)

packages/sqlalchemy-spanner/noxfile.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,42 @@ def mypy(session):
411411

412412

413413
@nox.session(python=DEFAULT_PYTHON_VERSION)
414-
def core_deps_from_source(session):
414+
@nox.parametrize(
415+
"protobuf_implementation",
416+
["python", "upb"],
417+
)
418+
def core_deps_from_source(session, protobuf_implementation):
415419
"""Run all tests with core dependencies installed from source"""
416-
session.skip("Core deps from source tests are not yet supported")
420+
session.install("setuptools")
421+
session.install("pytest")
422+
session.install("mock")
423+
session.install(".")
424+
session.install("opentelemetry-api")
425+
session.install("opentelemetry-sdk")
426+
session.install("opentelemetry-instrumentation")
427+
428+
core_dependencies_from_source = [
429+
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
430+
"google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core",
431+
"google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth",
432+
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
433+
"proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus",
434+
]
435+
436+
for dep in core_dependencies_from_source:
437+
session.install(dep, "--no-deps", "--ignore-installed")
438+
print(f"Installed {dep}")
439+
440+
tests_path = os.path.join("tests", "unit")
441+
session.run(
442+
"py.test",
443+
"--quiet",
444+
tests_path,
445+
*session.posargs,
446+
env={
447+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
448+
},
449+
)
417450

418451

419452
@nox.session(python=DEFAULT_PYTHON_VERSION)

0 commit comments

Comments
 (0)