diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index f654277b..83d80855 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -6,7 +6,31 @@ on: - 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 @@ -14,7 +38,6 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - option: ["", "_grpc_gcp", "_wo_grpc", "_w_prerelease_deps", "_w_async_rest_extra"] python: - "3.7" - "3.8" @@ -24,13 +47,6 @@ jobs: - "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 @@ -45,21 +61,21 @@ jobs: 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 diff --git a/noxfile.py b/noxfile.py index 37ef2caf..9f53dbde 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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) +@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)