Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
Merged
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
112 changes: 78 additions & 34 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,40 @@ concurrency:
env:
SHOWCASE_VERSION: 0.35.0
PROTOC_VERSION: 3.20.2
OLDEST_PYTHON: 3.7
LATEST_STABLE_PYTHON: 3.13
PRE_RELEASE_PYTHON: 3.14
ALL_PYTHON: "['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']"

permissions:
contents: read

jobs:
# `all_python_setup` amd `python_config` are a workaround for a known issue where it's not possible to use environment variables outside of `steps`.
# Some jobs set up a text matrix which is outside of `steps` and environment variables can't be used directly.
# This requires a workaround based on the discussion in:
# https://github.com/actions/runner/issues/2372
# The limitation is captured here where certain job configurations don't have access to `env`
# https://docs.github.com/en/enterprise-cloud@latest/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#context-availability
all_python_setup:
runs-on: ubuntu-latest
outputs:
all_python: ${{ env.ALL_PYTHON }}
steps:
- name: Set up all python
id: all_python
run: |
echo 'all_python={{ "${{ env.ALL_PYTHON }}" }}'
python_config:
runs-on: ubuntu-latest
outputs:
oldest_python: ${{ env.OLDEST_PYTHON }}
latest_stable_python: ${{ env.LATEST_STABLE_PYTHON }}
steps:
- name: Print env variables for `python_config`
run: |
echo 'oldest_python={{ "${{ env.OLDEST_PYTHON }}" }}'
echo 'latest_stable_python={{ "${{ env.LATEST_STABLE_PYTHON }}" }}'
docs:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -49,11 +81,15 @@ jobs:
- name: Build the documentation.
run: nox -s docfx
mypy:
needs: all_python_setup
strategy:
matrix:
# Run mypy on all of the supported python versions listed in setup.py
# https://github.com/python/mypy/blob/master/setup.py
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
exclude:
# Remove once https://github.com/googleapis/gapic-generator-python/issues/2303 is fixed
- python: '3.7'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Expand All @@ -62,16 +98,18 @@ jobs:
with:
python-version: "${{ matrix.python }}"
cache: 'pip'
allow-prereleases: true
- name: Install nox.
run: python -m pip install nox
- name: Check type annotations.
run: nox -s mypy-${{ matrix.python }}
showcase:
needs: python_config
strategy:
# Run showcase tests on the lowest and highest supported runtimes
matrix:
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `showcase_w_rest_async` target when async rest is GA.
python: ["3.7", "3.13"]
python: ["${{ needs.python_config.outputs.oldest_python }}", "${{ needs.python_config.outputs.latest_stable_python }}"]
target: [showcase, showcase_w_rest_async]
logging_scope: ["", "google"]

Expand Down Expand Up @@ -126,10 +164,10 @@ jobs:
run: |
sudo mkdir -p /tmp/workspace/tests/cert/
sudo chown -R ${USER} /tmp/workspace/
- name: Set up Python "3.13"
- name: Set up Python ${{ env.LATEST_STABLE_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: "${{ env.LATEST_STABLE_PYTHON }}"
cache: 'pip'
- name: Copy mtls files
run: cp tests/cert/mtls.* /tmp/workspace/tests/cert/
Expand Down Expand Up @@ -160,9 +198,10 @@ jobs:
nox -s ${{ matrix.target }}
# TODO(yon-mg): add compute unit tests
showcase-unit:
needs: all_python_setup
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
variant: ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
logging_scope: ["", "google"]
Expand All @@ -177,6 +216,7 @@ jobs:
with:
python-version: "${{ matrix.python }}"
cache: 'pip'
allow-prereleases: true
- name: Install system dependencies.
run: |
sudo apt-get update
Expand All @@ -200,10 +240,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python "3.13"
- name: Set up Python ${{ env.LATEST_STABLE_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: "${{ env.LATEST_STABLE_PYTHON }}"
cache: 'pip'
- name: Install system dependencies.
run: |
Expand All @@ -228,10 +268,10 @@ jobs:
variant: ['', _alternative_templates]
steps:
- uses: actions/checkout@v5
- name: Set up Python "3.13"
- name: Set up Python ${{ env.LATEST_STABLE_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: "${{ env.LATEST_STABLE_PYTHON }}"
cache: 'pip'
- name: Install system dependencies.
run: |
Expand All @@ -250,13 +290,14 @@ jobs:
- name: Typecheck the generated output.
run: nox -s showcase_mypy${{ matrix.variant }}
snippetgen:
needs: all_python_setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python "3.13"
- name: Set up Python ${{ env.LATEST_STABLE_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: "${{ env.LATEST_STABLE_PYTHON }}"
cache: 'pip'
- name: Install system dependencies.
run: |
Expand All @@ -267,10 +308,10 @@ jobs:
- name: Check autogenerated snippets.
run: nox -s snippetgen
unit:
needs: all_python_setup
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
runs-on: ubuntu-22.04
Expand All @@ -279,8 +320,9 @@ jobs:
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
python-version: "${{ matrix.python }}"
cache: 'pip'
allow-prereleases: true
- name: Install pandoc
run: |
sudo apt-get update
Expand All @@ -291,11 +333,11 @@ jobs:
- name: Run unit tests.
run: nox -s unit-${{ matrix.python }}
fragment:
needs: all_python_setup
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python: ${{ fromJSON(needs.all_python_setup.outputs.all_python) }}
variant: ['', _alternative_templates]

# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
runs-on: ubuntu-22.04
Expand All @@ -304,8 +346,9 @@ jobs:
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
python-version: "${{ matrix.python }}"
cache: 'pip'
allow-prereleases: true
- name: Install pandoc
run: |
sudo apt-get update
Expand Down Expand Up @@ -348,29 +391,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.13
- name: Set up Python ${{ env.LATEST_STABLE_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: ${{ env.LATEST_STABLE_PYTHON }}
cache: 'pip'
- name: Install nox.
run: |
python -m pip install nox
- name: Run blacken and lint on the generated output.
run: |
nox -f tests/integration/goldens/asset/noxfile.py -s mypy-3.13 blacken lint
nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-3.13 blacken lint
nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-3.13 blacken lint
nox -f tests/integration/goldens/logging/noxfile.py -s mypy-3.13 blacken lint
nox -f tests/integration/goldens/redis/noxfile.py -s mypy-3.13 blacken lint
nox -f tests/integration/goldens/asset/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
nox -f tests/integration/goldens/logging/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
nox -f tests/integration/goldens/redis/noxfile.py -s mypy-${{ env.LATEST_STABLE_PYTHON }} blacken lint
goldens-unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.13
- name: Set up Python ${{ env.LATEST_STABLE_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: "${{ env.LATEST_STABLE_PYTHON }}"
cache: 'pip'
- name: Install nox.
run: |
Expand All @@ -380,19 +423,20 @@ jobs:
# in order to run unit tests
# See https://github.com/googleapis/gapic-generator-python/issues/1806
run: |
nox -f tests/integration/goldens/credentials/noxfile.py -s unit-3.13
nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-3.13
nox -f tests/integration/goldens/logging/noxfile.py -s unit-3.13
nox -f tests/integration/goldens/redis/noxfile.py -s unit-3.13
nox -f tests/integration/goldens/credentials/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
nox -f tests/integration/goldens/logging/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
nox -f tests/integration/goldens/redis/noxfile.py -s unit-${{ env.LATEST_STABLE_PYTHON }}
goldens-prerelease:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.13
- name: Set up Python ${{ env.PRE_RELEASE_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: "${{ env.PRE_RELEASE_PYTHON }}"
cache: 'pip'
allow-prereleases: true
- name: Install nox.
run: |
python -m pip install nox
Expand All @@ -409,10 +453,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python "3.13"
- name: Set up Python ${{ env.LATEST_STABLE_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: "${{ env.LATEST_STABLE_PYTHON }}"
cache: 'pip'
- name: Install nox.
run: |
Expand Down
4 changes: 3 additions & 1 deletion gapic/schema/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,11 +935,13 @@ def enforce_valid_library_settings(

# Check to see if selective gapic generation methods are valid.
selective_gapic_errors = {}
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2446):
# Workaround issue in Python 3.14 related to code coverage by adding `# pragma: no branch`
for (
method_name
) in (
library_settings.python_settings.common.selective_gapic_generation.methods
):
): # pragma: no branch
if method_name not in self.all_methods:
selective_gapic_errors[method_name] = "Method does not exist."
elif not method_name.startswith(library_settings.version):
Expand Down
18 changes: 12 additions & 6 deletions gapic/templates/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ ALL_PYTHON = [
"3.11",
"3.12",
"3.13",
"3.14",
]

DEFAULT_PYTHON_VERSION = ALL_PYTHON[-1]
DEFAULT_PYTHON_VERSION = ALL_PYTHON[-2]
PRE_RELEASE_PYTHON = ALL_PYTHON[-1]

CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()

Expand All @@ -51,7 +53,7 @@ UNIT_TEST_DEPENDENCIES: List[str] = []
UNIT_TEST_EXTRAS: List[str] = []
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}

SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ALL_PYTHON
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
"mock",
"pytest",
Expand Down Expand Up @@ -224,15 +226,17 @@ def install_unittest_dependencies(session, *constraints):
def unit(session, protobuf_implementation):
# Install all test dependencies, then install this package in-place.

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"):
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
# Remove this check once support for Protobuf 3.x is dropped.
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13", "3.14"):
session.skip("cpp implementation is not supported in python 3.11+")

constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
install_unittest_dependencies(session, "-c", constraints_path)

# TODO(https://github.com/googleapis/synthtool/issues/1976):
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
# Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
# The 'cpp' implementation requires Protobuf<4.
if protobuf_implementation == "cpp":
Expand Down Expand Up @@ -425,7 +429,7 @@ def docfx(session):
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
@nox.session(python=PRE_RELEASE_PYTHON)
@nox.parametrize(
"protobuf_implementation",
["python", "upb", "cpp"],
Expand All @@ -438,7 +442,9 @@ def prerelease_deps(session, protobuf_implementation):
`pip install --pre <package>`.
"""

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"):
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
# Remove this check once support for Protobuf 3.x is dropped.
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13", "3.14"):
session.skip("cpp implementation is not supported in python 3.11+")

# Install all dependencies
Expand Down
20 changes: 20 additions & 0 deletions gapic/templates/testing/constraints-3.14.txt.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% from '_pypi_packages.j2' import pypi_packages %}
# We use the constraints file for the latest Python version
# (currently this file) to check that the latest
# major versions of dependencies are supported in setup.py.
# List all library dependencies and extras in this file.
# Require the latest major version be installed for each dependency.
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0",
# Then this file should have google-cloud-foo>=1
google-api-core>=2
google-auth>=2
proto-plus>=1
protobuf>=6
{% for package_tuple, package_info in pypi_packages.items() %}
{# Quick check to make sure `package_info.package_name` is not the package being generated so we don't circularly include this package in its own constraints file. #}
{% if api.naming.warehouse_package_name != package_info.package_name %}
{% if api.requires_package(package_tuple) %}
{{ package_info.package_name }}>={{ (package_info.upper_bound.split(".")[0] | int) - 1 }}
{% endif %}
{% endif %}
{% endfor %}
3 changes: 2 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
"3.11",
"3.12",
"3.13",
"3.14",
)

NEWEST_PYTHON = ALL_PYTHON[-1]
NEWEST_PYTHON = ALL_PYTHON[-2]
Comment thread
parthea marked this conversation as resolved.


@nox.session(python=ALL_PYTHON)
Expand Down
Loading
Loading