chore: add breaking change detector #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Breaking Change Detector | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'src/**' | |
| jobs: | |
| check-api: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| version: "latest" | |
| - name: Install project | |
| run: | | |
| uv sync --extra test | |
| uv pip install griffe | |
| - name: Run Breaking Change Detection | |
| run: | | |
| uv run python - <<EOF | |
| import sys | |
| import griffe | |
| from griffe import find_breaking_changes, load, load_git | |
| try: | |
| # 1. Force static analysis (allow_inspection=False) to avoid sys.modules caching issues | |
| print("Loading new API...") | |
| new_api = load("google.adk", search_paths=["src"], allow_inspection=False) | |
| print("Loading old API...") | |
| old_api = load_git("google.adk", ref="main", search_paths=["src"], allow_inspection=False) | |
| # Debug: Verify we are comparing different files | |
| print(f"DEBUG: New API path: {new_api.filepath}") | |
| print(f"DEBUG: Old API path: {old_api.filepath}") | |
| print("Comparing...") | |
| breakages = list(find_breaking_changes(old_api, new_api)) | |
| if breakages: | |
| print(f"::error::Found {len(breakages)} breaking changes!") | |
| for breakage in breakages: | |
| print(breakage.explain()) | |
| sys.exit(1) | |
| print("Success: No breaking changes detected.") | |
| except Exception as e: | |
| print(f"::error::Breaking change detection failed: {e}") | |
| sys.exit(1) | |
| EOF |