| # 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] |
| default_language_version: |
| # force all unspecified python hooks to run python3 |
| python: python3 |
| repos: |
| - repo: local |
| hooks: |
| - id: build |
| name: Check if image build is needed |
| entry: ./scripts/ci/local_ci_build.sh |
| language: system |
| always_run: true |
| pass_filenames: false |
| - id: check-apache-license |
| name: Check if licences are OK for Apache |
| entry: "./scripts/ci/pre_commit_check_license.sh" |
| language: system |
| files: ^.*LICENSE.*$|^.*LICENCE.*$ |
| pass_filenames: false |
| require_serial: true |
| - repo: https://github.com/Lucas-C/pre-commit-hooks |
| rev: v1.1.7 |
| hooks: |
| - id: forbid-tabs |
| exclude: ^airflow/_vendor/.*$|^docs/Makefile$ |
| - id: insert-license |
| name: Add licence for all SQL files |
| files: \.sql$ |
| exclude: ^\.github/.*$|^airflow/_vendor/.*$ |
| args: |
| - --comment-style |
| - "/*||*/" |
| - --license-filepath |
| - license-templates/LICENSE.txt |
| - --fuzzy-match-generates-todo |
| - id: insert-license |
| name: Add licence for all other files |
| exclude: ^\.github/.*$"|^airflow/_vendor/.*$ |
| args: |
| - --comment-style |
| - "|#|" |
| - --license-filepath |
| - license-templates/LICENSE.txt |
| - --fuzzy-match-generates-todo |
| files: > |
| \.properties$|\.cfg$|\.conf$|\.ini$|\.ldif$|\.readthedocs$|\.service$|^Dockerfile.*$ |
| - id: insert-license |
| name: Add licence for all rst files |
| exclude: ^\.github/.*$"|^airflow/_vendor/.*$ |
| args: |
| - --comment-style |
| - "||" |
| - --license-filepath |
| - license-templates/LICENSE.rst |
| - --fuzzy-match-generates-todo |
| files: \.rst$ |
| - id: insert-license |
| name: Add licence for all JS files |
| files: \.js$ |
| exclude: ^\.github/.*$|^airflow/_vendor/.*$|^airflow/www/static/.*$ |
| args: |
| - --comment-style |
| - "/**| *| */" |
| - --license-filepath |
| - license-templates/LICENSE.txt |
| - --fuzzy-match-generates-todo |
| - id: insert-license |
| name: Add licence for all JINJA template files |
| files: ^airflow/www/templates/.*\.html$|^docs/templates/.*\.html$|^airflow/contrib/plugins/metastore_browser/templates/.*\.html$ # yamllint disable-line rule:line-length |
| exclude: ^\.github/.*$|^airflow/_vendor/.*$ |
| args: |
| - --comment-style |
| - "{#||#}" |
| - --license-filepath |
| - license-templates/LICENSE.txt |
| - --fuzzy-match-generates-todo |
| - id: insert-license |
| name: Add licence for all shell files |
| exclude: ^\.github/.*$"|^airflow/_vendor/.*$ |
| files: ^breeze$|^breeze-complete$|\.sh$ |
| args: |
| - --comment-style |
| - "|#|" |
| - --license-filepath |
| - license-templates/LICENSE.txt |
| - --fuzzy-match-generates-todo |
| - id: insert-license |
| name: Add licence for all python files |
| exclude: ^\.github/.*$"|^airflow/_vendor/.*$ |
| types: [python] |
| args: |
| - --comment-style |
| - "|#|" |
| - --license-filepath |
| - license-templates/LICENSE.txt |
| - --fuzzy-match-generates-todo |
| - id: insert-license |
| name: Add licence for all XML files |
| exclude: ^\.github/.*$"|^airflow/_vendor/.*$ |
| types: [xml] |
| args: |
| - --comment-style |
| - "<!--||-->" |
| - --license-filepath |
| - license-templates/LICENSE.txt |
| - --fuzzy-match-generates-todo |
| - id: insert-license |
| name: Add licence for all yaml files |
| exclude: ^\.github/.*$"|^airflow/_vendor/.*$ |
| types: [yaml] |
| args: |
| - --comment-style |
| - "|#|" |
| - --license-filepath |
| - license-templates/LICENSE.txt |
| - --fuzzy-match-generates-todo |
| - id: insert-license |
| name: Add licence for all md files |
| files: \.md$ |
| exclude: ^\.github/.*$|^airflow/_vendor/.*$ |
| args: |
| - --comment-style |
| - "<!--|| -->" |
| - --license-filepath |
| - license-templates/LICENSE.txt |
| - --fuzzy-match-generates-todo |
| - 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" |
| - repo: meta |
| hooks: |
| - id: check-hooks-apply |
| - repo: https://github.com/pre-commit/pre-commit-hooks |
| rev: v2.3.0 |
| hooks: |
| - id: check-merge-conflict |
| - id: detect-private-key |
| - id: end-of-file-fixer |
| - id: mixed-line-ending |
| - id: check-executables-have-shebangs |
| - id: check-xml |
| - repo: https://github.com/pre-commit/pygrep-hooks |
| rev: v1.4.1 |
| hooks: |
| - id: rst-backticks |
| - id: python-no-log-warn |
| - repo: local |
| hooks: |
| - id: yamllint |
| name: Check yaml files with yamllint |
| entry: yamllint -c yamllint-config.yml |
| language: python |
| additional_dependencies: ['yamllint'] |
| types: [yaml] |
| exclude: ^.*init_git_sync\.template\.yaml$|^.*airflow\.template\.yaml$ |
| - id: shellcheck |
| name: Check Shell scripts syntax correctness |
| language: docker_image |
| entry: koalaman/shellcheck:stable -x -a |
| types: [shell] |
| files: ^breeze$|^breeze-complete$|\.sh$|^hooks/build$|^hooks/push$ |
| exclude: ^airflow/_vendor/.*$ |
| - id: lint-dockerfile |
| name: Lint dockerfile |
| language: system |
| entry: "./scripts/ci/pre_commit_lint_dockerfile.sh" |
| files: ^Dockerfile.*$ |
| pass_filenames: true |
| - id: mypy |
| name: Run mypy |
| language: system |
| entry: "./scripts/ci/pre_commit_mypy.sh" |
| files: \.py$ |
| exclude: ^airflow/_vendor/.*$ |
| pass_filenames: true |
| - id: flake8 |
| name: Run flake8 |
| language: system |
| entry: "./scripts/ci/pre_commit_flake8.sh" |
| files: \.py$ |
| pass_filenames: true |
| - id: python2-fastcheck |
| language: pygrep |
| name: Find common Python 3 vs. 2.7 compatibility problems |
| entry: > |
| (?x) |
| (?!.*\#\ noqa)(?!.*//\ noqa)( # Exclude lines with '# noqa' or '// noqa' comment |
| .super\(\).*| # Matches super() call from Python 3 |
| ^\s*def\s*\S*\([^:#)]*:.*| # Matches function param with Python3 type |
| ^\sdef\s*\S*\(.*\):\s*\-\>\s*\S*.* # Matches -> return value syntax from Python3 |
| )$ |
| files: \.py$ |
| exclude: ^airflow/_vendor |
| pass_filenames: true |
| - id: python2-compile |
| name: Compile code using python2 |
| language: system |
| entry: python2.7 -m py_compile |
| files: \.py$ |
| pass_filenames: true |
| require_serial: true |