From d65b5e4be2148720085e73537aa775e1a456dfc2 Mon Sep 17 00:00:00 2001 From: Josh Radcliff Date: Tue, 24 Nov 2026 17:09:18 +0000 Subject: [PATCH] ci: add test_kokoro nox session and presubmit job --- .github/workflows/presubmit.yaml | 22 +++++++++++++++++++ noxfile.py | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/.github/workflows/presubmit.yaml b/.github/workflows/presubmit.yaml index 6124d48..df9fbc8 100644 --- a/.github/workflows/presubmit.yaml +++ b/.github/workflows/presubmit.yaml @@ -46,3 +46,25 @@ jobs: run: pip install -e .[dev] - name: Run tests run: nox -s tests-${{ matrix.python-version }} + + kokoro: + name: Kokoro Release Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + - name: Lint release script + run: | + bash -n .kokoro/release.sh + shellcheck --severity=warning .kokoro/release.sh + - name: Set up Python + uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7 + with: + python-version: "3.12" + cache: 'pip' + cache-dependency-path: '.kokoro/requirements.txt' + - name: Install nox + run: pip install "nox >= 2026.7.11" + - name: Run Kokoro checks + run: nox -s test_kokoro diff --git a/noxfile.py b/noxfile.py index eea9842..0865958 100644 --- a/noxfile.py +++ b/noxfile.py @@ -101,3 +101,40 @@ def compile_kokoro_requirements(session): ".kokoro/requirements.in", env={"CUSTOM_COMPILE_COMMAND": custom_command}, ) + + +@nox.session(python="3.12") +def test_kokoro(session): + """Verifies .kokoro/requirements.txt, package build, and keyring setup.""" + # Verify hashes and dependency compatibility for pinned release tools. + session.install("--require-hashes", "-r", ".kokoro/requirements.txt") + session.run("python", "-m", "pip", "check") + + # Verify the Python keyring package (from .kokoro/requirements.txt) loads + # the Artifact Registry auth plugin used by twine upload during releases. + session.run("python", "-c", "import keyrings.gauth") + backends = session.run("keyring", "--list-backends", silent=True) + session.log(backends) + if "keyrings.gauth.GooglePythonAuth" not in backends: + session.error("keyrings.gauth.GooglePythonAuth backend not registered") + + # Build sdist and wheel into a temp dir and validate metadata/README + # rendering with the pinned twine package. + tmp_dir = pathlib.Path(session.create_tmp()) + dist_dir = tmp_dir / "dist" + session.run("python", "-m", "build", "--outdir", str(dist_dir)) + session.run("twine", "--version") + session.run("twine", "check", *(str(p) for p in dist_dir.iterdir())) + + # Smoke-test that the built wheel installs and imports cleanly. + smoke_dir = tmp_dir / "smoke-venv" + session.run("python", "-m", "venv", str(smoke_dir)) + smoke_python = str(smoke_dir / "bin" / "python") + wheel = next(dist_dir.glob("*.whl")) + session.run(smoke_python, "-m", "pip", "install", str(wheel), external=True) + session.run( + smoke_python, + "-c", + "import google.ads.datamanager_util", + external=True, + )