diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml deleted file mode 100644 index b724bada..00000000 --- a/.github/sync-repo-settings.yaml +++ /dev/null @@ -1,60 +0,0 @@ -# https://github.com/googleapis/repo-automation-bots/tree/main/packages/sync-repo-settings -# Rules for main branch protection -branchProtectionRules: -# Identifies the protection rule pattern. Name of the branch to be protected. -# Defaults to `main` -- pattern: main - requiresCodeOwnerReviews: true - requiresStrictStatusChecks: true - requiredStatusCheckContexts: - - 'cla/google' - # No Kokoro: the following are Github actions - - 'lint' - - 'mypy' - - 'unit_grpc_gcp-3.7' - - 'unit_grpc_gcp-3.8' - - 'unit_grpc_gcp-3.9' - - 'unit_grpc_gcp-3.10' - - 'unit_grpc_gcp-3.11' - - 'unit_grpc_gcp-3.12' - - 'unit_grpc_gcp-3.13' - - 'unit_grpc_gcp-3.14' - - 'unit-3.7' - - 'unit-3.8' - - 'unit-3.9' - - 'unit-3.10' - - 'unit-3.11' - - 'unit-3.12' - - 'unit-3.13' - - 'unit-3.14' - - 'unit_wo_grpc-3.10' - - 'unit_wo_grpc-3.11' - - 'unit_wo_grpc-3.12' - - 'unit_wo_grpc-3.13' - - 'unit_wo_grpc-3.14' - - 'unit_w_prerelease_deps-3.7' - - 'unit_w_prerelease_deps-3.8' - - 'unit_w_prerelease_deps-3.9' - - 'unit_w_prerelease_deps-3.10' - - 'unit_w_prerelease_deps-3.11' - - 'unit_w_prerelease_deps-3.12' - - 'unit_w_prerelease_deps-3.13' - - 'unit_w_prerelease_deps-3.14' - - 'unit_w_async_rest_extra-3.7' - - 'unit_w_async_rest_extra-3.8' - - 'unit_w_async_rest_extra-3.9' - - 'unit_w_async_rest_extra-3.10' - - 'unit_w_async_rest_extra-3.11' - - 'unit_w_async_rest_extra-3.12' - - 'unit_w_async_rest_extra-3.13' - - 'unit_w_async_rest_extra-3.14' - - 'cover' - - 'docs' - - 'docfx' -permissionRules: - - team: actools-python - permission: admin - - team: actools - permission: admin - - team: yoshi-python - permission: push diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml deleted file mode 100644 index 8363e721..00000000 --- a/.github/workflows/mypy.yml +++ /dev/null @@ -1,22 +0,0 @@ -on: - pull_request: - branches: - - main -name: mypy -jobs: - mypy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.14" - - name: Install nox - run: | - python -m pip install --upgrade setuptools pip wheel - python -m pip install nox - - name: Run mypy - run: | - nox -s mypy diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index f654277b..ce988835 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -6,7 +6,7 @@ on: - 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 @@ -14,7 +14,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 +23,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 @@ -39,27 +31,52 @@ jobs: 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: 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..868ddf81 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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", @@ -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): @@ -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) @@ -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.