Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
324 changes: 321 additions & 3 deletions .pre-commit-config.yaml

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions airflow-core/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ repos:
hooks:
- id: check-first-limit
name: Check single-row lookups have an explicit limit
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_first_limit.py
language: python
files: ^src/airflow/.*\.py$
pass_filenames: true
- id: check-airflow-k8s-not-used
name: Check airflow.kubernetes imports are not used
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
files: ^src/airflow/.*\.py$
require_serial: true
Expand All @@ -41,6 +45,8 @@ repos:
--message "You should only import kubernetes code from `airflow.providers.cncf.kubernetes`."
- id: check-common-compat-used-for-openlineage
name: Check common.compat is used for OL deprecated classes
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
files: ^src/airflow/.*\.py$
require_serial: true
Expand All @@ -50,6 +56,8 @@ repos:
--message "You should import from `airflow.providers.common.compat.openlineage.facet` instead."
- id: check-cncf-k8s-only-for-executors
name: Check cncf.kubernetes imports used for executors only
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
files: ^src/airflow/.*\.py$
require_serial: true
Expand All @@ -66,12 +74,16 @@ repos:
"Only few k8s executors exceptions are allowed to use `airflow.providers.cncf.kubernetes`."
- id: check-extra-packages-references
name: Checks setup extra packages
env:
PYTHONPYCACHEPREFIX: .build/pycache
description: Checks if extras defined in hatch_build.py are listed in extra-packages-ref.rst file
language: python
files: ^docs/extra-packages-ref\.rst$|^hatch_build\.py$
pass_filenames: false
entry: ../scripts/ci/prek/check_extra_packages_ref.py
- id: check-no-providers-in-core-examples
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: pygrep
name: No providers imports in core example DAGs
description: The core example DAGs have no dependencies other than standard provider or core Airflow
Expand All @@ -80,25 +92,33 @@ repos:
files: ^src/airflow/example_dags/.*\.py$
- id: check-only-new-session-with-provide-session
name: Check NEW_SESSION is only used with @provide_session
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/new_session_in_provide_session.py
pass_filenames: true
files: ^src/airflow/.+\.py$
exclude: ^src/airflow/serialization/pydantic/.*
- id: check-base-operator-partial-arguments
name: Check BaseOperator and partial() arguments
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/check_base_operator_partial_arguments.py
pass_filenames: false
files: ^src/airflow/models/(?:base|mapped)operator\.py$
- id: check-decorated-operator-implements-custom-name
name: Check @task decorator implements custom_operator_name
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/decorator_operator_implements_custom_name.py
pass_filenames: true
files: ^src/airflow/.*\.py$
- id: compile-ui-assets
name: Compile ui assets (manual)
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: node
stages: ['manual']
types_or: [javascript, ts, tsx]
Expand All @@ -111,6 +131,8 @@ repos:
additional_dependencies: ['pnpm@10.25.0']
- id: compile-ui-assets-dev
name: Compile ui assets in dev mode (manual)
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: node
stages: ['manual']
types_or: [javascript, ts, tsx]
Expand All @@ -123,13 +145,17 @@ repos:
additional_dependencies: ['pnpm@10.25.0']
- id: check-tests-in-the-right-folders
name: Check if tests are in the right folders
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_tests_in_right_folders.py
language: python
files: ^tests/.*\.py$
pass_filenames: true
require_serial: true
- id: lint-json-schema
name: Lint config_templates/config.yml
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/lint_json_schema.py
args:
- --spec-file
Expand All @@ -140,12 +166,16 @@ repos:
require_serial: true
- id: check-code-deprecations
name: Check deprecations categories in decorators
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_deprecations.py
language: python
pass_filenames: true
files: ^src/airflow/.*\.py$
- id: check-http-exception-import-from-fastapi
name: Check HTTPException is imported from fastapi
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_http_exception_import_from_fastapi.py
language: python
pass_filenames: true
Expand All @@ -157,24 +187,32 @@ repos:
^tests/unit/utils/test_serve_logs\.py$
- id: check-openapi-exception-doc-in-sync
name: Check API routes declare the HTTP statuses they raise
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_openapi_exception_doc_in_sync.py
language: python
pass_filenames: true
files: ^src/airflow/api_fastapi/.*/routes/.*\.py$
- id: create-missing-init-py-files-tests
name: Create missing init.py files in tests
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_init_in_tests.py
language: python
pass_filenames: false
files: ^tests/.*\.py$
- id: check-tests-unittest-testcase
name: Unit tests do not inherit from unittest.TestCase
env:
PYTHONPYCACHEPREFIX: .build/pycache
description: Check that unit tests do not inherit from unittest.TestCase
entry: ../scripts/ci/prek/unittest_testcase.py
language: python
pass_filenames: true
files: ^tests/.*\.py$
- id: check-no-fab-migrations
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: pygrep
name: Check no migration is done on FAB related table
description: >
Expand Down Expand Up @@ -202,6 +240,8 @@ repos:
^src/airflow/migrations/versions/0028_3_0_0_drop_ab_user_id_foreign_key\.py$
- id: ts-compile-lint-ui
name: Compile / format / lint UI
env:
PYTHONPYCACHEPREFIX: .build/pycache
description: TS types generation / ESLint / Prettier new UI files
language: node
files: |
Expand All @@ -218,6 +258,8 @@ repos:
require_serial: true
- id: ts-compile-lint-simple-auth-manager-ui
name: Compile / format / lint simple auth manager UI
env:
PYTHONPYCACHEPREFIX: .build/pycache
description: TS types generation / ESLint / Prettier new UI files
language: node
files: |
Expand All @@ -235,6 +277,8 @@ repos:
require_serial: true
- id: mypy-airflow-core
name: Run mypy for airflow-core
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/run_mypy_full_dist_local_venv_or_breeze_in_ci.py airflow-core
pass_filenames: false
Expand All @@ -244,6 +288,8 @@ repos:
# The below prek hooks are those requiring CI image to be built
- id: generate-openapi-spec
name: Generate the FastAPI API spec
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/generate_openapi_spec.py
pass_filenames: false
Expand All @@ -254,13 +300,17 @@ repos:
exclude: ^src/airflow/api_fastapi/execution_api/.*
- id: check-i18n-json
name: Check i18n files validity
env:
PYTHONPYCACHEPREFIX: .build/pycache
description: Check i18n files are valid json, have no TODOs, and auto-format them
language: python
files: ^src/airflow/ui/public/i18n/locales/.*\.json$
entry: ../scripts/ci/prek/check_i18n_json.py
pass_filenames: false
- id: update-migration-references
name: Update migration ref doc
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/migration_reference.py
args: ["--app", "airflow"]
Expand All @@ -271,6 +321,8 @@ repos:
^docs/migrations-ref\.rst$
- id: migration-round-trip
name: Migration round-trip SQLite FK enforcement
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/migration_round_trip.py
pass_filenames: false
Expand All @@ -279,13 +331,17 @@ repos:
files: ^src/airflow/migrations/versions/.*\.py$
- id: check-default-configuration
name: Check the default configuration
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_default_configuration.py
language: python
require_serial: true
pass_filenames: false
files: ^src/airflow/config_templates/config\.yml$
- id: check-security-doc-constants
name: Check security docs match config.yml constants
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_security_doc_constants.py
language: python
pass_filenames: false
Expand All @@ -295,6 +351,8 @@ repos:
^docs/security/jwt_token_authentication\.rst$|
^docs/security/security_model\.rst$
- id: check-airflow-version-checks-in-core
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: pygrep
name: No AIRFLOW_V_* imports in airflow-core
entry: "import AIRFLOW_V_"
Expand All @@ -312,13 +370,17 @@ repos:
^tests/unit/models/test_variable\.py$
- id: check-sdk-imports-in-core
name: Check for SDK imports in core files
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_sdk_imports_in_core.py
language: python
types: [python]
files: ^src/airflow/
## ONLY ADD PREK HOOKS HERE THAT REQUIRE CI IMAGE
- id: check-schema-defaults
name: Check schema defaults match server-side defaults
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_schema_defaults.py
language: python
files:
Expand Down
4 changes: 4 additions & 0 deletions airflow-ctl-tests/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ repos:
hooks:
- id: check-airflowctl-command-coverage
name: Check airflowctl CLI command test coverage
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_airflowctl_command_coverage.py
language: python
pass_filenames: false
Expand All @@ -32,6 +34,8 @@ repos:
^tests/airflowctl_tests/.*\.py$
- id: mypy-airflow-ctl-tests
name: Run mypy for airflow-ctl-tests
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/run_mypy_full_dist_local_venv_or_breeze_in_ci.py airflow-ctl-tests
pass_filenames: false
Expand Down
8 changes: 8 additions & 0 deletions airflow-ctl/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ repos:
hooks:
- id: mypy-airflow-ctl
name: Run mypy for airflow-ctl
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/run_mypy_full_dist_local_venv_or_breeze_in_ci.py airflow-ctl
pass_filenames: false
files: ^.*\.py$
require_serial: true
- id: generate-airflowctl-help-images
name: Generate SVG from Airflow CTL Commands
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/capture_airflowctl_help.py
language: python
pass_filenames: false
Expand All @@ -43,6 +47,8 @@ repos:
^src/airflowctl/ctl/commands/.*\.py$
- id: check-airflowctl-command-coverage
name: Check airflowctl CLI command test coverage
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_airflowctl_command_coverage.py
language: python
pass_filenames: false
Expand All @@ -52,6 +58,8 @@ repos:
^docs/images/command_hashes.txt$
- id: check-airflowctl-help-texts
name: Check airflowctl CLI commands have help texts
env:
PYTHONPYCACHEPREFIX: .build/pycache
entry: ../scripts/ci/prek/check_airflowctl_help_texts.py
language: python
pass_filenames: false
Expand Down
2 changes: 2 additions & 0 deletions airflow-e2e-tests/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ repos:
hooks:
- id: mypy-airflow-e2e-tests
name: Run mypy for airflow-e2e-tests
env:
PYTHONPYCACHEPREFIX: .build/pycache
language: python
entry: ../scripts/ci/prek/run_mypy_full_dist_local_venv_or_breeze_in_ci.py airflow-e2e-tests
pass_filenames: false
Expand Down
Loading
Loading