Update breaking-change-detector.yml

This commit is contained in:
sasha-gitg
2026-01-12 16:57:30 -05:00
committed by GitHub
parent e5e15a807e
commit 313b042b69
+13 -13
View File
@@ -14,7 +14,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for griffe.load_git to access main branch history
fetch-depth: 0 # Required for griffe.load_git to access 'main' history
- name: Set up Python
uses: actions/setup-python@v5
@@ -25,42 +25,42 @@ jobs:
uses: astral-sh/setup-uv@v5
- name: Install dependencies
# Syncing extras (like test) ensures 'google-auth' and other 'google.*'
# namespaces are populated, preventing ModuleNotFound errors.
# 1. uv sync installs the SDK (google-auth, pydantic, etc.)
# 2. uv pip install griffe ensures the detector tool is in the venv
run: |
uv sync --extra test
uv pip install griffe
- name: Run Breaking Change Detection
shell: python
# Using 'uv run python' is the key: it automatically runs the script
# inside the .venv created in the previous step, so both 'griffe'
# and 'google' are found.
run: |
uv run python - <<EOF
import sys
import griffe
from griffe import find_breaking_changes, load, load_git
# The package 'google.adk' is located inside the 'src' directory.
# Specifying search_paths=["src"] allows Griffe to find it.
try:
print("Loading current API version...")
print("Loading current API (from PR)...")
# We use 'google.adk' and tell Griffe to look in 'src'
new_api = load("google.adk", search_paths=["src"])
print("Loading baseline API version from main branch...")
# load_git automatically handles the temporary checkout of the ref.
print("Loading baseline API (from main branch)...")
# search_paths=["src"] is also required here to find the package in the worktree
old_api = load_git("google.adk", ref="main", search_paths=["src"])
print("Comparing versions for breaking changes...")
print("Comparing for breaking changes...")
breakages = list(find_breaking_changes(old_api, new_api))
if breakages:
# Annotation for GitHub Actions UI
print(f"::error::Found {len(breakages)} breaking changes!")
for breakage in breakages:
# .explain() provides details on what was removed or changed
print(breakage.explain())
sys.exit(1)
print("Success: No breaking changes detected.")
except Exception as e:
# If Griffe fails (e.g., due to the 'google' module error), we fail the check.
print(f"::error::Breaking change detection failed: {e}")
sys.exit(1)
EOF