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 fcf0970bc3 Run MSSQL tests when PR contains DB migrations (#33265)
fcf0970bc3 is described below
commit fcf0970bc3df69e53c9dad7535b61f9e7d91a3c7
Author: Jarek Potiuk <[email protected]>
AuthorDate: Wed Aug 9 21:41:00 2023 +0200
Run MSSQL tests when PR contains DB migrations (#33265)
We skip MSSQL tests usually for stability, but when the PR
contains migrations, we should always run them.
---
.github/workflows/ci.yml | 4 +++-
.../src/airflow_breeze/utils/selective_checks.py | 4 ++++
dev/breeze/tests/test_selective_checks.py | 27 ++++++++++++++++++++++
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 889ee7292d..59c4a0adb1 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -121,6 +121,7 @@ jobs:
helm-test-packages: ${{
steps.selective-checks.outputs.helm-test-packages }}
debug-resources: ${{ steps.selective-checks.outputs.debug-resources }}
runs-on: ${{ steps.selective-checks.outputs.runs-on }}
+ has-migrations: ${{ steps.selective-checks.outputs.has-migrations }}
source-head-repo: ${{ steps.source-run-info.outputs.source-head-repo }}
pull-request-labels: ${{ steps.source-run-info.outputs.pr-labels }}
in-workflow-build: ${{ steps.source-run-info.outputs.in-workflow-build }}
@@ -1153,7 +1154,8 @@ jobs:
if: >
needs.build-info.outputs.run-tests == 'true' &&
(needs.build-info.outputs.runs-on == 'self-hosted' ||
- needs.build-info.outputs.full-tests-needed == 'true')
+ needs.build-info.outputs.full-tests-needed == 'true' ||
+ needs.build-info.outputs.has-migrations == 'true')
steps:
- name: Cleanup repo
shell: bash
diff --git a/dev/breeze/src/airflow_breeze/utils/selective_checks.py
b/dev/breeze/src/airflow_breeze/utils/selective_checks.py
index 6f9fc51d88..7dfbabf8b7 100644
--- a/dev/breeze/src/airflow_breeze/utils/selective_checks.py
+++ b/dev/breeze/src/airflow_breeze/utils/selective_checks.py
@@ -813,3 +813,7 @@ class SelectiveChecks:
def mssql_parallelism(self) -> int:
# Limit parallelism for MSSQL to 1 for public runners due to race
conditions generated there
return SELF_HOSTED_RUNNERS_CPU_COUNT if self.runs_on ==
RUNS_ON_SELF_HOSTED_RUNNER else 1
+
+ @cached_property
+ def has_migrations(self) -> bool:
+ return any([file.startswith("airflow/migrations/") for file in
self._files])
diff --git a/dev/breeze/tests/test_selective_checks.py
b/dev/breeze/tests/test_selective_checks.py
index 9bd83c15c8..4e447d24c1 100644
--- a/dev/breeze/tests/test_selective_checks.py
+++ b/dev/breeze/tests/test_selective_checks.py
@@ -1299,3 +1299,30 @@ def test_runs_on(
default_branch="main",
)
assert_outputs_are_printed({"runs-on": runs_on}, str(stderr))
+
+
[email protected](
+ "files, has_migrations",
+ [
+ pytest.param(
+ ("airflow/test.py",),
+ False,
+ id="No migrations",
+ ),
+ pytest.param(
+ ("airflow/migrations/test_sql", "aiflow/test.py"),
+ True,
+ id="With migrations",
+ ),
+ ],
+)
+def test_has_migrations(files: tuple[str, ...], has_migrations: bool):
+ stderr = str(
+ SelectiveChecks(
+ files=files,
+ commit_ref="HEAD",
+ github_event=GithubEvents.PULL_REQUEST,
+ default_branch="main",
+ )
+ )
+ assert_outputs_are_printed({"has-migrations":
str(has_migrations).lower()}, str(stderr))