Skip to content
Closed
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
60 changes: 0 additions & 60 deletions .github/sync-repo-settings.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/mypy.yml

This file was deleted.

49 changes: 33 additions & 16 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
- main

jobs:
run-unittests:
unit:
name: unit${{ matrix.option }}-${{ matrix.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
# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
runs-on: ubuntu-22.04
strategy:
matrix:
option: ["", "_grpc_gcp", "_wo_grpc", "_w_prerelease_deps", "_w_async_rest_extra"]
python:
- "3.7"
- "3.8"
Expand All @@ -24,13 +23,6 @@
- "3.12"
- "3.13"
- "3.14"
exclude:
- option: "_wo_grpc"
python: 3.7
- option: "_wo_grpc"
python: 3.8
- option: "_wo_grpc"
python: 3.9
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -39,27 +31,52 @@
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
- name: Install nox
- name: Install nox / pytest
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
python -m pip install nox pytest
- name: Run unit tests
env:
COVERAGE_FILE: .coverage${{ matrix.option }}-${{matrix.python }}
COVERAGE_FILE: .coverage-${{matrix.python }}
run: |
nox -s unit${{ matrix.option }}-${{ matrix.python }}
nox -s unit-${{ matrix.python }}
- name: Upload coverage results
uses: actions/upload-artifact@v4
with:
name: coverage-artifact-${{ matrix.option }}-${{ matrix.python }}
path: .coverage${{ matrix.option }}-${{ matrix.python }}
name: coverage-artifact-${{ matrix.python }}
path: .coverage-${{ matrix.python }}
include-hidden-files: true

unit-prerelease:
name: prerelease_deps
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.14"]
option: ["prerelease"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
- name: Run ${{ matrix.option }} tests
env:
COVERAGE_FILE: .coverage${{ matrix.option }}-${{matrix.python }}
run: |
nox -s prerelease_deps

report-coverage:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: cover
runs-on: ubuntu-latest
needs:
- run-unittests
- unit
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
104 changes: 42 additions & 62 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@
# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
nox.options.sessions = [
"unit",
"unit_grpc_gcp",
"unit_wo_grpc",
"unit_w_prerelease_deps",
"unit_w_async_rest_extra",
"prerelease_deps",
"cover",
"pytype",
"mypy",
"lint",
"lint_setup_py",
"blacken",
Expand Down Expand Up @@ -70,6 +65,17 @@ def lint(session):
)
session.run("flake8", "google", "tests")

"""Run type-checking."""
session.install(".[grpc,async_rest]", "mypy")
session.install(
"types-setuptools",
"types-requests",
"types-protobuf",
"types-dataclasses",
"types-mock; python_version=='3.7'",
)
session.run("mypy", "google", "tests")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def blacken(session):
Expand Down Expand Up @@ -215,46 +221,41 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal


@nox.session(python=PYTHON_VERSIONS)
def unit(session):
@nox.parametrize(
["install_grpc_gcp", "install_grpc", "install_async_rest"],
[
(False, True, False), # Run unit tests with grpcio installed
(True, True, False), # Run unit tests with grpcio/grpcio-gcp installed
(False, False, False), # Run unit tests without grpcio installed
(False, True, True), # Run unit tests with grpcio and async rest installed
],
)
def unit(session, install_grpc_gcp, install_grpc, install_async_rest):
"""Run the unit test suite."""
default(session)


@nox.session(python=PYTHON_VERSIONS)
def unit_w_prerelease_deps(session):
"""Run the unit test suite."""
default(session, prerelease=True)


@nox.session(python=PYTHON_VERSIONS)
def unit_grpc_gcp(session):
"""
Run the unit test suite with grpcio-gcp installed.
`grpcio-gcp` doesn't support protobuf 4+.
Remove extra `grpcgcp` when protobuf 3.x is dropped.
https://github.com/googleapis/python-api-core/issues/594
"""
constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
# `grpcio-gcp` doesn't support protobuf 4+.
# Remove extra `grpcgcp` when protobuf 3.x is dropped.
# https://github.com/googleapis/python-api-core/issues/594
if install_grpc_gcp:
constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
# Install grpcio-gcp
session.install("-e", ".[grpcgcp]", "-c", constraints_path)
# Install protobuf < 4.0.0
session.install("protobuf<4.0.0")

default(
session=session,
install_grpc=install_grpc,
install_async_rest=install_async_rest,
)
# Install grpcio-gcp
session.install("-e", ".[grpcgcp]", "-c", constraints_path)
# Install protobuf < 4.0.0
session.install("protobuf<4.0.0")

default(session)


@nox.session(python=PYTHON_VERSIONS)
def unit_wo_grpc(session):
"""Run the unit test suite w/o grpcio installed"""
default(session, install_grpc=False)


@nox.session(python=PYTHON_VERSIONS)
def unit_w_async_rest_extra(session):
"""Run the unit test suite with the `async_rest` extra"""
default(session, install_async_rest=True)
@nox.session(python=DEFAULT_PYTHON_VERSION)
def prerelease_deps(session):
"""Run the unit test suite."""
default(session, prerelease=True)


@nox.session(python=DEFAULT_PYTHON_VERSION)
Expand All @@ -265,27 +266,6 @@ def lint_setup_py(session):
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def pytype(session):
"""Run type-checking."""
session.install(".[grpc]", "pytype")
session.run("pytype")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def mypy(session):
"""Run type-checking."""
session.install(".[grpc,async_rest]", "mypy")
session.install(
"types-setuptools",
"types-requests",
"types-protobuf",
"types-dataclasses",
"types-mock; python_version=='3.7'",
)
session.run("mypy", "google", "tests")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def cover(session):
"""Run the final coverage report.
Expand Down