Skip to content

Commit 0aa012e

Browse files
fix: skip version bump requirement for test/doc-only changes (#28)
1 parent 15bd8aa commit 0aa012e

2 files changed

Lines changed: 43 additions & 22 deletions

File tree

scripts/check_version_bump.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,14 @@ def get_diff_stats(base_ref: str, dir_name: str) -> dict | None:
9292
# --- file-level stats (added / deleted) ---
9393
for diff_filter, key_suffix in [("A", "added"), ("D", "deleted")]:
9494
result = subprocess.run(
95-
[
96-
"git", "diff", "--name-only", f"--diff-filter={diff_filter}",
97-
base_ref, "HEAD", "--", f"{dir_name}/"
98-
],
95+
["git", "diff", "--name-only", f"--diff-filter={diff_filter}", base_ref, "HEAD", "--", f"{dir_name}/"],
9996
capture_output=True,
10097
text=True,
10198
)
10299
if result.returncode != 0:
103100
return None
104101
files = [f for f in result.stdout.splitlines() if f.strip()]
105-
py_files = [
106-
f for f in files
107-
if f.endswith(".py") and "/tests/" not in f and not f.endswith("test_.py")
108-
]
102+
py_files = [f for f in files if f.endswith(".py") and "/tests/" not in f and not f.endswith("test_.py")]
109103
if key_suffix == "added":
110104
py_files_added = len(py_files)
111105
else:
@@ -143,13 +137,9 @@ def get_diff_stats(base_ref: str, dir_name: str) -> dict | None:
143137
# --- check if only tests / docs changed ---
144138
all_changed = get_changed_files(base_ref, dir_name) or []
145139
non_test_doc = [
146-
f for f in all_changed
147-
if not (
148-
"/tests/" in f
149-
or f.endswith("README.md")
150-
or f.endswith(".md")
151-
or f.endswith("requirements.txt")
152-
)
140+
f
141+
for f in all_changed
142+
if not ("/tests/" in f or f.endswith("README.md") or f.endswith(".md") or f.endswith("requirements.txt"))
153143
]
154144
# config.json is handled separately so exclude it here
155145
non_test_doc = [f for f in non_test_doc if not f.endswith("config.json")]
@@ -167,8 +157,12 @@ def get_diff_stats(base_ref: str, dir_name: str) -> dict | None:
167157

168158

169159
def recommend_bump(
170-
base_config: dict, current_config: dict, changed_files: list[str], dir_name: str,
171-
*, base_ref: str = "",
160+
base_config: dict,
161+
current_config: dict,
162+
changed_files: list[str],
163+
dir_name: str,
164+
*,
165+
base_ref: str = "",
172166
) -> str:
173167
"""Recommend major, minor, or patch based on what changed.
174168
@@ -216,6 +210,10 @@ def recommend_bump(
216210
if base_ref:
217211
stats = get_diff_stats(base_ref, dir_name)
218212
if stats:
213+
# Only tests, docs, or requirements changed — always patch
214+
if stats["only_tests_docs"]:
215+
return "patch"
216+
219217
# Major: source files or public symbols removed
220218
if stats["py_files_deleted"] > 0:
221219
return "major"
@@ -294,6 +292,15 @@ def check_version_bump(base_ref: str, dirs: list[str]) -> int:
294292
# No changes in this dir — nothing to check
295293
continue
296294

295+
# If only tests, docs, or requirements changed, version bump is optional
296+
diff_stats = get_diff_stats(base_ref, d)
297+
if diff_stats and diff_stats["only_tests_docs"] and current_version_str == base_version_str:
298+
actions_same = base_config.get("actions") == current_config.get("actions")
299+
auth_same = base_config.get("auth") == current_config.get("auth")
300+
if actions_same and auth_same:
301+
print(f"✅ {d}: No version bump needed (only tests/docs changed)")
302+
continue
303+
297304
# Only config.json changed with no version diff is still a problem,
298305
# but if nothing meaningful changed we skip
299306
if current_version_str == base_version_str:
@@ -348,9 +355,7 @@ def check_version_bump(base_ref: str, dirs: list[str]) -> int:
348355
return 0
349356

350357

351-
def _detect_bump_level(
352-
base: tuple[int, ...], current: tuple[int, ...]
353-
) -> str:
358+
def _detect_bump_level(base: tuple[int, ...], current: tuple[int, ...]) -> str:
354359
"""Detect whether the version change was major, minor, or patch."""
355360
if current[0] > base[0]:
356361
return "major"

scripts/docs/check_version_bump.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ flowchart TD
6262
E -->|Yes — existing integration| I[Compare versions]
6363
I --> J{Files changed?}
6464
J -->|No| G
65-
J -->|Yes| K{Version incremented?}
65+
J -->|Yes| TD{Only tests/docs?}
66+
TD -->|Yes| G
67+
TD -->|No| K{Version incremented?}
6668
K -->|Same| L[Fail + recommend bump level]
6769
K -->|Decreased| M[Fail]
6870
K -->|Incremented| N{Bump level sufficient?}
@@ -118,6 +120,10 @@ The script recommends a bump level by inspecting both config.json changes and co
118120
| New `.py` source files added (excluding tests) | **minor** |
119121
| New `class` or `def` definitions added | **minor** |
120122

123+
### Test/doc-only changes
124+
125+
If every changed file is in `tests/`, a `.md` file, or `requirements.txt` (and the config is unchanged), the version check is **skipped entirely** — no bump is required. This allows adding or updating tests, docs, and dependencies without touching the version number.
126+
121127
### Fallback
122128

123129
If none of the above signals match, the recommendation defaults to **patch** (bug fixes, docs, dependency updates, test changes).
@@ -164,6 +170,16 @@ The recommendation is advisory — bumping at a lower level than recommended pro
164170
========================================
165171
```
166172

173+
### When only tests/docs changed (no bump needed):
174+
175+
```
176+
✅ my-integration: No version bump needed (only tests/docs changed)
177+
178+
========================================
179+
✅ VERSION CHECK PASSED
180+
========================================
181+
```
182+
167183
### New integration with valid version:
168184

169185
```
@@ -194,7 +210,7 @@ The recommendation is advisory — bumping at a lower level than recommended pro
194210
| Files changed but version unchanged | ❌ Fails with recommendation |
195211
| Version decreased | ❌ Fails |
196212
| Bump level lower than recommended | ✅ Passes with ⚠️ warning |
197-
| Only test/doc files changed, version unchanged | ❌ Fails (patch bump recommended) |
213+
| Only test/doc files changed, version unchanged | ✅ Passes (no bump needed) |
198214
| No files changed in directory | ✅ Passes (nothing to check) |
199215
| Directory doesn't exist on disk | ⚠️ Skipped with warning |
200216
| No `config.json` in directory | ⚠️ Skipped with warning |

0 commit comments

Comments
 (0)