Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions scripts/ci/prek/boring_cyborg.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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__"):
Expand All @@ -39,8 +40,7 @@

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}")
Expand All @@ -50,7 +50,7 @@
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}"
Expand All @@ -60,7 +60,7 @@

# 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}"
Expand All @@ -71,7 +71,7 @@

# 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}"
Expand Down
5 changes: 3 additions & 2 deletions scripts/ci/prek/chart_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
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']",
Expand Down
2 changes: 0 additions & 2 deletions scripts/ci/prek/check_aiobotocore_optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import yaml
from rich.console import Console

AIRFLOW_SOURCES = Path(__file__).parents[3]

console = Console(color_system="standard", width=200)

if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion scripts/ci/prek/check_airflow_v_imports_in_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
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

Expand Down Expand Up @@ -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 = []
Expand Down
7 changes: 2 additions & 5 deletions scripts/ci/prek/check_init_in_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__"):
Expand All @@ -36,17 +36,14 @@
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] = []

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"}
Expand Down
3 changes: 2 additions & 1 deletion scripts/ci/prek/mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
sys.path.insert(0, str(Path(__file__).parent.resolve()))

from common_prek_utils import (
AIRFLOW_ROOT_PATH,
console,
initialize_breeze_prek,
pre_process_files,
Expand All @@ -46,7 +47,7 @@

# TODO(potiuk): add suspended providers exclusion

repo_root = Path(__file__).parents[3].resolve()
repo_root = AIRFLOW_ROOT_PATH.resolve()
cmd = [
"bash",
"-c",
Expand Down
8 changes: 3 additions & 5 deletions scripts/ci/prek/supported_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@

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",
Expand Down Expand Up @@ -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"
Expand All @@ -69,7 +67,7 @@ def replace_text_between(file: Path, start: str, end: str, replacement_text: str
+ "\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"
Expand Down