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

potiuk 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 44d953154a Move breeze command line pre-commit check to breeze shell 
(#35881)
44d953154a is described below

commit 44d953154ad7e879a097ef0cd9d8aa3deca354f0
Author: Jarek Potiuk <[email protected]>
AuthorDate: Mon Nov 27 16:24:05 2023 +0100

    Move breeze command line pre-commit check to breeze shell (#35881)
---
 .pre-commit-config.yaml                            |  2 +-
 .../ci/pre_commit/pre_commit_breeze_cmd_line.py    | 82 ++++++++--------------
 2 files changed, 32 insertions(+), 52 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 097608aa8f..05adea077d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -935,7 +935,7 @@ repos:
           ^generated/provider_dependencies.json$
         require_serial: true
         pass_filenames: false
-        additional_dependencies: ['rich>=12.4.4', 'rich-click>=1.7.0', 
'inputimeout', 'pyyaml', 'packaging', 'filelock']
+        additional_dependencies: ['rich>=12.4.4']
       - id: check-example-dags-urls
         name: Check that example dags url include provider versions
         entry: ./scripts/ci/pre_commit/pre_commit_update_example_dags_paths.py
diff --git a/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py 
b/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py
index 8ee4a9db21..567b5819a0 100755
--- a/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py
+++ b/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py
@@ -19,13 +19,12 @@
 from __future__ import annotations
 
 import os
-import shutil
 import subprocess
 import sys
 from pathlib import Path
-from subprocess import call
 
-from rich.console import Console
+sys.path.insert(0, str(Path(__file__).parent.resolve()))
+from common_precommit_utils import console, initialize_breeze_precommit
 
 AIRFLOW_SOURCES_DIR = Path(__file__).parents[3].resolve()
 BREEZE_IMAGES_DIR = AIRFLOW_SOURCES_DIR / "images" / "breeze"
@@ -33,8 +32,6 @@ BREEZE_INSTALL_DIR = AIRFLOW_SOURCES_DIR / "dev" / "breeze"
 BREEZE_SOURCES_DIR = BREEZE_INSTALL_DIR / "src"
 FORCE = os.environ.get("FORCE", "false")[0].lower() == "t"
 
-console = Console(width=400, color_system="standard")
-
 
 def verify_all_commands_described_in_docs():
     errors = []
@@ -60,57 +57,40 @@ def verify_all_commands_described_in_docs():
 
 
 def is_regeneration_needed() -> bool:
-    return_code = call(
-        [
-            sys.executable,
-            str(BREEZE_SOURCES_DIR / "airflow_breeze" / "breeze.py"),
-            "setup",
-            "regenerate-command-images",
-            "--check-only",
-        ],
+    result = subprocess.run(
+        ["breeze", "setup", "regenerate-command-images", "--check-only"],
+        check=False,
     )
-    return return_code != 0
+    return result.returncode != 0
 
 
-if __name__ == "__main__":
-    os.environ["AIRFLOW_SOURCES_ROOT"] = str(AIRFLOW_SOURCES_DIR)
-    # needed to keep consistent output
-    os.environ["PYTHONPATH"] = str(BREEZE_SOURCES_DIR)
-    os.environ["SKIP_BREEZE_SELF_UPGRADE_CHECK"] = "true"
-    return_code = 0
-    verify_all_commands_described_in_docs()
-    if is_regeneration_needed():
-        return_code = 1
-        if shutil.which("breeze") is None:
-            console.print("\n[red]Breeze command configuration has changed.\n")
-            console.print(
-                "[yellow]The `breeze` command is not on path. "
-                "Skipping regeneration of images and consistency check."
-            )
-            console.print(
-                "\n[bright_blue]Some of the commands changed since last time 
images were generated.\n"
-            )
-            console.print("\n[yellow]You should install it and run those 
commands manually:\n")
-            console.print("\n[magenta]breeze setup 
regenerate-command-images\n")
-            console.print("\n[magenta]breeze setup 
check-all-params-in-groups\n")
-            sys.exit(return_code)
-        res = subprocess.run(
-            ["breeze", "setup", "regenerate-command-images"],
-            check=False,
-        )
-        if res.returncode != 0:
-            console.print("\n[red]Breeze command configuration has changed.\n")
-            console.print("\n[bright_blue]Images have been regenerated.\n")
-            console.print("\n[bright_blue]You might want to run it 
manually:\n")
-            console.print("\n[magenta]breeze setup 
regenerate-command-images\n")
+initialize_breeze_precommit(__name__, __file__)
+
+return_code = 0
+verify_all_commands_described_in_docs()
+if is_regeneration_needed():
+    console.print(
+        "\n[bright_blue]Some of the commands changed since last time "
+        "images were generated. Regenerating.\n"
+    )
+    return_code = 1
     res = subprocess.run(
-        ["breeze", "setup", "check-all-params-in-groups"],
+        ["breeze", "setup", "regenerate-command-images"],
         check=False,
     )
     if res.returncode != 0:
-        return_code = 1
         console.print("\n[red]Breeze command configuration has changed.\n")
-        console.print("\n[yellow]Please fix it in the appropriate 
command_*_config.py file\n")
-        console.print("\n[bright_blue]You can run consistency check manually 
by running:\n")
-        console.print("\nbreeze setup check-all-params-in-groups\n")
-    sys.exit(return_code)
+        console.print("\n[bright_blue]Images have been regenerated.\n")
+        console.print("\n[bright_blue]You might want to run it manually:\n")
+        console.print("\n[magenta]breeze setup regenerate-command-images\n")
+res = subprocess.run(
+    ["breeze", "setup", "check-all-params-in-groups"],
+    check=False,
+)
+if res.returncode != 0:
+    return_code = 1
+    console.print("\n[red]Breeze command configuration has changed.\n")
+    console.print("\n[yellow]Please fix it in the appropriate 
command_*_config.py file\n")
+    console.print("\n[bright_blue]You can run consistency check manually by 
running:\n")
+    console.print("\nbreeze setup check-all-params-in-groups\n")
+sys.exit(return_code)

Reply via email to