Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(ci): validate full versions in breaking release guard (#7210)

Chanhyo Jung877214a312b2
diff --git a/scripts/ci/check_breaking_release.py b/scripts/ci/check_breaking_release.py
index c3850021d4..f30c4806ed 100644
--- a/scripts/ci/check_breaking_release.py
+++ b/scripts/ci/check_breaking_release.py
@@ -38,7 +38,11 @@ sys.path.insert(
from _changelog_fragments import towncrier_fragments # noqa: E402
BREAKING = "breaking"
-_VERSION_RE = re.compile(r"^v?(\d+)\.(\d+)\.(\d+)(?!\d)")
+_VERSION_RE = re.compile(
+ r"v?([0-9]+)\.([0-9]+)\.([0-9]+)"
+ r"(?:[-_.]?(?:alpha|a|beta|b|preview|pre|c|rc)[-_.]?[0-9]*)?"
+ r"(?:[-_.]?dev[-_.]?[0-9]*)?"
+)
def pending_breaking(changelog_dir, pyproject):
@@ -52,7 +56,7 @@ def is_major_release(version):
Anything unparseable is refused (returns False) so the guard fails closed.
"""
- match = _VERSION_RE.match(version.strip())
+ match = _VERSION_RE.fullmatch(version.strip().lower())
if not match:
return False
major, minor, patch = (int(group) for group in match.groups())
diff --git a/tests/ci/test_breaking_release_full_version.py b/tests/ci/test_breaking_release_full_version.py
new file mode 100644
index 0000000000..ab9915c276
--- /dev/null
+++ b/tests/ci/test_breaking_release_full_version.py
@@ -0,0 +1,134 @@
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[2]
+SCRIPT = ROOT / "scripts/ci/check_breaking_release.py"
+sys.path.insert(0, str(SCRIPT.parent))
+sys.path.insert(0, str(ROOT / ".github/scripts"))
+
+import check_breaking_release # noqa: E402
+import release_package # noqa: E402
+
+
+ "version,normalized,major",
+ [
+ ("2.0.0-post1", "2.0.0.post1", False),
+ ("2.0.0-1", "2.0.0.post1", False),
+ ("0.5.0.post1", "0.5.0.post1", False),
+ ("2.0.0_rev_2", "2.0.0.post2", False),
+ ("2.0.0r", "2.0.0.post0", False),
+ ("2.0.0rc1.post2.dev3", "2.0.0rc1.post2.dev3", False),
+ ("2.0.0+local", "2.0.0+local", False),
+ ("2.0.0rc1+build.1", "2.0.0rc1+build.1", False),
+ ("0!2.0.0", "2.0.0", False),
+ ("1!2.0.0", "1!2.0.0", False),
+ ("2.0.0.0", "2.0.0.0", False),
+ ("2.0.0.1", "2.0.0.1", False),
+ ("1.0.0", "1.0.0", True),
+ ("12.0.0", "12.0.0", True),
+ ("0.1.0", "0.1.0", True),
+ (" \tv2.0.0\n", "2.0.0", True),
+ ("V02.00.00_RC_01", "2.0.0rc1", True),
+ ("2.0.0-rc1", "2.0.0rc1", True),
+ ("2.0.0rc1", "2.0.0rc1", True),
+ ("2.0.0alpha", "2.0.0a0", True),
+ ("2.0.0-a.2", "2.0.0a2", True),
+ ("2.0.0.beta-2", "2.0.0b2", True),
+ ("2.0.0b3", "2.0.0b3", True),
+ ("2.0.0preview1", "2.0.0rc1", True),
+ ("2.0.0pre", "2.0.0rc0", True),
+ ("0.5.0c1", "0.5.0rc1", True),
+ ("2.0.0-dev", "2.0.0.dev0", True),
+ ("2.0.0rc1.dev2", "2.0.0rc1.dev2", True),
+ ("1.11.0rc1", "1.11.0rc1", False),
+ ("2.0.1", "2.0.1", False),
+ ("0.5.1rc1", "0.5.1rc1", False),
+ ("0.0.0", "0.0.0", False),
+ ],
+)
+def test_major_boundary_matches_publisher_version(
+ version: str, normalized: str, major: bool
+) -> None:
+ assert release_package.normalize_version(version) == normalized
+ assert check_breaking_release.is_major_release(version) is major
+
+
+ "version",
+ [
+ "2.0.0garbage",
+ "2.0.0-",
+ "2.0.0-rc1-extra",
+ "2.0.0rc1.2",
+ "2.0.0rc1rc2",
+ "2.0.0--rc1",
+ "2.0.0dev1rc1",
+ "2.0.0\nrc1",
+ "2.0.0..dev1",
+ "\u0662.0.0",
+ "2.\uff10.0",
+ "2.0.0rc\u0661",
+ ],
+)
+def test_malformed_publisher_versions_are_not_major(version: str) -> None:
+ with pytest.raises(ValueError, match="Invalid package version"):
+ release_package.normalize_version(version)
+ assert check_breaking_release.is_major_release(version) is False
+
+
[email protected]("pending", [True, False])
+ "version,major",
+ [
+ ("2.0.0-post1", False),
+ ("2.0.0-1", False),
+ ("2.0.0-rc1-extra", False),
+ ("2.0.0.1", False),
+ ("2.0.0", True),
+ ("0.5.0", True),
+ ("2.0.0-rc1", True),
+ ("2.0.0rc1", True),
+ ],
+)
+def test_cli_enforces_full_version_when_breaking_changes_are_pending(
+ tmp_path: Path, pending: bool, version: str, major: bool
+) -> None:
+ fragment = tmp_path / "7203.breaking.md"
+ if pending:
+ fragment.write_text("Breaking change\n", encoding="utf-8")
+
+ result = subprocess.run(
+ [
+ sys.executable,
+ "-I",
+ "-S",
+ str(SCRIPT),
+ "--pyproject",
+ str(ROOT / "pyproject.toml"),
+ "--changelog-dir",
+ str(tmp_path),
+ "version",
+ version,
+ ],
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+
+ assert result.returncode == (1 if pending and not major else 0)
+ assert result.stderr == ""
+ if not pending:
+ assert result.stdout == "No breaking changelog fragments are pending.\n"
+ elif major:
+ assert result.stdout == (
+ f"Version {version} is a major release; breaking fragments allowed.\n"
+ )
+ else:
+ assert result.stdout.startswith(
+ f"::error::Version {version} is not a major release,"
+ )
+ assert fragment.name in result.stdout