This is an automated email from the ASF dual-hosted git repository.
jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new b55022e2e97 Fix version validation script for building docker images
(#50668)
b55022e2e97 is described below
commit b55022e2e9741c99a868a38f506a80720973e9f0
Author: Kaxil Naik <[email protected]>
AuthorDate: Fri May 16 01:02:46 2025 +0530
Fix version validation script for building docker images (#50668)
Example failure:
https://github.com/apache/airflow/actions/runs/15053245013/job/42312930970
Previously, the script used string-based sorting of PyPI releases, which
caused versions like 2.11.0 to be incorrectly excluded (e.g. sorted behind
2.9.x). This commit updates the logic to use semantic versioning via
`packaging.version.Version`.
Before:
```
❯ uv run scripts/ci/airflow_version_check.py 2.11.0rc1
Version 2.11.0rc1 is not a valid Airflow version
Available versions: (first available 30 versions):
['3.0.1rc1', '3.0.1', '3.0.0rc4', '3.0.0rc3', '3.0.0rc2', '3.0.0rc1.post4',
'3.0.0rc1.post3', '3.0.0rc1.post2', '3.0.0rc1.post1', '3.0.0rc1', '3.0.0b4',
'3.0.0', '2.9.3rc1', '2.9.3', '2.9.2rc1', '2.9.2', '2.9.1rc2', '2.9.1rc1',
'2.9.1', '2.9.0rc3', '2.9.0rc2', '2.9.0rc1', '2.9.0b2', '2.9.0b1', '2.9.0',
'2.8.4rc1', '2.8.4', '2.8.3rc1', '2.8.3', '2.8.2rc3']
```
After:
```
❯ uv run scripts/ci/airflow_version_check.py 2.11.0rc1
Checking constraints file:
https://raw.githubusercontent.com/apache/airflow/constraints-2.11.0rc1/constraints-3.9.txt
Constraints file found for version 2.11.0rc1, Python 3.9
airflowVersion=2.11.0rc1
airflowVersion=2.11.0rc1
skipLatest=true
skipLatest=true
```
---
scripts/ci/airflow_version_check.py | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/scripts/ci/airflow_version_check.py
b/scripts/ci/airflow_version_check.py
index 6d2655fafce..3b6cf453651 100755
--- a/scripts/ci/airflow_version_check.py
+++ b/scripts/ci/airflow_version_check.py
@@ -31,7 +31,7 @@ import sys
from pathlib import Path
import requests
-from packaging.version import Version
+from packaging.version import Version, parse
from rich.console import Console
console = Console(color_system="standard", stderr=True, width=400)
@@ -46,18 +46,19 @@ def check_airflow_version(airflow_version: Version) ->
tuple[str, bool]:
"""
latest = False
url = "https://pypi.org/pypi/apache-airflow/json"
- max_versions_shown = 30
try:
response = requests.get(url)
response.raise_for_status()
data = response.json()
latest_version = Version(data["info"]["version"])
- valid_versions =
list(reversed(data["releases"].keys()))[:max_versions_shown]
- if str(airflow_version) not in valid_versions:
- console.print(f"[red]Version {airflow_version} is not a valid
Airflow version")
- console.print(
- f"Available versions: (first available {max_versions_shown}
versions):", valid_versions
- )
+ all_versions = sorted(
+ (parse(v) for v in data["releases"].keys()),
+ reverse=True,
+ )
+ if airflow_version not in all_versions:
+ console.print(f"[red]Version {airflow_version} is not a valid
Airflow release version.")
+ console.print("[yellow]Available versions (latest 30 shown):")
+ console.print([str(v) for v in all_versions[:30]])
sys.exit(1)
if airflow_version == latest_version:
latest = True