This is an automated email from the ASF dual-hosted git repository.

jscheffl pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-1-test by this push:
     new 3222f28d8b8 [v3-1-test] Clean up some root discovery in prek scripts 
(#57290) (#57291)
3222f28d8b8 is described below

commit 3222f28d8b84c0165e509ebc6756e108ac1cd1f4
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sun Oct 26 12:38:23 2025 +0100

    [v3-1-test] Clean up some root discovery in prek scripts (#57290) (#57291)
    
    (cherry picked from commit bedd81c33224c39447df9242137c819c823b9a13)
    
    Co-authored-by: Jens Scheffler <[email protected]>
---
 scripts/ci/prek/boring_cyborg.py                    | 10 +++++-----
 scripts/ci/prek/chart_schema.py                     |  5 +++--
 scripts/ci/prek/check_aiobotocore_optional.py       |  2 --
 scripts/ci/prek/check_airflow_v_imports_in_tests.py |  4 +++-
 scripts/ci/prek/check_init_in_tests.py              |  7 ++-----
 scripts/ci/prek/mypy.py                             |  3 ++-
 scripts/ci/prek/supported_versions.py               |  8 +++-----
 7 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/scripts/ci/prek/boring_cyborg.py b/scripts/ci/prek/boring_cyborg.py
index a3af440883a..a4dd0204f04 100755
--- a/scripts/ci/prek/boring_cyborg.py
+++ b/scripts/ci/prek/boring_cyborg.py
@@ -29,6 +29,7 @@ import sys
 from pathlib import Path
 
 import yaml
+from common_prek_utils import AIRFLOW_ROOT_PATH
 from termcolor import colored
 
 if __name__ not in ("__main__", "__mp_main__"):
@@ -39,8 +40,7 @@ if __name__ not in ("__main__", "__mp_main__"):
 
 CONFIG_KEY = "labelPRBasedOnFilePath"
 
-repo_root = Path(__file__).parents[3]
-cyborg_config_path = repo_root / ".github" / "boring-cyborg.yml"
+cyborg_config_path = AIRFLOW_ROOT_PATH / ".github" / "boring-cyborg.yml"
 cyborg_config = yaml.safe_load(cyborg_config_path.read_text())
 if CONFIG_KEY not in cyborg_config:
     raise SystemExit(f"Missing section {CONFIG_KEY}")
@@ -50,7 +50,7 @@ errors = []
 for label, patterns in cyborg_config[CONFIG_KEY].items():
     for pattern in patterns:
         try:
-            next(Path(repo_root).glob(pattern))
+            next(Path(AIRFLOW_ROOT_PATH).glob(pattern))
             continue
         except StopIteration:
             yaml_path = f"{CONFIG_KEY}.{label}"
@@ -60,7 +60,7 @@ for label, patterns in cyborg_config[CONFIG_KEY].items():
 
 # Check for missing providers
 EXCEPTIONS = ["edge3"]
-providers_root = repo_root / "providers"
+providers_root = AIRFLOW_ROOT_PATH / "providers"
 for p in providers_root.glob("**/provider.yaml"):
     provider_name = str(p.parent.relative_to(providers_root)).replace("/", "-")
     expected_key = f"provider:{provider_name}"
@@ -71,7 +71,7 @@ for p in providers_root.glob("**/provider.yaml"):
 
 # Check for missing translations
 EXCEPTIONS = ["en"]
-for p in repo_root.glob("airflow-core/src/airflow/ui/public/i18n/locales/*"):
+for p in 
AIRFLOW_ROOT_PATH.glob("airflow-core/src/airflow/ui/public/i18n/locales/*"):
     if p.is_dir():
         lang_id = p.name
         expected_key = f"translation:{lang_id}"
diff --git a/scripts/ci/prek/chart_schema.py b/scripts/ci/prek/chart_schema.py
index de720573f7e..ba92be20975 100755
--- a/scripts/ci/prek/chart_schema.py
+++ b/scripts/ci/prek/chart_schema.py
@@ -21,14 +21,15 @@ import json
 import sys
 from pathlib import Path
 
+from common_prek_utils import AIRFLOW_ROOT_PATH
+
 if __name__ not in ("__main__", "__mp_main__"):
     raise SystemExit(
         "This file is intended to be executed as an executable program. You 
cannot use it as a module."
         f"To run this script, run the ./{__file__} command"
     )
 
-PROJECT_SOURCE_ROOT_DIR = Path(__file__).resolve().parents[3]
-CHART_DIR = PROJECT_SOURCE_ROOT_DIR / "chart"
+CHART_DIR = AIRFLOW_ROOT_PATH / "chart"
 KNOWN_INVALID_TYPES = {
     # I don't know the data structure for this type with 100 certainty. We 
have no tests.
     
"$['properties']['ingress']['properties']['web']['properties']['precedingPaths']",
diff --git a/scripts/ci/prek/check_aiobotocore_optional.py 
b/scripts/ci/prek/check_aiobotocore_optional.py
index 7a84feca897..41dc160dd8d 100755
--- a/scripts/ci/prek/check_aiobotocore_optional.py
+++ b/scripts/ci/prek/check_aiobotocore_optional.py
@@ -32,8 +32,6 @@ from pathlib import Path
 import yaml
 from rich.console import Console
 
-AIRFLOW_SOURCES = Path(__file__).parents[3]
-
 console = Console(color_system="standard", width=200)
 
 if __name__ == "__main__":
diff --git a/scripts/ci/prek/check_airflow_v_imports_in_tests.py 
b/scripts/ci/prek/check_airflow_v_imports_in_tests.py
index c56cd0baac2..13109164c50 100755
--- a/scripts/ci/prek/check_airflow_v_imports_in_tests.py
+++ b/scripts/ci/prek/check_airflow_v_imports_in_tests.py
@@ -31,6 +31,8 @@ import ast
 import sys
 from pathlib import Path
 
+from common_prek_utils import AIRFLOW_ROOT_PATH
+
 sys.path.insert(0, str(Path(__file__).parent.resolve()))  # make sure 
common_prek_utils is imported
 from common_prek_utils import console
 
@@ -68,7 +70,7 @@ def main():
     if len(sys.argv) > 1:
         test_files = [Path(f) for f in sys.argv[1:]]
     else:
-        base = Path(__file__).parents[3] / "providers"
+        base = AIRFLOW_ROOT_PATH / "providers"
         test_files = list(base.glob("**/tests/**/*.py"))
         console.print(test_files)
     all_errors = []
diff --git a/scripts/ci/prek/check_init_in_tests.py 
b/scripts/ci/prek/check_init_in_tests.py
index db228d90e9a..c5fc3f20c5f 100755
--- a/scripts/ci/prek/check_init_in_tests.py
+++ b/scripts/ci/prek/check_init_in_tests.py
@@ -24,10 +24,10 @@
 from __future__ import annotations
 
 import os
-import pathlib
 import sys
 from pathlib import Path
 
+from common_prek_utils import AIRFLOW_ROOT_PATH
 from rich.console import Console
 
 if __name__ not in ("__main__", "__mp_main__"):
@@ -36,9 +36,6 @@ if __name__ not in ("__main__", "__mp_main__"):
         f"To execute this script, run ./{__file__} [FILE] ..."
     )
 
-ROOT_DIR = pathlib.Path(__file__).resolve().parents[3]
-
-
 console = Console(color_system="standard", width=200)
 
 errors: list[str] = []
@@ -46,7 +43,7 @@ errors: list[str] = []
 added = False
 
 if __name__ == "__main__":
-    for dirname, sub_dirs, _ in os.walk(ROOT_DIR / "tests"):
+    for dirname, sub_dirs, _ in os.walk(AIRFLOW_ROOT_PATH / "tests"):
         dir = Path(dirname)
         sub_dirs[:] = [
             subdir for subdir in sub_dirs if subdir not in {"__pycache__", 
"test_logs", "test_zip"}
diff --git a/scripts/ci/prek/mypy.py b/scripts/ci/prek/mypy.py
index d92ffd85e31..52523c094bf 100755
--- a/scripts/ci/prek/mypy.py
+++ b/scripts/ci/prek/mypy.py
@@ -31,6 +31,7 @@ from pathlib import Path
 sys.path.insert(0, str(Path(__file__).parent.resolve()))
 
 from common_prek_utils import (
+    AIRFLOW_ROOT_PATH,
     console,
     initialize_breeze_prek,
     pre_process_files,
@@ -46,7 +47,7 @@ if not files_to_test:
 
 # TODO(potiuk): add suspended providers exclusion
 
-repo_root = Path(__file__).parents[3].resolve()
+repo_root = AIRFLOW_ROOT_PATH.resolve()
 cmd = [
     "bash",
     "-c",
diff --git a/scripts/ci/prek/supported_versions.py 
b/scripts/ci/prek/supported_versions.py
index d7188ee7271..2721aa0b0fa 100755
--- a/scripts/ci/prek/supported_versions.py
+++ b/scripts/ci/prek/supported_versions.py
@@ -26,11 +26,9 @@ from __future__ import annotations
 
 from pathlib import Path
 
+from common_prek_utils import AIRFLOW_ROOT_PATH
 from tabulate import tabulate
 
-AIRFLOW_SOURCES = Path(__file__).resolve().parents[3]
-
-
 HEADERS = (
     "Version",
     "Current Patch/Minor",
@@ -59,7 +57,7 @@ def replace_text_between(file: Path, start: str, end: str, 
replacement_text: str
 
 if __name__ == "__main__":
     replace_text_between(
-        file=AIRFLOW_SOURCES / "README.md",
+        file=AIRFLOW_ROOT_PATH / "README.md",
         start="<!-- Beginning of auto-generated table -->\n",
         end="<!-- End of auto-generated table -->\n",
         replacement_text="\n"
@@ -69,7 +67,7 @@ if __name__ == "__main__":
         + "\n\n",
     )
     replace_text_between(
-        file=AIRFLOW_SOURCES / "airflow-core" / "docs" / "installation" / 
"supported-versions.rst",
+        file=AIRFLOW_ROOT_PATH / "airflow-core" / "docs" / "installation" / 
"supported-versions.rst",
         start=" .. Beginning of auto-generated table\n",
         end=" .. End of auto-generated table\n",
         replacement_text="\n"

Reply via email to