File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Breaking Change Detector
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ paths :
8+ - ' src/**'
9+
10+ jobs :
11+ check-api :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+ with :
17+ fetch-depth : 0 # Crucial for griffe.load_git to access the main branch history
18+
19+ - name : Set up Python
20+ uses : actions/setup-python@v5
21+ with :
22+ python-version : ' 3.10'
23+
24+ - name : Install Griffe
25+ run : pip install griffe
26+
27+ - name : Run Breaking Change Detection
28+ shell : python
29+ run : |
30+ import sys
31+ import griffe
32+ from griffe import find_breaking_changes, load, load_git
33+
34+ # 1. Load the current PR version from the local source
35+ # The adk-python source is located in src/google/adk
36+ try:
37+ new_api = load("src/google/adk")
38+
39+ # 2. Load the 'main' version for comparison
40+ # Griffe will look at the main branch's version of the package
41+ old_api = load_git("google.adk", ref="main")
42+
43+ # 3. Detect and explain breaking changes
44+ breakages = list(find_breaking_changes(old_api, new_api))
45+
46+ if breakages:
47+ print(f"::error::Found {len(breakages)} breaking changes!")
48+ for breakage in breakages:
49+ # .explain() provides a human-readable reason for the breakage
50+ print(breakage.explain())
51+ sys.exit(1)
52+
53+ print("No breaking changes detected.")
54+ except Exception as e:
55+ print(f"::warning::Breaking change detection failed: {e}")
56+ # We don't exit 1 here to prevent CI failure if the tool itself crashes
You can’t perform that action at this time.
0 commit comments