From 47f3a42bd8802d30c147a875ddb2346e33bed102 Mon Sep 17 00:00:00 2001 From: Heba Alazzeh Date: Thu, 21 May 2026 23:39:59 +0000 Subject: [PATCH 1/4] test --- SUPPORT.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SUPPORT.md b/SUPPORT.md index 13c64a683c75..29cbc9bc2392 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -57,3 +57,4 @@ Consider using [Google Cloud Customer Care](https://cloud.google.com/support/?hl 1. Search for issues already opened (in this repository, those would be in ). If you find your problem already filed, just add any more context or details that seem appropriate. 2. If your problem has not been previously filed, file an issue. If you're filing in this repository, choose either the [bug report](https://github.com/googleapis/google-cloud-python/issues/new?template=bug_report.yaml) or [feature request](https://github.com/googleapis/google-cloud-python/issues/new?template=feature_request.yaml) template, fill in the details, and submit the issue with an informative title! + From f1680c2d1ae44f0f6d577e8c5b13e3a45b4627dd Mon Sep 17 00:00:00 2001 From: Heba Alazzeh Date: Wed, 27 May 2026 01:10:43 +0000 Subject: [PATCH 2/4] chore: add core_deps and prerelease_deps nox sessions --- packages/google-auth/noxfile.py | 184 +++++++++++++++++++++++++++++--- 1 file changed, 172 insertions(+), 12 deletions(-) diff --git a/packages/google-auth/noxfile.py b/packages/google-auth/noxfile.py index 70c113a98014..333d73b5571c 100644 --- a/packages/google-auth/noxfile.py +++ b/packages/google-auth/noxfile.py @@ -14,6 +14,7 @@ import os import pathlib +import re import shutil import nox @@ -33,6 +34,12 @@ ] DEFAULT_PYTHON_VERSION = "3.14" + +# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450): +# Switch this to Python 3.15 alpha1 +# https://peps.python.org/pep-0790/ +PREVIEW_PYTHON_VERSION = "3.14" + UNIT_TEST_PYTHON_VERSIONS = [ "3.10", "3.11", @@ -42,6 +49,24 @@ ] ALL_PYTHON = UNIT_TEST_PYTHON_VERSIONS.copy() +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES: list[str] = [] + +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES: list[str] = [] +SYSTEM_TEST_EXTRAS: list[str] = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON: dict[str, list[str]] = {} + # Error if a python version is missing nox.options.error_on_missing_interpreters = True @@ -111,7 +136,7 @@ def format(session): "--select", "I", "--fix", - f"--target-version=py{ALL_PYTHON[0].replace('.', '')}", + f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}", "--line-length=88", *BLACK_PATHS, ) @@ -143,7 +168,7 @@ def mypy(session): session.run("mypy", "-p", "google", "-p", "tests", "-p", "tests_async") -@nox.session(python=ALL_PYTHON) +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) @nox.parametrize(["install_deprecated_extras"], (True, False)) def unit(session, install_deprecated_extras): # Install all test dependencies, then install this package in-place. @@ -220,23 +245,158 @@ def docfx(session): session.skip("This package does not have documentation in cloud.google.com") -@nox.session(python=DEFAULT_PYTHON_VERSION) -def prerelease_deps(session): - """Run all tests with pre-release versions of dependencies installed + +@nox.session(python=PREVIEW_PYTHON_VERSION) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb"], +) +def prerelease_deps(session, protobuf_implementation): + """ + Run all tests with pre-release versions of dependencies installed rather than the standard non pre-release versions. Pre-release versions can be installed using `pip install --pre `. """ - # TODO(https://github.com/googleapis/google-cloud-python/issues/16013): - # Add prerelease tests - session.skip("Prerelease tests are not yet supported") + + # Install all dependencies + session.install("-e", ".[testing,rsa]") + session.install("oauth2client") + + # Install dependencies for the unit test environment + unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES + session.install(*unit_deps_all) + + # Because we test minimum dependency versions on the minimum Python + # version, the first version we test with in the unit tests sessions has a + # constraints file containing all dependencies and extras. + with open( + CURRENT_DIRECTORY / "testing" / f"constraints-{ALL_PYTHON[0]}.txt", + encoding="utf-8", + ) as constraints_file: + constraints_text = constraints_file.read() + + # Ignore leading whitespace and comment lines. + constraints_deps = [ + match.group(1) + for match in re.finditer( + r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE + ) + ] + + # Install dependencies specified in `testing/constraints-X.txt`. + session.install(*constraints_deps) + + # Note: If a dependency is added to the `prerel_deps` list, + # the `core_dependencies_from_source` list in the `core_deps_from_source` + # nox session should also be updated. + prerel_deps = [ + "googleapis-common-protos", + "google-api-core", + "google-auth", + "grpc-google-iam-v1", + "grpcio>=1.75.1" if session.python >= "3.12" else "grpcio<=1.62.2", + "grpcio-status", + "protobuf", + "proto-plus", + ] + + for dep in prerel_deps: + session.install("--pre", "--no-deps", "--ignore-installed", dep) + # TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status`` + # to the dictionary below once this bug is fixed. + # TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add + # `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below + # once this bug is fixed. + package_namespaces = { + "google-api-core": "google.api_core", + "google-auth": "google.auth", + "grpcio": "grpc", + "protobuf": "google.protobuf", + "proto-plus": "proto", + } + + version_namespace = package_namespaces.get(dep) + + print(f"Installed {dep}") + if version_namespace: + session.run( + "python", + "-c", + f"import {version_namespace}; print({version_namespace}.__version__)", + ) + + session.run( + "py.test", + "tests", + "tests_async", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) @nox.session(python=DEFAULT_PYTHON_VERSION) -def core_deps_from_source(session): +@nox.parametrize( + "protobuf_implementation", + ["python", "upb"], +) +def core_deps_from_source(session, protobuf_implementation): """Run all tests with core dependencies installed from source rather than pulling the dependencies from PyPI. """ - # TODO(https://github.com/googleapis/google-cloud-python/issues/16013): - # Add prerelease tests - session.skip("Prerelease tests are not yet supported") + + # Install all dependencies + session.install("-e", ".[testing,rsa]") + session.install("oauth2client") + + # Install dependencies for the unit test environment + unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES + session.install(*unit_deps_all) + + # Because we test minimum dependency versions on the minimum Python + # version, the first version we test with in the unit tests sessions has a + # constraints file containing all dependencies and extras. + with open( + CURRENT_DIRECTORY / "testing" / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", + encoding="utf-8", + ) as constraints_file: + constraints_text = constraints_file.read() + + # Ignore leading whitespace and comment lines. + constraints_deps = [ + match.group(1) + for match in re.finditer( + r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE + ) + ] + + # Install dependencies specified in `testing/constraints-X.txt`. + session.install(*constraints_deps) + + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2358): `grpcio` and + # `grpcio-status` should be added to the list below so that they are installed from source, + # rather than PyPI. + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2357): `protobuf` should be + # added to the list below so that it is installed from source, rather than PyPI + # Note: If a dependency is added to the `core_dependencies_from_source` list, + # the `prerel_deps` list in the `prerelease_deps` nox session should also be updated. + core_dependencies_from_source = [ + "googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos", + "google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core", + "grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1", + "proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus", + ] + + for dep in core_dependencies_from_source: + session.install(dep, "--no-deps", "--ignore-installed") + print(f"Installed {dep}") + + session.run( + "py.test", + "tests", + "tests_async", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) From 91b1724d1250521e8bc0c523fc80d988a897cd4d Mon Sep 17 00:00:00 2001 From: Heba Alazzeh Date: Wed, 27 May 2026 01:21:36 +0000 Subject: [PATCH 3/4] fix lint issues --- packages/google-auth/noxfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/google-auth/noxfile.py b/packages/google-auth/noxfile.py index 333d73b5571c..dd9bf1395b8b 100644 --- a/packages/google-auth/noxfile.py +++ b/packages/google-auth/noxfile.py @@ -245,7 +245,6 @@ def docfx(session): session.skip("This package does not have documentation in cloud.google.com") - @nox.session(python=PREVIEW_PYTHON_VERSION) @nox.parametrize( "protobuf_implementation", @@ -358,7 +357,9 @@ def core_deps_from_source(session, protobuf_implementation): # version, the first version we test with in the unit tests sessions has a # constraints file containing all dependencies and extras. with open( - CURRENT_DIRECTORY / "testing" / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", + CURRENT_DIRECTORY + / "testing" + / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", encoding="utf-8", ) as constraints_file: constraints_text = constraints_file.read() From c12f687987fa85dbad219eea1443b98eefd3471d Mon Sep 17 00:00:00 2001 From: Heba Alazzeh Date: Thu, 28 May 2026 23:24:31 +0000 Subject: [PATCH 4/4] Update SUPPORT.md --- SUPPORT.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/SUPPORT.md b/SUPPORT.md index 29cbc9bc2392..3cedbc31c82f 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -56,5 +56,3 @@ Consider using [Google Cloud Customer Care](https://cloud.google.com/support/?hl - Go to the correct repository, as identified above 1. Search for issues already opened (in this repository, those would be in ). If you find your problem already filed, just add any more context or details that seem appropriate. 2. If your problem has not been previously filed, file an issue. If you're filing in this repository, choose either the [bug report](https://github.com/googleapis/google-cloud-python/issues/new?template=bug_report.yaml) or [feature request](https://github.com/googleapis/google-cloud-python/issues/new?template=feature_request.yaml) template, fill in the details, and submit the issue with an informative title! - -