Skip to content
Open
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
22 changes: 22 additions & 0 deletions .github/workflows/presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder: After merging, add this to the list of checks that must pass before a PR can be merged

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
37 changes: 37 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Loading