.pre-commit-config.yaml 3.9 KB
Newer Older
1
# Exclude all third-party libraries globally
2 3
exclude: |
    (?x)^(
4 5
        patches/.+|
        paddle/fluid/framework/fleet/heter_ps/cudf/.+|
6 7
        paddle/fluid/distributed/ps/thirdparty/round_robin.h|
        python/paddle/utils/gast/.+
8
    )$
Y
Yi Wang 已提交
9
repos:
Y
Yu Yang 已提交
10
-   repo: https://github.com/Lucas-C/pre-commit-hooks.git
11
    rev: v1.1.14
Y
Yu Yang 已提交
12 13
    hooks:
    -   id: remove-crlf
14 15 16
    -   id: remove-tabs
        files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps)$
        args: [--whitespaces-count, '2']
17 18 19 20 21 22 23 24 25 26 27
    -   id: remove-tabs
        files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
        args: [--whitespaces-count, '4']
        # Exclude the fluid directory but keep the fluid/tests directory.
        # And exclude some unit test files that require tabs.
        exclude: |
            (?x)^(
                python/paddle/fluid/(?!tests).+|
                python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py|
                python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py
            )$
28
-   repo: https://github.com/google/yapf
29
    rev: v0.32.0
Y
Yu Yang 已提交
30
    hooks:
Y
Yi Wang 已提交
31 32
    -   id: yapf
        files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
33 34 35 36 37
        exclude: |
            (?x)^(
                python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py|
                python/paddle/fluid/tests/unittests/dygraph_to_static/test_origin_info.py
            )$
38 39 40 41
-   repo: https://github.com/PyCQA/flake8
    rev: 4.0.1
    hooks:
    -   id: flake8
Y
Yu Yang 已提交
42
-   repo: https://github.com/pre-commit/pre-commit-hooks
43
    rev: v4.1.0
Y
Yu Yang 已提交
44 45 46 47 48 49
    hooks:
    -   id: check-added-large-files
    -   id: check-merge-conflict
    -   id: check-symlinks
    -   id: detect-private-key
    -   id: end-of-file-fixer
50
    -   id: sort-simple-yaml
51
        files: (op|backward|op_[a-z_]+)\.yaml$
52
    -   id: trailing-whitespace
53
        files: (.*\.(py|bzl|md|rst|c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps|cmake|yaml|yml|hook)|BUILD|.*\.BUILD|WORKSPACE|CMakeLists\.txt)$
L
test  
liaogang 已提交
54
-   repo: local
Y
Yu Yang 已提交
55
    hooks:
56
    -   id: clang-format
L
test  
liaogang 已提交
57 58
        name: clang-format
        description: Format files with ClangFormat.
59
        entry: bash ./tools/codestyle/clang_format.hook -i
L
test  
liaogang 已提交
60
        language: system
61
        files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps)$
Y
Yi Wang 已提交
62 63 64 65 66 67 68 69
-   repo: local
    hooks:
    -   id: cpplint-cpp-source
        name: cpplint
        description: Check C++ code style using cpplint.py.
        entry: bash ./tools/codestyle/cpplint_pre_commit.hook
        language: system
        files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx)$
70 71 72 73
        args:
            - --extensions=c,cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps
            - --filter=-readability/fn_size,-build/include_what_you_use,-build/c++11,-whitespace/parens
            - --quiet
G
gongweibao 已提交
74 75 76 77 78 79 80 81
-   repo: local
    hooks:
    -   id: pylint-doc-string
        name: pylint
        description: Check python docstring style using docstring_checker.
        entry: bash ./tools/codestyle/pylint_pre_commit.hook
        language: system
        files: \.(py)$
D
dzhwinter 已提交
82 83 84 85
-   repo: local
    hooks:
    -   id: copyright_checker
        name: copyright_checker
86
        entry: python ./tools/codestyle/copyright.hook
D
dzhwinter 已提交
87
        language: system
88
        files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|xpu|kps|py|sh)$
89 90 91 92
        exclude: |
            (?x)^(
                paddle/utils/.*
            )$
R
Roc 已提交
93 94 95 96 97 98 99
-   repo: local
    hooks:
    -   id: auto-generate-cmakelists
        name: auto-generate-cmakelists
        entry: bash ./tools/gen_ut_cmakelists.hook
        language: system
        files: testslist.csv$
100 101 102 103 104 105 106 107 108 109
-   repo: https://github.com/cheshirekow/cmake-format-precommit
    rev: v0.6.13
    hooks:
    -   id: cmake-format
        # exclude paddle/fluid/operators/CMakeLists.txt, see the comment
        # https://github.com/PaddlePaddle/Paddle/pull/43057#pullrequestreview-993471860
        exclude: |
            (?x)^(
                paddle/fluid/operators/CMakeLists.txt
            )$
110 111 112 113 114 115

-   repo: https://github.com/cmake-lint/cmake-lint
    rev: 1.4.2
    hooks:
    -   id: cmakelint
        args: [--config=./tools/codestyle/.cmakelintrc]