Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +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 <https://github.com/googleapis/google-cloud-python/issues>). 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!

185 changes: 173 additions & 12 deletions packages/google-auth/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import os
import pathlib
import re
import shutil

import nox
Expand All @@ -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",
Expand All @@ -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

Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -220,23 +245,159 @@ 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 <package>`.
"""
# 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:
Comment on lines +272 to +275
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the core_deps_from_source session and to avoid using the ALL_PYTHON copy, use UNIT_TEST_PYTHON_VERSIONS[0] when referencing the constraints file.

    with open(
        CURRENT_DIRECTORY / 

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,
},
)
Loading