diff --git a/dev/breeze/doc/ci/04_selective_checks.md b/dev/breeze/doc/ci/04_selective_checks.md index 5e3c231b5feb9..f8e27582ee9b1 100644 --- a/dev/breeze/doc/ci/04_selective_checks.md +++ b/dev/breeze/doc/ci/04_selective_checks.md @@ -508,8 +508,11 @@ when some files are not changed. Those are the rules implemented: skipped (it regenerates and diffs the generated ts-sdk file; a change to the supervisor wire schema alone deliberately does not trigger it - regenerating the ts-sdk types is the ts-sdk follow-up PR's job, not the schema author's) - * if no `All Providers Python files` and no `All Providers Yaml files` are changed - - `check-provider-yaml-valid` check is skipped + * `check-provider-yaml-valid` is skipped unless at least one of these changed: + `All Providers Python files`, `All Providers Distribution Config files` + (which includes `provider.yaml`, `pyproject.toml`, and `providers/.pre-commit-config.yaml`), + or `Prek files` (`scripts/ci/prek/`). The last condition ensures the check runs + when the check script itself is modified. ## Suspended providers diff --git a/dev/breeze/src/airflow_breeze/utils/selective_checks.py b/dev/breeze/src/airflow_breeze/utils/selective_checks.py index f03d468e7ca1f..95fe83b0e3853 100644 --- a/dev/breeze/src/airflow_breeze/utils/selective_checks.py +++ b/dev/breeze/src/airflow_breeze/utils/selective_checks.py @@ -399,6 +399,7 @@ def __hash__(self): FileGroupForCi.ALL_PROVIDERS_DISTRIBUTION_CONFIG_FILES: [ r"^providers/.*/pyproject\.toml$", r"^providers/.*/provider\.yaml$", + r"^providers/\.pre-commit-config\.yaml$", ], FileGroupForCi.ALL_DEV_PYTHON_FILES: [ r"^dev/.*\.py$", @@ -1696,9 +1697,12 @@ def skip_prek_hooks(self) -> str: FileGroupForCi.ALL_PROVIDERS_DISTRIBUTION_CONFIG_FILES, CI_FILE_GROUP_MATCHES ) or self._matching_files(FileGroupForCi.ALL_PROVIDERS_PYTHON_FILES, CI_FILE_GROUP_MATCHES) + or self._matching_files(FileGroupForCi.PREK_FILES, CI_FILE_GROUP_MATCHES) ): - # only skip provider validation if none of the provider.yaml and provider - # python files changed because validation also walks through all the provider python files + # Skip provider validation only when none of these changed: + # - provider.yaml / pyproject.toml / providers/.pre-commit-config.yaml + # - provider Python files (validation walks all provider Python files) + # - prek scripts (the check script itself may have changed) prek_hooks_to_skip.add("check-provider-yaml-valid") # Non-provider mypy checks run as prek hooks in static checks. # Skip them when their relevant files haven't changed, unless devel-common diff --git a/dev/breeze/tests/test_selective_checks.py b/dev/breeze/tests/test_selective_checks.py index 8b215ba4dd86a..1dac0e3dd8354 100644 --- a/dev/breeze/tests/test_selective_checks.py +++ b/dev/breeze/tests/test_selective_checks.py @@ -2014,6 +2014,37 @@ def test_full_test_needed_when_scripts_changes(files: tuple[str, ...], expected_ assert_outputs_are_printed(expected_outputs, str(stderr)) +@pytest.mark.parametrize( + "files", + [ + pytest.param( + ("scripts/ci/prek/check_provider_yaml_files.py",), + id="provider yaml check script changed", + ), + pytest.param( + ("providers/.pre-commit-config.yaml",), + id="providers prek config changed", + ), + pytest.param( + ( + "scripts/ci/prek/check_provider_yaml_files.py", + "providers/.pre-commit-config.yaml", + ), + id="provider yaml check script and providers prek config changed together", + ), + ], +) +def test_provider_yaml_check_not_skipped_when_check_scripts_change(files: tuple[str, ...]): + stderr = SelectiveChecks( + files=files, + github_event=GithubEvents.PULL_REQUEST, + commit_ref=NEUTRAL_COMMIT, + default_branch="main", + ) + skip_prek_hooks = str(stderr).split("skip-prek-hooks=")[1].split("\n")[0] + assert "check-provider-yaml-valid" not in skip_prek_hooks.split(",") + + @pytest.mark.parametrize( ("files", "expected_outputs"), [