1# See https://pre-commit.com for more information
2# See https://pre-commit.com/hooks.html for more hooks
3
4repos:
5  - repo: https://github.com/pre-commit/pre-commit-hooks
6    rev: v4.0.1
7    hooks:
8      - id: trailing-whitespace
9        # note: whitespace exclusions use multiline regex, see https://pre-commit.com/#regular-expressions
10        # items are:
11        # 1 - some file extensions
12        # 2 - any file matching *test*/*expected* (for host tests, if possible use this naming pattern always)
13        # 3 - any directory named 'testdata'
14        # 4 - IDF monitor test data
15        exclude: &whitespace_excludes |
16          (?x)^(
17            .+\.(md|rst|map|bin)|
18            .+test.*\/.*expected.*|
19            .+\/testdata\/.+|
20            .+test_idf_monitor\/tests\/.+
21          )$
22      - id: end-of-file-fixer
23        exclude: *whitespace_excludes
24      - id: check-executables-have-shebangs
25      - id: mixed-line-ending
26        args: ['-f=lf']
27      - id: double-quote-string-fixer
28  - repo: https://gitlab.com/pycqa/flake8
29    rev: 3.9.2
30    hooks:
31      - id: flake8
32        args: ['--config=.flake8', '--tee', '--benchmark']
33  - repo: https://github.com/pycqa/isort
34    rev: 5.9.3
35    hooks:
36      - id: isort
37        name: isort (python)
38  - repo: local
39    hooks:
40      - id: check-executables
41        name: Check File Permissions
42        entry: tools/ci/check_executables.py --action executables
43        language: python
44        types: [executable]
45        exclude: '\.pre-commit/.+'
46      - id: check-executable-list
47        name: Validate executable-list.txt
48        entry: tools/ci/check_executables.py --action list
49        language: python
50        pass_filenames: false
51        always_run: true
52      - id: check-kconfigs
53        name: Validate Kconfig files
54        entry: tools/ci/check_kconfigs.py
55        language: python
56        files: '^Kconfig$|Kconfig.*$'
57      - id: check-deprecated-kconfigs-options
58        name: Check if any Kconfig Options Deprecated
59        entry: tools/ci/check_deprecated_kconfigs.py
60        language: python
61        files: 'sdkconfig\.ci$|sdkconfig\.rename$|sdkconfig.*$'
62      - id: cmake-lint
63        name: Check CMake Files Format
64        entry: cmakelint --linelength=120 --spaces=4 --filter=-whitespace/indent
65        language: python
66        additional_dependencies:
67          - cmakelint==1.4.1
68        files: 'CMakeLists.txt$|\.cmake$'
69        exclude: '\/third_party\/'
70      - id: check-codeowners
71        name: Validate Codeowner File
72        entry: tools/ci/check_codeowners.py ci-check
73        language: python
74        files: '\.gitlab/CODEOWNERS'
75        pass_filenames: false
76      - id: check-rules-yml
77        name: Check rules.yml all rules have at lease one job applied, all rules needed exist
78        entry: tools/ci/check_rules_yml.py
79        language: python
80        files: '\.gitlab/ci/.+\.yml|\.gitlab-ci.yml'
81        pass_filenames: false
82        additional_dependencies:
83          - PyYAML == 5.3.1
84      - id: check-generated-rules
85        name: Check rules are generated (based on .gitlab/ci/dependencies/dependencies.yml)
86        entry: .gitlab/ci/dependencies/generate_rules.py
87        language: python
88        files: '\.gitlab/ci/dependencies/.+|\.gitlab/ci/rules\.yml'
89        pass_filenames: false
90        additional_dependencies:
91          - PyYAML == 5.3.1
92      - id: mypy-check
93        name: Check type annotations in python files
94        entry: tools/ci/check_type_comments.py
95        additional_dependencies:
96          - 'mypy==0.800'
97          - 'mypy-extensions==0.4.3'
98        language: python
99        types: [python]
100      - id: check-tools-files-patterns
101        name: Check tools dir files patterns
102        entry: tools/ci/check_tools_files_patterns.py
103        language: python
104        files: '^tools/.+'
105        additional_dependencies:
106          - PyYAML == 5.3.1
107        pass_filenames: false
108  - repo: https://github.com/pre-commit/pre-commit-hooks
109    rev: v4.0.1
110    hooks:
111      - id: file-contents-sorter
112        files: 'tools\/ci\/(executable-list\.txt|mypy_ignore_list\.txt)'
113