Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
44 changes: 30 additions & 14 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,38 @@
- main

jobs:
run-unittests:
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
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 +47,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 @@ -45,21 +61,21 @@
python -m pip install nox
- 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

report-coverage:
name: cover
runs-on: ubuntu-latest
needs:
- run-unittests
- unit
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
63 changes: 29 additions & 34 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,46 +215,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)
def prerelease_deps(session):
"""Run the unit test suite."""
default(session, prerelease=True)


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