diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 883816f901e60..0692904ce58fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -341,7 +341,7 @@ repos: pass_filenames: true files: ^airflow/providers/.*\.py$ additional_dependencies: ['rich>=12.4.4'] - - id: update-breeze-file + - id: update-breeze-cmd-output name: Update output of breeze commands in BREEZE.rst entry: ./scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py language: python diff --git a/STATIC_CODE_CHECKS.rst b/STATIC_CODE_CHECKS.rst index 53b526fdfcd8d..27338c3f9d367 100644 --- a/STATIC_CODE_CHECKS.rst +++ b/STATIC_CODE_CHECKS.rst @@ -294,7 +294,7 @@ require Breeze Docker image to be build locally. +--------------------------------------------------------+------------------------------------------------------------------+---------+ | trailing-whitespace | Remove trailing whitespace at end of line | | +--------------------------------------------------------+------------------------------------------------------------------+---------+ -| update-breeze-file | Update output of breeze commands in BREEZE.rst | | +| update-breeze-cmd-output | Update output of breeze commands in BREEZE.rst | | +--------------------------------------------------------+------------------------------------------------------------------+---------+ | update-breeze-readme-config-hash | Update Breeze README.md with config files hash | | +--------------------------------------------------------+------------------------------------------------------------------+---------+ diff --git a/dev/breeze/src/airflow_breeze/pre_commit_ids.py b/dev/breeze/src/airflow_breeze/pre_commit_ids.py index 541707045661f..29427fea48cfb 100644 --- a/dev/breeze/src/airflow_breeze/pre_commit_ids.py +++ b/dev/breeze/src/airflow_breeze/pre_commit_ids.py @@ -94,7 +94,7 @@ 'run-shellcheck', 'static-check-autoflake', 'trailing-whitespace', - 'update-breeze-file', + 'update-breeze-cmd-output', 'update-breeze-readme-config-hash', 'update-extras', 'update-in-the-wild-to-be-sorted', diff --git a/images/breeze/output-commands-hash.txt b/images/breeze/output-commands-hash.txt index 70ac9b305de2f..ef6122b57ad37 100644 --- a/images/breeze/output-commands-hash.txt +++ b/images/breeze/output-commands-hash.txt @@ -1 +1,5 @@ -8b4116c1808c84d491961283a4ddbec2 + +# This file is automatically generated by pre-commit. If you have a conflict with this file +# Please do not solve it but run `breeze regenerate-command-images`. +# This command should fix the conflict and regenerate help images that you have conflict with. +82cd0f28c2c53f699a5b571275f8f674 diff --git a/images/breeze/output-static-checks.svg b/images/breeze/output-static-checks.svg index 695266c06fd3b..49cf642d99ad6 100644 --- a/images/breeze/output-static-checks.svg +++ b/images/breeze/output-static-checks.svg @@ -19,241 +19,241 @@ font-weight: 700; } - .terminal-2504633254-matrix { + .terminal-749841752-matrix { font-family: Fira Code, monospace; font-size: 20px; line-height: 24.4px; font-variant-east-asian: full-width; } - .terminal-2504633254-title { + .terminal-749841752-title { font-size: 18px; font-weight: bold; font-family: arial; } - .terminal-2504633254-r1 { fill: #c5c8c6;font-weight: bold } -.terminal-2504633254-r2 { fill: #c5c8c6 } -.terminal-2504633254-r3 { fill: #d0b344;font-weight: bold } -.terminal-2504633254-r4 { fill: #868887 } -.terminal-2504633254-r5 { fill: #68a0b3;font-weight: bold } -.terminal-2504633254-r6 { fill: #98a84b;font-weight: bold } -.terminal-2504633254-r7 { fill: #8d7b39 } + .terminal-749841752-r1 { fill: #c5c8c6;font-weight: bold } +.terminal-749841752-r2 { fill: #c5c8c6 } +.terminal-749841752-r3 { fill: #d0b344;font-weight: bold } +.terminal-749841752-r4 { fill: #868887 } +.terminal-749841752-r5 { fill: #68a0b3;font-weight: bold } +.terminal-749841752-r6 { fill: #98a84b;font-weight: bold } +.terminal-749841752-r7 { fill: #8d7b39 } - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - Command: static-checks + Command: static-checks - + - - -Usage: breeze static-checks [OPTIONS] [PRECOMMIT_ARGS]... - -Run static checks. - -╭─ Pre-commit flags ───────────────────────────────────────────────────────────────────────────────────────────────────╮ -│--type-tType(s) of the static checks to run (multiple can be added).                            │ -│(all | black | blacken-docs | check-airflow-2-1-compatibility |                         │ -│check-airflow-config-yaml-consistent | check-airflow-providers-have-extras |            │ -│check-apache-license-rat | check-base-operator-partial-arguments |                      │ -│check-base-operator-usage | check-boring-cyborg-configuration |                         │ -│check-breeze-top-dependencies-limited | check-builtin-literals |                        │ -│check-changelog-has-no-duplicates | check-daysago-import-from-utils |                   │ -│check-docstring-param-types | check-example-dags-urls | check-executables-have-shebangs │ -│| check-extra-packages-references | check-extras-order | check-for-inclusive-language | │ -│check-hooks-apply | check-incorrect-use-of-LoggingMixin |                               │ -│check-integrations-are-consistent | check-merge-conflict | check-newsfragments-are-valid│ -│| check-no-providers-in-core-examples | check-no-relative-imports |                     │ -│check-persist-credentials-disabled-in-github-workflows |                                │ -│check-pre-commit-information-consistent | check-provide-create-sessions-imports |       │ -│check-provider-yaml-valid | check-providers-init-file-missing |                         │ -│check-providers-subpackages-init-file-exist | check-pydevd-left-in-code |               │ -│check-revision-heads-map | check-safe-filter-usage-in-html | check-setup-order |        │ -│check-start-date-not-used-in-defaults | check-system-tests-present |                    │ -│check-system-tests-tocs | check-xml | codespell | create-missing-init-py-files-tests |  │ -│debug-statements | detect-private-key | doctoc | end-of-file-fixer | fix-encoding-pragma│ -│| flynt | forbid-tabs | identity | insert-license | isort | lint-chart-schema | lint-css│ -│| lint-dockerfile | lint-helm-chart | lint-javascript | lint-json-schema | lint-markdown│ -│| lint-openapi | mixed-line-ending | pretty-format-json | pydocstyle |                  │ -│python-no-log-warn | pyupgrade | rst-backticks | run-flake8 | run-mypy | run-shellcheck │ -│| static-check-autoflake | trailing-whitespace | update-breeze-file |                   │ -│update-breeze-readme-config-hash | update-extras | update-in-the-wild-to-be-sorted |    │ -│update-inlined-dockerfile-scripts | update-local-yml-file | update-migration-references │ -│| update-providers-dependencies | update-setup-cfg-file |                               │ -│update-spelling-wordlist-to-be-sorted | update-supported-versions |                     │ -│update-vendored-in-k8s-json-schema | update-version | yamllint | yesqa)                 │ -│--file-fList of files to run the checks on.(PATH)│ -│--all-files-aRun checks on all files.│ -│--show-diff-on-failure-sShow diff for files modified by the checks.│ -│--last-commit-cRun checks for all files in last commit. Mutually exclusive with --commit-ref.│ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│--commit-ref-rRun checks for this commit reference only (can be any git commit-ish reference). Mutually  │ -│exclusive with --last-commit.                                                              │ -│(TEXT)                                                                                     │ -│--verbose-vPrint verbose information about performed steps.│ -│--dry-run-DIf dry-run is set, commands are only printed, not executed.│ -│--github-repository-gGitHub repository used to pull, push run images.(TEXT)[default: apache/airflow]│ -│--help-hShow this message and exit.│ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + +Usage: breeze static-checks [OPTIONS] [PRECOMMIT_ARGS]... + +Run static checks. + +╭─ Pre-commit flags ───────────────────────────────────────────────────────────────────────────────────────────────────╮ +│--type-tType(s) of the static checks to run (multiple can be added).                            │ +│(all | black | blacken-docs | check-airflow-2-1-compatibility |                         │ +│check-airflow-config-yaml-consistent | check-airflow-providers-have-extras |            │ +│check-apache-license-rat | check-base-operator-partial-arguments |                      │ +│check-base-operator-usage | check-boring-cyborg-configuration |                         │ +│check-breeze-top-dependencies-limited | check-builtin-literals |                        │ +│check-changelog-has-no-duplicates | check-daysago-import-from-utils |                   │ +│check-docstring-param-types | check-example-dags-urls | check-executables-have-shebangs │ +│| check-extra-packages-references | check-extras-order | check-for-inclusive-language | │ +│check-hooks-apply | check-incorrect-use-of-LoggingMixin |                               │ +│check-integrations-are-consistent | check-merge-conflict | check-newsfragments-are-valid│ +│| check-no-providers-in-core-examples | check-no-relative-imports |                     │ +│check-persist-credentials-disabled-in-github-workflows |                                │ +│check-pre-commit-information-consistent | check-provide-create-sessions-imports |       │ +│check-provider-yaml-valid | check-providers-init-file-missing |                         │ +│check-providers-subpackages-init-file-exist | check-pydevd-left-in-code |               │ +│check-revision-heads-map | check-safe-filter-usage-in-html | check-setup-order |        │ +│check-start-date-not-used-in-defaults | check-system-tests-present |                    │ +│check-system-tests-tocs | check-xml | codespell | create-missing-init-py-files-tests |  │ +│debug-statements | detect-private-key | doctoc | end-of-file-fixer | fix-encoding-pragma│ +│| flynt | forbid-tabs | identity | insert-license | isort | lint-chart-schema | lint-css│ +│| lint-dockerfile | lint-helm-chart | lint-javascript | lint-json-schema | lint-markdown│ +│| lint-openapi | mixed-line-ending | pretty-format-json | pydocstyle |                  │ +│python-no-log-warn | pyupgrade | rst-backticks | run-flake8 | run-mypy | run-shellcheck │ +│| static-check-autoflake | trailing-whitespace | update-breeze-cmd-output |             │ +│update-breeze-readme-config-hash | update-extras | update-in-the-wild-to-be-sorted |    │ +│update-inlined-dockerfile-scripts | update-local-yml-file | update-migration-references │ +│| update-providers-dependencies | update-setup-cfg-file |                               │ +│update-spelling-wordlist-to-be-sorted | update-supported-versions |                     │ +│update-vendored-in-k8s-json-schema | update-version | yamllint | yesqa)                 │ +│--file-fList of files to run the checks on.(PATH)│ +│--all-files-aRun checks on all files.│ +│--show-diff-on-failure-sShow diff for files modified by the checks.│ +│--last-commit-cRun checks for all files in last commit. Mutually exclusive with --commit-ref.│ +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│--commit-ref-rRun checks for this commit reference only (can be any git commit-ish reference). Mutually  │ +│exclusive with --last-commit.                                                              │ +│(TEXT)                                                                                     │ +│--verbose-vPrint verbose information about performed steps.│ +│--dry-run-DIf dry-run is set, commands are only printed, not executed.│ +│--github-repository-gGitHub repository used to pull, push run images.(TEXT)[default: apache/airflow]│ +│--help-hShow this message and exit.│ +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ 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 c01c6bfbf6b17..81b9fedf52f0e 100755 --- a/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py +++ b/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py @@ -30,6 +30,12 @@ SCREENSHOT_WIDTH = "120" +PREAMBLE = """ +# This file is automatically generated by pre-commit. If you have a conflict with this file +# Please do not solve it but run `breeze regenerate-command-images`. +# This command should fix the conflict and regenerate help images that you have conflict with. +""" + def get_command_list(): comp_env = os.environ.copy() @@ -61,7 +67,7 @@ def print_help_for_all_commands(): ) hash_file_path = BREEZE_IMAGES_DIR / "output-commands-hash.txt" try: - old_hash = hash_file_path.read_text() + old_hash = hash_file_path.read_text()[len(PREAMBLE) :] except FileNotFoundError: old_hash = "" if old_hash == new_hash: @@ -83,7 +89,7 @@ def print_help_for_all_commands(): env['RECORD_BREEZE_OUTPUT_FILE'] = str(BREEZE_IMAGES_DIR / f"output-{command}.svg") env['TERM'] = "xterm-256color" check_call(["breeze", command, "--help"], env=env) - hash_file_path.write_text(new_hash) + hash_file_path.write_text(PREAMBLE + new_hash) def verify_all_commands_described_in_docs(): @@ -114,3 +120,9 @@ def verify_all_commands_described_in_docs(): if __name__ == '__main__': print_help_for_all_commands() verify_all_commands_described_in_docs() + console = Console(width=int(SCREENSHOT_WIDTH), color_system="standard") + if os.environ.get('CI'): + console.print( + "\n\n[yellow] If you see that images got re-generatead in CI, please run:[/]" + "\n\n breeze regenerate-command-images\n\n\n" + )