diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index afccaf7810bc8..7d0384c14bd22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1025,6 +1025,38 @@ repos: - "B301,B324,B403,B404,B603" - "--severity-level" - "high" # TODO: remove this line when we fix all the issues + - id: check-fab-migrations + language: pygrep + name: Check no migration is done on FAB related table + description: > + FAB tables are no longer used in core Airflow but in FAB provider. + As such, it is forbidden to create migrations related to FAB tables in core Airflow. + Such migrations should be in FAB provider. To achieve this, a new capability must be implemented: + support migrations for providers. In other words, providers need to be able to specify migrations + so that, any FAB related migration (besides the legacy ones) is defined in FAB provider. + See https://github.com/apache/airflow/issues/32210 + entry: > + (?ix) + \bab_permission\b| + \bab_view_menu\b| + \bab_role\b| + \bab_permission_view\b| + \bab_permission_view_role\b| + \bab_user\b| + \bab_user_role\b| + \bab_register_user\b + pass_filenames: true + files: ^airflow/migrations/versions/.*\.py$ + # These migrations contain FAB related changes but existed before moving FAB auth manager + # to its own provider + exclude: > + (?ix) + ^airflow/migrations/versions/00.*\.py$| + ^airflow/migrations/versions/0106.*\.py$| + ^airflow/migrations/versions/0118.*\.py$| + ^airflow/migrations/versions/0119.*\.py$| + ^airflow/migrations/versions/0121.*\.py$| + ^airflow/migrations/versions/0124.*\.py$ ## ADD MOST PRE-COMMITS ABOVE THAT LINE # The below pre-commits are those requiring CI image to be built - id: mypy-dev diff --git a/STATIC_CODE_CHECKS.rst b/STATIC_CODE_CHECKS.rst index 95e71cccb7ae5..0c064ef5fd59b 100644 --- a/STATIC_CODE_CHECKS.rst +++ b/STATIC_CODE_CHECKS.rst @@ -188,6 +188,8 @@ require Breeze Docker image to be built locally. +-----------------------------------------------------------+--------------------------------------------------------------+---------+ | check-extras-order | Check order of extras in Dockerfile | | +-----------------------------------------------------------+--------------------------------------------------------------+---------+ +| check-fab-migrations | Check no migration is done on FAB related table | | ++-----------------------------------------------------------+--------------------------------------------------------------+---------+ | check-for-inclusive-language | Check for language that we do not accept as community | | +-----------------------------------------------------------+--------------------------------------------------------------+---------+ | check-google-re2-as-dependency | Check google-re2 is declared as dependency when needed | | diff --git a/dev/breeze/src/airflow_breeze/pre_commit_ids.py b/dev/breeze/src/airflow_breeze/pre_commit_ids.py index cdb138f2e6fd1..972508760988e 100644 --- a/dev/breeze/src/airflow_breeze/pre_commit_ids.py +++ b/dev/breeze/src/airflow_breeze/pre_commit_ids.py @@ -47,6 +47,7 @@ "check-executables-have-shebangs", "check-extra-packages-references", "check-extras-order", + "check-fab-migrations", "check-for-inclusive-language", "check-google-re2-as-dependency", "check-hooks-apply", diff --git a/images/breeze/output_static-checks.svg b/images/breeze/output_static-checks.svg index 51ee1a2b3ee1e..a30351839bb5b 100644 --- a/images/breeze/output_static-checks.svg +++ b/images/breeze/output_static-checks.svg @@ -314,7 +314,7 @@ check-daysago-import-from-utils | check-decorated-operator-implements-custom-name | check-deferrable-default-value | check-docstring-param-types |                  check-example-dags-urls | check-executables-have-shebangs |                       -check-extra-packages-references | check-extras-order |                            +check-extra-packages-references | check-extras-order | check-fab-migrations |     check-for-inclusive-language | check-google-re2-as-dependency | check-hooks-apply | check-incorrect-use-of-LoggingMixin | check-init-decorator-arguments |          check-lazy-logging | check-links-to-example-dags-do-not-use-hardcoded-versions |  diff --git a/images/breeze/output_static-checks.txt b/images/breeze/output_static-checks.txt index b53957c36895b..db19bfb4e62a5 100644 --- a/images/breeze/output_static-checks.txt +++ b/images/breeze/output_static-checks.txt @@ -1 +1 @@ -e8250c9df1b2d0e6be8267102688c14b +4f78b9aa5b7e62a2ceca1478900d74d9