From 48e51d6803089e9e1065ae05cb641bca2ec922f7 Mon Sep 17 00:00:00 2001 From: Amogh Desai Date: Thu, 1 Jan 2026 11:05:55 +0530 Subject: [PATCH] Run airflow-ctl integration tests conditionally on airflowctl changes --- .../workflows/additional-prod-image-tests.yml | 5 ++ .github/workflows/ci-amd-arm.yml | 2 + .../airflow_breeze/utils/selective_checks.py | 12 ++++ dev/breeze/tests/test_selective_checks.py | 55 +++++++++++++++++++ 4 files changed, 74 insertions(+) diff --git a/.github/workflows/additional-prod-image-tests.yml b/.github/workflows/additional-prod-image-tests.yml index d4e2d4061a8de..94c6f1d933694 100644 --- a/.github/workflows/additional-prod-image-tests.yml +++ b/.github/workflows/additional-prod-image-tests.yml @@ -68,6 +68,10 @@ on: # yamllint disable-line rule:truthy description: "Whether to run UI e2e tests (true/false)" required: true type: string + run-airflow-ctl-integration-tests: + description: "Whether to run Airflow CTL integration tests (true/false)" + required: true + type: string permissions: contents: read jobs: @@ -288,3 +292,4 @@ jobs: id: breeze - name: "Run airflowctl integration tests" run: breeze testing airflow-ctl-integration-tests + if: inputs.run-airflow-ctl-integration-tests == 'true' diff --git a/.github/workflows/ci-amd-arm.yml b/.github/workflows/ci-amd-arm.yml index ca1954acfdb3e..dccf4125a8eab 100644 --- a/.github/workflows/ci-amd-arm.yml +++ b/.github/workflows/ci-amd-arm.yml @@ -105,6 +105,7 @@ jobs: python-versions-list-as-string: ${{ steps.selective-checks.outputs.python-versions-list-as-string }} python-versions: ${{ steps.selective-checks.outputs.python-versions }} run-airflow-ctl-tests: ${{ steps.selective-checks.outputs.run-airflow-ctl-tests }} + run-airflow-ctl-integration-tests: ${{ steps.selective-checks.outputs.run-airflow-ctl-integration-tests }} run-amazon-tests: ${{ steps.selective-checks.outputs.run-amazon-tests }} run-api-codegen: ${{ steps.selective-checks.outputs.run-api-codegen }} run-api-tests: ${{ steps.selective-checks.outputs.run-api-tests }} @@ -792,6 +793,7 @@ jobs: canary-run: ${{ needs.build-info.outputs.canary-run }} use-uv: ${{ needs.build-info.outputs.use-uv }} run-ui-e2e-tests: ${{ needs.build-info.outputs.run-ui-e2e-tests }} + run-airflow-ctl-integration-tests: ${{ needs.build-info.outputs.run-airflow-ctl-integration-tests }} if: needs.build-info.outputs.prod-image-build == 'true' tests-kubernetes: diff --git a/dev/breeze/src/airflow_breeze/utils/selective_checks.py b/dev/breeze/src/airflow_breeze/utils/selective_checks.py index c897f0509bcb2..844729fe460c8 100644 --- a/dev/breeze/src/airflow_breeze/utils/selective_checks.py +++ b/dev/breeze/src/airflow_breeze/utils/selective_checks.py @@ -118,6 +118,7 @@ class FileGroupForCi(Enum): TASK_SDK_INTEGRATION_TEST_FILES = auto() GO_SDK_FILES = auto() AIRFLOW_CTL_FILES = auto() + AIRFLOW_CTL_INTEGRATION_TEST_FILES = auto() ALL_PYPROJECT_TOML_FILES = auto() ALL_PYTHON_FILES = auto() ALL_SOURCE_FILES = auto() @@ -307,6 +308,9 @@ def __hash__(self): r"^airflow-ctl/src/airflowctl/.*\.py$", r"^airflow-ctl/tests/.*\.py$", ], + FileGroupForCi.AIRFLOW_CTL_INTEGRATION_TEST_FILES: [ + r"^airflow-ctl-tests/.*\.py$", + ], FileGroupForCi.DEVEL_TOML_FILES: [ r"^devel-common/pyproject\.toml$", ], @@ -899,6 +903,12 @@ def run_go_sdk_tests(self) -> bool: def run_airflow_ctl_tests(self) -> bool: return self._should_be_run(FileGroupForCi.AIRFLOW_CTL_FILES) + @cached_property + def run_airflow_ctl_integration_tests(self) -> bool: + return self._should_be_run(FileGroupForCi.AIRFLOW_CTL_FILES) or self._should_be_run( + FileGroupForCi.AIRFLOW_CTL_INTEGRATION_TEST_FILES + ) + @cached_property def run_kubernetes_tests(self) -> bool: return self._should_be_run(FileGroupForCi.KUBERNETES_FILES) @@ -951,6 +961,7 @@ def ci_image_build(self) -> bool: or self.docs_build or self.run_kubernetes_tests or self.run_task_sdk_integration_tests + or self.run_airflow_ctl_integration_tests or self.run_helm_tests or self.run_ui_tests or self.pyproject_toml_changed @@ -963,6 +974,7 @@ def prod_image_build(self) -> bool: self.run_kubernetes_tests or self.run_helm_tests or self.run_task_sdk_integration_tests + or self.run_airflow_ctl_integration_tests or self.run_ui_e2e_tests ) diff --git a/dev/breeze/tests/test_selective_checks.py b/dev/breeze/tests/test_selective_checks.py index 6c5139d221410..66a356dda4deb 100644 --- a/dev/breeze/tests/test_selective_checks.py +++ b/dev/breeze/tests/test_selective_checks.py @@ -649,6 +649,61 @@ def assert_outputs_are_printed(expected_outputs: dict[str, str], stderr: str): "Task SDK integration tests and prod image build should run but no other tests", ) ), + ( + pytest.param( + ("airflow-ctl/src/airflowctl/random.py",), + { + "all-python-versions": f"['{DEFAULT_PYTHON_MAJOR_MINOR_VERSION}']", + "all-python-versions-list-as-string": DEFAULT_PYTHON_MAJOR_MINOR_VERSION, + "python-versions": f"['{DEFAULT_PYTHON_MAJOR_MINOR_VERSION}']", + "python-versions-list-as-string": DEFAULT_PYTHON_MAJOR_MINOR_VERSION, + "ci-image-build": "true", + "prod-image-build": "true", + "run-api-tests": "false", + "run-helm-tests": "false", + "run-kubernetes-tests": "false", + "run-unit-tests": "true", + "run-airflow-ctl-tests": "true", + "run-airflow-ctl-integration-tests": "true", + "docs-build": "true", + "full-tests-needed": "false", + "skip-prek-hooks": ALL_SKIPPED_COMMITS_IF_NO_PROVIDERS_UI_AND_HELM_TESTS, + "skip-providers-tests": "true", + "upgrade-to-newer-dependencies": "false", + "run-mypy": "true", + "mypy-checks": "['mypy-airflow-ctl']", + }, + id="Airflow CTL source file changed - Airflow CTL tests should run", + ) + ), + ( + pytest.param( + ("airflow-ctl-tests/tests/random.py",), + { + "all-python-versions": f"['{DEFAULT_PYTHON_MAJOR_MINOR_VERSION}']", + "all-python-versions-list-as-string": DEFAULT_PYTHON_MAJOR_MINOR_VERSION, + "python-versions": f"['{DEFAULT_PYTHON_MAJOR_MINOR_VERSION}']", + "python-versions-list-as-string": DEFAULT_PYTHON_MAJOR_MINOR_VERSION, + "ci-image-build": "true", + "prod-image-build": "true", + "run-api-tests": "false", + "run-helm-tests": "false", + "run-kubernetes-tests": "false", + "run-unit-tests": "false", + "run-airflow-ctl-tests": "false", + "run-airflow-ctl-integration-tests": "true", + "docs-build": "false", + "full-tests-needed": "false", + "skip-prek-hooks": ALL_SKIPPED_COMMITS_IF_NO_PROVIDERS_UI_AND_HELM_TESTS, + "skip-providers-tests": "true", + "upgrade-to-newer-dependencies": "false", + "run-mypy": "false", + "mypy-checks": "[]", + }, + id="Airflow CTL integration tests files changed - " + "Airflow CTL integration tests and prod image build should run but no other tests", + ) + ), ( pytest.param( (