This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-8-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 884a35fba5abbbad3e36274320830b933862ae61
Author: Vincent <[email protected]>
AuthorDate: Tue Nov 28 18:19:30 2023 -0500

    Create pre-commit script to prevent creating FAB related migrations in core 
Airflow (#35927)
    
    (cherry picked from commit 6393b3515fbb7aabb1613f61204686e89479a5a0)
---
 .pre-commit-config.yaml                         | 32 +++++++++++++++++++++++++
 STATIC_CODE_CHECKS.rst                          |  2 ++
 dev/breeze/src/airflow_breeze/pre_commit_ids.py |  1 +
 images/breeze/output_static-checks.svg          |  2 +-
 images/breeze/output_static-checks.txt          |  2 +-
 5 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index afccaf7810..7d0384c14b 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 95e71cccb7..0c064ef5fd 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 cdb138f2e6..9725087609 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 @@ PRE_COMMIT_LIST = [
     "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 51ee1a2b3e..a30351839b 100644
--- a/images/breeze/output_static-checks.svg
+++ b/images/breeze/output_static-checks.svg
@@ -314,7 +314,7 @@
 </text><text class="breeze-static-checks-r5" x="0" y="361.6" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-14)">│</text><text 
class="breeze-static-checks-r7" x="451.4" y="361.6" textLength="988.2" 
clip-path="url(#breeze-static-checks-line-14)">check-daysago-import-from-utils&#160;|&#160;check-decorated-operator-implements-custom-name</text><text
 class="breeze-static-checks-r5" x="1451.8" y="361.6" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-14)">│</text><tex [...]
 </text><text class="breeze-static-checks-r5" x="0" y="386" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-15)">│</text><text 
class="breeze-static-checks-r7" x="451.4" y="386" textLength="988.2" 
clip-path="url(#breeze-static-checks-line-15)">|&#160;check-deferrable-default-value&#160;|&#160;check-docstring-param-types&#160;|&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text
 class="breeze-static-checks-r5" x="1451 [...]
 </text><text class="breeze-static-checks-r5" x="0" y="410.4" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-16)">│</text><text 
class="breeze-static-checks-r7" x="451.4" y="410.4" textLength="988.2" 
clip-path="url(#breeze-static-checks-line-16)">check-example-dags-urls&#160;|&#160;check-executables-have-shebangs&#160;|&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text
 class="breeze-s [...]
-</text><text class="breeze-static-checks-r5" x="0" y="434.8" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-17)">│</text><text 
class="breeze-static-checks-r7" x="451.4" y="434.8" textLength="988.2" 
clip-path="url(#breeze-static-checks-line-17)">check-extra-packages-references&#160;|&#160;check-extras-order&#160;|&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</t
 [...]
+</text><text class="breeze-static-checks-r5" x="0" y="434.8" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-17)">│</text><text 
class="breeze-static-checks-r7" x="451.4" y="434.8" textLength="988.2" 
clip-path="url(#breeze-static-checks-line-17)">check-extra-packages-references&#160;|&#160;check-extras-order&#160;|&#160;check-fab-migrations&#160;|&#160;&#160;&#160;&#160;</text><text
 class="breeze-static-checks-r5" x="1451.8" y="434.8" textLength="12.2" 
clip-path="url(#breeze-s [...]
 </text><text class="breeze-static-checks-r5" x="0" y="459.2" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-18)">│</text><text 
class="breeze-static-checks-r7" x="451.4" y="459.2" textLength="988.2" 
clip-path="url(#breeze-static-checks-line-18)">check-for-inclusive-language&#160;|&#160;check-google-re2-as-dependency&#160;|&#160;check-hooks-apply</text><text
 class="breeze-static-checks-r5" x="1451.8" y="459.2" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-18)">│< [...]
 </text><text class="breeze-static-checks-r5" x="0" y="483.6" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-19)">│</text><text 
class="breeze-static-checks-r7" x="451.4" y="483.6" textLength="988.2" 
clip-path="url(#breeze-static-checks-line-19)">|&#160;check-incorrect-use-of-LoggingMixin&#160;|&#160;check-init-decorator-arguments&#160;|&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text
 class="breeze-static-checks-r5" x="1451.8" y="483.6" textLength="12.2" clip 
[...]
 </text><text class="breeze-static-checks-r5" x="0" y="508" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-20)">│</text><text 
class="breeze-static-checks-r7" x="451.4" y="508" textLength="988.2" 
clip-path="url(#breeze-static-checks-line-20)">check-lazy-logging&#160;|&#160;check-links-to-example-dags-do-not-use-hardcoded-versions&#160;|&#160;</text><text
 class="breeze-static-checks-r5" x="1451.8" y="508" textLength="12.2" 
clip-path="url(#breeze-static-checks-line-20)">│</text> [...]
diff --git a/images/breeze/output_static-checks.txt 
b/images/breeze/output_static-checks.txt
index b53957c368..db19bfb4e6 100644
--- a/images/breeze/output_static-checks.txt
+++ b/images/breeze/output_static-checks.txt
@@ -1 +1 @@
-e8250c9df1b2d0e6be8267102688c14b
+4f78b9aa5b7e62a2ceca1478900d74d9

Reply via email to