From 1479cf6a23b5e5fe677d19fb517efdcf5dc96b47 Mon Sep 17 00:00:00 2001 From: Bugra Ozturk Date: Sat, 5 Oct 2024 03:08:18 +0200 Subject: [PATCH] Include Selective Check to Ping Maintainer about Legacy WWW and API Changes (#42758) * Include new check in selective_checks.py for checking PR labels to ping maintainers about updating legacy ui or legacy api code piece * Remove airflow/api from LEGACY_API_FILES --- .../airflow_breeze/utils/selective_checks.py | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/dev/breeze/src/airflow_breeze/utils/selective_checks.py b/dev/breeze/src/airflow_breeze/utils/selective_checks.py index 3b3408d06cfc..b5bea53d8b68 100644 --- a/dev/breeze/src/airflow_breeze/utils/selective_checks.py +++ b/dev/breeze/src/airflow_breeze/utils/selective_checks.py @@ -76,6 +76,8 @@ FULL_TESTS_NEEDED_LABEL = "full tests needed" INCLUDE_SUCCESS_OUTPUTS_LABEL = "include success outputs" LATEST_VERSIONS_ONLY_LABEL = "latest versions only" +LEGACY_UI_LABEL = "legacy ui" +LEGACY_API_LABEL = "legacy api" NON_COMMITTER_BUILD_LABEL = "non committer build" UPGRADE_TO_NEWER_DEPENDENCIES_LABEL = "upgrade to newer dependencies" USE_PUBLIC_RUNNERS_LABEL = "use public runners" @@ -102,11 +104,12 @@ class FileGroupForCi(Enum): ALWAYS_TESTS_FILES = "always_test_files" API_TEST_FILES = "api_test_files" API_CODEGEN_FILES = "api_codegen_files" + LEGACY_API_FILES = "legacy_api_files" HELM_FILES = "helm_files" DEPENDENCY_FILES = "dependency_files" DOC_FILES = "doc_files" UI_FILES = "ui_files" - WWW_FILES = "www_files" + LEGACY_WWW_FILES = "legacy_www_files" SYSTEM_TEST_FILES = "system_tests" KUBERNETES_FILES = "kubernetes_files" ALL_PYTHON_FILES = "all_python_files" @@ -157,6 +160,9 @@ def __hash__(self): r"^airflow/api_connexion/openapi/v1\.yaml", r"^clients/gen", ], + FileGroupForCi.LEGACY_API_FILES: [ + r"^airflow/api_connexion/", + ], FileGroupForCi.HELM_FILES: [ r"^chart", r"^airflow/kubernetes", @@ -185,7 +191,7 @@ def __hash__(self): r"^airflow/ui/[^/]+\.json$", r"^airflow/ui/.*\.lock$", ], - FileGroupForCi.WWW_FILES: [ + FileGroupForCi.LEGACY_WWW_FILES: [ r"^airflow/www/.*\.ts[x]?$", r"^airflow/www/.*\.js[x]?$", r"^airflow/www/[^/]+\.json$", @@ -680,7 +686,7 @@ def run_ui_tests(self) -> bool: @cached_property def run_www_tests(self) -> bool: - return self._should_be_run(FileGroupForCi.WWW_FILES) + return self._should_be_run(FileGroupForCi.LEGACY_WWW_FILES) @cached_property def run_amazon_tests(self) -> bool: @@ -1055,7 +1061,9 @@ def skip_pre_commits(self) -> str: # when full tests are needed, we do not want to skip any checks and we should # run all the pre-commits just to be sure everything is ok when some structural changes occurred return ",".join(sorted(pre_commits_to_skip)) - if not self._matching_files(FileGroupForCi.WWW_FILES, CI_FILE_GROUP_MATCHES, CI_FILE_GROUP_EXCLUDES): + if not self._matching_files( + FileGroupForCi.LEGACY_WWW_FILES, CI_FILE_GROUP_MATCHES, CI_FILE_GROUP_EXCLUDES + ): pre_commits_to_skip.add("ts-compile-format-lint-www") if not self._matching_files(FileGroupForCi.UI_FILES, CI_FILE_GROUP_MATCHES, CI_FILE_GROUP_EXCLUDES): pre_commits_to_skip.add("ts-compile-format-lint-ui") @@ -1354,3 +1362,32 @@ def _is_canary_run(self): self._github_event in [GithubEvents.SCHEDULE, GithubEvents.PUSH] and self._github_repository == APACHE_AIRFLOW_GITHUB_REPOSITORY ) or CANARY_LABEL in self._pr_labels + + @cached_property + def is_legacy_ui_api_labeled(self) -> bool: + # Selective check for legacy UI/API updates. + # It is to ping the maintainer to add the label and make them aware of the changes. + if ( + self._matching_files( + FileGroupForCi.LEGACY_API_FILES, CI_FILE_GROUP_MATCHES, CI_FILE_GROUP_EXCLUDES + ) + and LEGACY_API_LABEL not in self._pr_labels + ): + get_console().print( + f"[error]Please ask maintainer to assign " + f"the '{LEGACY_API_LABEL}' label to the PR in order to continue" + ) + sys.exit(1) + elif ( + self._matching_files( + FileGroupForCi.LEGACY_WWW_FILES, CI_FILE_GROUP_MATCHES, CI_FILE_GROUP_EXCLUDES + ) + and LEGACY_UI_LABEL not in self._pr_labels + ): + get_console().print( + f"[error]Please ask maintainer to assign " + f"the '{LEGACY_UI_LABEL}' label to the PR in order to continue" + ) + sys.exit(1) + else: + return True