2019-08-15 03:53:28 +03:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
---
|
|
|
|
default_stages: [commit, push]
|
2019-08-22 17:13:56 +03:00
|
|
|
default_language_version:
|
|
|
|
# force all unspecified python hooks to run python3
|
|
|
|
python: python3
|
2019-11-04 11:50:06 +03:00
|
|
|
minimum_pre_commit_version: "1.20.0"
|
2019-08-15 03:53:28 +03:00
|
|
|
repos:
|
2019-09-04 16:56:03 +03:00
|
|
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
|
|
|
rev: v1.1.7
|
2019-08-16 02:59:35 +03:00
|
|
|
hooks:
|
2019-08-16 17:35:34 +03:00
|
|
|
- id: forbid-tabs
|
|
|
|
exclude: ^airflow/_vendor/.*$|^docs/Makefile$
|
2019-08-16 02:59:35 +03:00
|
|
|
- id: insert-license
|
2019-10-26 14:31:51 +03:00
|
|
|
name: Add license for all SQL files
|
2019-08-16 02:59:35 +03:00
|
|
|
files: \.sql$
|
|
|
|
exclude: ^\.github/.*$|^airflow/_vendor/.*$
|
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "/*||*/"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.txt
|
2019-08-27 21:06:41 +03:00
|
|
|
- --fuzzy-match-generates-todo
|
2019-08-16 03:02:53 +03:00
|
|
|
- id: insert-license
|
2019-10-26 14:31:51 +03:00
|
|
|
name: Add license for all other files
|
2019-08-16 03:02:53 +03:00
|
|
|
exclude: ^\.github/.*$"|^airflow/_vendor/.*$
|
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "|#|"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.txt
|
2019-08-27 21:06:41 +03:00
|
|
|
- --fuzzy-match-generates-todo
|
2019-08-16 03:02:53 +03:00
|
|
|
files: >
|
|
|
|
\.properties$|\.cfg$|\.conf$|\.ini$|\.ldif$|\.readthedocs$|\.service$|^Dockerfile.*$
|
2019-08-16 07:09:26 +03:00
|
|
|
- id: insert-license
|
2019-10-26 14:31:51 +03:00
|
|
|
name: Add license for all rst files
|
2019-08-16 07:09:26 +03:00
|
|
|
exclude: ^\.github/.*$"|^airflow/_vendor/.*$
|
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "||"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.rst
|
2019-08-27 21:06:41 +03:00
|
|
|
- --fuzzy-match-generates-todo
|
2019-08-16 07:09:26 +03:00
|
|
|
files: \.rst$
|
2019-08-16 03:06:18 +03:00
|
|
|
- id: insert-license
|
2019-11-26 00:11:26 +03:00
|
|
|
name: Add license for all JS/CSS files
|
|
|
|
files: \.(js|css)$
|
2019-08-16 03:06:18 +03:00
|
|
|
exclude: ^\.github/.*$|^airflow/_vendor/.*$
|
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "/**| *| */"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.txt
|
2019-08-27 21:06:41 +03:00
|
|
|
- --fuzzy-match-generates-todo
|
|
|
|
- id: insert-license
|
2019-10-26 14:31:51 +03:00
|
|
|
name: Add license for all JINJA template files
|
2019-10-15 13:56:09 +03:00
|
|
|
files: ^airflow/www/templates/.*\.html$|^docs/templates/.*\.html$|^airflow/contrib/plugins/metastore_browser/templates/.*\.html$ # yamllint disable-line rule:line-length
|
2019-08-27 21:06:41 +03:00
|
|
|
exclude: ^\.github/.*$|^airflow/_vendor/.*$
|
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "{#||#}"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.txt
|
|
|
|
- --fuzzy-match-generates-todo
|
2019-08-20 07:07:39 +03:00
|
|
|
- id: insert-license
|
2019-10-26 14:31:51 +03:00
|
|
|
name: Add license for all shell files
|
2019-08-20 07:07:39 +03:00
|
|
|
exclude: ^\.github/.*$"|^airflow/_vendor/.*$
|
2020-01-07 17:38:05 +03:00
|
|
|
files: ^breeze$|^breeze-complete$|\.sh$|\.bash$|\.bats$
|
2019-08-20 07:07:39 +03:00
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "|#|"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.txt
|
2019-08-27 21:06:41 +03:00
|
|
|
- --fuzzy-match-generates-todo
|
2019-09-17 14:16:32 +03:00
|
|
|
- id: insert-license
|
2019-10-26 14:31:51 +03:00
|
|
|
name: Add license for all python files
|
2019-09-17 14:16:32 +03:00
|
|
|
exclude: ^\.github/.*$"|^airflow/_vendor/.*$
|
|
|
|
types: [python]
|
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "|#|"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.txt
|
|
|
|
- --fuzzy-match-generates-todo
|
2019-08-20 17:29:34 +03:00
|
|
|
- id: insert-license
|
2019-10-26 14:31:51 +03:00
|
|
|
name: Add license for all XML files
|
2019-08-20 17:29:34 +03:00
|
|
|
exclude: ^\.github/.*$"|^airflow/_vendor/.*$
|
|
|
|
types: [xml]
|
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "<!--||-->"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.txt
|
2019-08-27 21:06:41 +03:00
|
|
|
- --fuzzy-match-generates-todo
|
2019-08-22 17:13:56 +03:00
|
|
|
- id: insert-license
|
2019-10-26 14:31:51 +03:00
|
|
|
name: Add license for all yaml files
|
2019-08-22 17:13:56 +03:00
|
|
|
exclude: ^\.github/.*$"|^airflow/_vendor/.*$
|
|
|
|
types: [yaml]
|
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "|#|"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.txt
|
2019-08-27 21:06:41 +03:00
|
|
|
- --fuzzy-match-generates-todo
|
2019-08-22 06:27:54 +03:00
|
|
|
- id: insert-license
|
2019-10-26 14:31:51 +03:00
|
|
|
name: Add license for all md files
|
2019-08-22 06:27:54 +03:00
|
|
|
files: \.md$
|
|
|
|
exclude: ^\.github/.*$|^airflow/_vendor/.*$
|
|
|
|
args:
|
|
|
|
- --comment-style
|
|
|
|
- "<!--|| -->"
|
|
|
|
- --license-filepath
|
|
|
|
- license-templates/LICENSE.txt
|
2019-08-27 21:06:41 +03:00
|
|
|
- --fuzzy-match-generates-todo
|
2019-08-22 06:27:54 +03:00
|
|
|
- repo: https://github.com/thlorenz/doctoc.git
|
|
|
|
rev: v1.4.0
|
|
|
|
hooks:
|
|
|
|
- id: doctoc
|
|
|
|
name: Add TOC for md files
|
|
|
|
files: ^README\.md$|^CONTRIBUTING\.md$|^UPDATING.md$|^dev/README.md$
|
|
|
|
args:
|
|
|
|
- "--maxlevel"
|
|
|
|
- "2"
|
2019-08-16 17:35:34 +03:00
|
|
|
- repo: meta
|
|
|
|
hooks:
|
|
|
|
- id: check-hooks-apply
|
|
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
2019-11-04 11:50:06 +03:00
|
|
|
rev: v2.4.0
|
2019-08-16 17:35:34 +03:00
|
|
|
hooks:
|
|
|
|
- id: check-merge-conflict
|
2019-11-26 11:28:42 +03:00
|
|
|
- id: debug-statements
|
2019-08-16 17:35:34 +03:00
|
|
|
- id: detect-private-key
|
|
|
|
- id: end-of-file-fixer
|
|
|
|
- id: mixed-line-ending
|
2019-08-20 17:29:34 +03:00
|
|
|
- id: check-executables-have-shebangs
|
|
|
|
- id: check-xml
|
2019-12-28 21:34:35 +03:00
|
|
|
- id: trailing-whitespace
|
2020-02-04 11:44:35 +03:00
|
|
|
- id: fix-encoding-pragma
|
|
|
|
args:
|
|
|
|
- --remove
|
|
|
|
exclude: ^airflow/_vendor/.*$
|
2019-09-21 22:47:02 +03:00
|
|
|
- repo: https://github.com/pre-commit/pygrep-hooks
|
2020-01-11 21:54:42 +03:00
|
|
|
rev: v1.4.4
|
2019-09-21 22:47:02 +03:00
|
|
|
hooks:
|
|
|
|
- id: rst-backticks
|
2019-09-22 10:55:39 +03:00
|
|
|
- id: python-no-log-warn
|
2019-08-15 03:53:28 +03:00
|
|
|
- repo: local
|
|
|
|
hooks:
|
2019-08-22 17:13:56 +03:00
|
|
|
- id: yamllint
|
|
|
|
name: Check yaml files with yamllint
|
|
|
|
entry: yamllint -c yamllint-config.yml
|
|
|
|
language: python
|
2019-09-01 12:13:50 +03:00
|
|
|
additional_dependencies: ['yamllint']
|
2019-08-22 17:13:56 +03:00
|
|
|
types: [yaml]
|
|
|
|
exclude: ^.*init_git_sync\.template\.yaml$|^.*airflow\.template\.yaml$
|
2019-08-20 07:07:39 +03:00
|
|
|
- id: shellcheck
|
|
|
|
name: Check Shell scripts syntax correctness
|
|
|
|
language: docker_image
|
|
|
|
entry: koalaman/shellcheck:stable -x -a
|
2020-01-07 22:38:24 +03:00
|
|
|
files: ^breeze$|^breeze-complete$|\.sh$|^hooks/build$|^hooks/push$|\.bash$|\.bats$
|
2019-09-10 11:16:10 +03:00
|
|
|
exclude: ^airflow/_vendor/.*$
|
2019-08-15 03:53:28 +03:00
|
|
|
- id: lint-dockerfile
|
|
|
|
name: Lint dockerfile
|
|
|
|
language: system
|
2019-09-18 14:43:30 +03:00
|
|
|
entry: "./scripts/ci/pre_commit_lint_dockerfile.sh"
|
2019-08-15 03:53:28 +03:00
|
|
|
files: ^Dockerfile.*$
|
2019-09-18 14:43:30 +03:00
|
|
|
pass_filenames: true
|
2019-11-04 17:59:48 +03:00
|
|
|
- id: isort
|
|
|
|
name: Run isort to sort imports
|
|
|
|
language: python
|
|
|
|
entry: isort
|
|
|
|
files: \.py$
|
|
|
|
# To keep consistent with the global isort skip config defined in setup.cfg
|
|
|
|
exclude: ^airflow/_vendor/.*$|^build/.*$|^.tox/.*$|^venv/.*$
|
|
|
|
additional_dependencies: ['isort']
|
2019-11-30 12:05:14 +03:00
|
|
|
- id: setup-order
|
|
|
|
name: Checks for an order of dependencies in setup.py
|
|
|
|
language: python
|
|
|
|
files: ^setup.py$
|
|
|
|
pass_filenames: false
|
|
|
|
require_serial: true
|
|
|
|
entry: tests/test_order_setup.py
|
2019-11-04 12:37:31 +03:00
|
|
|
- id: update-breeze-file
|
|
|
|
name: Update output of breeze command in BREEZE.rst
|
|
|
|
entry: "./scripts/ci/pre_commit_breeze_cmd_line.sh"
|
|
|
|
language: system
|
|
|
|
files: ^BREEZE.rst$|^breeze$|^breeze-complete$
|
|
|
|
pass_filenames: false
|
|
|
|
require_serial: true
|
2019-11-26 11:28:42 +03:00
|
|
|
- id: pydevd
|
|
|
|
language: pygrep
|
|
|
|
name: Check for pydevd debug statements accidentally left
|
|
|
|
entry: "pydevd.*settrace\\("
|
|
|
|
pass_filenames: true
|
|
|
|
files: \.py$
|
2019-12-01 14:26:10 +03:00
|
|
|
- id: consistent-pylint
|
|
|
|
language: pygrep
|
|
|
|
name: Check for inconsitent pylint disable/enable without space
|
|
|
|
entry: "pylint:disable|pylint:enable"
|
|
|
|
pass_filenames: true
|
|
|
|
files: \.py$
|
2019-11-27 01:19:45 +03:00
|
|
|
- id: base-operator
|
|
|
|
language: pygrep
|
2019-12-29 23:17:56 +03:00
|
|
|
name: Make sure BaseOperator[Link] is imported from airflow.models.baseoperator in core
|
2019-12-01 13:14:52 +03:00
|
|
|
entry: "from airflow\\.models import.* BaseOperator"
|
2019-11-27 01:19:45 +03:00
|
|
|
files: \.py$
|
|
|
|
pass_filenames: true
|
|
|
|
exclude: >
|
|
|
|
(?x)
|
|
|
|
^airflow/gcp/.*$|
|
|
|
|
^airflow/hooks/.*$|
|
|
|
|
^airflow/operators/.*$|
|
|
|
|
^airflow/sensors/.*$|
|
|
|
|
^airflow/providers/.*$|
|
|
|
|
^airflow/contrib/.*$
|
|
|
|
- id: base-operator
|
|
|
|
language: pygrep
|
2019-12-29 23:17:56 +03:00
|
|
|
name: Make sure BaseOperator[Link] is imported from airflow.models outside of core
|
2019-12-01 13:14:52 +03:00
|
|
|
entry: "from airflow\\.models\\.baseoperator import.* BaseOperator"
|
2019-11-27 01:19:45 +03:00
|
|
|
pass_filenames: true
|
|
|
|
files: >
|
|
|
|
(?x)
|
|
|
|
^airflow/gcp/.*$|
|
|
|
|
^airflow/hooks/.*$|
|
|
|
|
^airflow/operators/.*$|
|
|
|
|
^airflow/sensors/.*$|
|
|
|
|
^airflow/providers/.*\.py$|
|
|
|
|
^airflow/contrib/.*\.py$
|
2020-02-02 12:14:14 +03:00
|
|
|
- id: provide-create-sessions
|
|
|
|
language: pygrep
|
|
|
|
name: Make sure provide_session and create_session are imported from airflow.utils.session
|
|
|
|
entry: "from airflow\\.utils\\.db import.* (provide_session|create_session)"
|
|
|
|
files: \.py$
|
|
|
|
pass_filenames: true
|
2020-02-02 22:48:03 +03:00
|
|
|
- id: incorrect-use-of-LoggingMixin
|
|
|
|
language: pygrep
|
|
|
|
name: Make sure LoggingMixin is not used alone
|
|
|
|
entry: "LoggingMixin\\(\\)"
|
|
|
|
files: \.py$
|
|
|
|
pass_filenames: true
|
2020-02-03 00:55:49 +03:00
|
|
|
- id: daysago-import-check
|
|
|
|
language: pygrep
|
|
|
|
name: Make sure days_ago is imported from airflow.utils.dates
|
|
|
|
entry: "(airflow\\.){0,1}utils\\.dates\\.days_ago"
|
|
|
|
files: \.py$
|
|
|
|
pass_filenames: true
|
2019-11-04 17:59:48 +03:00
|
|
|
- id: build
|
|
|
|
name: Check if image build is needed
|
2019-11-06 00:30:00 +03:00
|
|
|
entry: ./scripts/ci/pre_commit_ci_build.sh
|
2019-11-04 17:59:48 +03:00
|
|
|
language: system
|
|
|
|
always_run: true
|
|
|
|
pass_filenames: false
|
|
|
|
- id: check-apache-license
|
|
|
|
name: Check if licenses are OK for Apache
|
|
|
|
entry: "./scripts/ci/pre_commit_check_license.sh"
|
|
|
|
language: system
|
|
|
|
files: ^.*LICENSE.*$|^.*LICENCE.*$
|
|
|
|
pass_filenames: false
|
|
|
|
require_serial: true
|
2020-01-09 00:48:22 +03:00
|
|
|
- id: airflow-config-yaml
|
|
|
|
name: Checks for consistency between config.yml and default_config.cfg
|
|
|
|
language: python
|
|
|
|
files: "^airflow/config_templates/config.yml$|^airflow/config_templates/default_airflow.cfg$"
|
|
|
|
pass_filenames: false
|
|
|
|
require_serial: false
|
|
|
|
entry: scripts/ci/pre_commit_yaml_to_cfg.py
|
|
|
|
additional_dependencies: ['pyyaml']
|
2019-08-15 03:53:28 +03:00
|
|
|
- id: mypy
|
|
|
|
name: Run mypy
|
|
|
|
language: system
|
2019-09-18 14:43:30 +03:00
|
|
|
entry: "./scripts/ci/pre_commit_mypy.sh"
|
2019-08-15 03:53:28 +03:00
|
|
|
files: \.py$
|
2020-02-16 22:05:50 +03:00
|
|
|
exclude: ^airflow/_vendor/.*$|^dev
|
2020-02-15 17:30:31 +03:00
|
|
|
pass_filenames: false
|
2019-08-15 03:53:28 +03:00
|
|
|
- id: pylint
|
|
|
|
name: Run pylint for main sources
|
|
|
|
language: system
|
2019-09-18 14:43:30 +03:00
|
|
|
entry: "./scripts/ci/pre_commit_pylint_main.sh"
|
2019-08-15 03:53:28 +03:00
|
|
|
files: \.py$
|
2020-02-16 22:05:50 +03:00
|
|
|
exclude: ^tests/.*\.py$|^airflow/_vendor/.*|^scripts/.*\.py$|^dev
|
2019-09-18 14:43:30 +03:00
|
|
|
pass_filenames: true
|
2019-12-03 18:02:20 +03:00
|
|
|
require_serial: true # Pylint tests should be run in one chunk to detect all cycles
|
|
|
|
- id: pylint-tests
|
2019-08-15 03:53:28 +03:00
|
|
|
name: Run pylint for tests
|
|
|
|
language: system
|
2019-09-18 14:43:30 +03:00
|
|
|
entry: "./scripts/ci/pre_commit_pylint_tests.sh"
|
2019-08-15 03:53:28 +03:00
|
|
|
files: ^tests/.*\.py$
|
2019-09-18 14:43:30 +03:00
|
|
|
pass_filenames: true
|
2020-01-25 17:06:27 +03:00
|
|
|
require_serial: true
|
2019-08-15 03:53:28 +03:00
|
|
|
- id: flake8
|
|
|
|
name: Run flake8
|
|
|
|
language: system
|
2019-09-18 14:43:30 +03:00
|
|
|
entry: "./scripts/ci/pre_commit_flake8.sh"
|
2019-08-15 03:53:28 +03:00
|
|
|
files: \.py$
|
2019-09-18 14:43:30 +03:00
|
|
|
pass_filenames: true
|
2020-01-07 17:38:05 +03:00
|
|
|
- id: bat-tests
|
2020-01-19 15:15:43 +03:00
|
|
|
name: Run BATS bash tests for changed bash files
|
2020-01-07 17:38:05 +03:00
|
|
|
language: system
|
|
|
|
entry: "./scripts/ci/pre_commit_bat_tests.sh"
|
2020-01-19 15:15:43 +03:00
|
|
|
files: ^breeze$|^breeze-complete$|\.sh$|\.bash$
|
|
|
|
pass_filenames: false
|