.pre-commit-config.yaml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. # See https://pre-commit.com for more information
  2. # See https://pre-commit.com/hooks.html for more hooks
  3. repos:
  4. - repo: https://github.com/pre-commit/pre-commit-hooks
  5. rev: v4.0.1
  6. hooks:
  7. - id: trailing-whitespace
  8. # note: whitespace exclusions use multiline regex, see https://pre-commit.com/#regular-expressions
  9. # items are:
  10. # 1 - some file extensions
  11. # 2 - any file matching *test*/*expected* (for host tests, if possible use this naming pattern always)
  12. # 3 - any directory named 'testdata'
  13. # 4 - protobuf auto-generated files
  14. exclude: &whitespace_excludes |
  15. (?x)^(
  16. .+\.(md|rst|map|bin)|
  17. .+test.*\/.*expected.*|
  18. .+\/testdata\/.+|
  19. .*_pb2.py|
  20. .*.pb-c.h|
  21. .*.pb-c.c|
  22. .*.yuv
  23. )$
  24. - id: end-of-file-fixer
  25. exclude: *whitespace_excludes
  26. - id: check-executables-have-shebangs
  27. - id: mixed-line-ending
  28. args: ['-f=lf']
  29. - id: double-quote-string-fixer
  30. - repo: https://github.com/PyCQA/flake8
  31. rev: 5.0.4
  32. hooks:
  33. - id: flake8
  34. args: ['--config=.flake8', '--tee', '--benchmark']
  35. - repo: https://github.com/pycqa/isort
  36. rev: 5.12.0 # python 3.8 compatible
  37. hooks:
  38. - id: isort
  39. name: isort (python)
  40. exclude: >
  41. (?x)^(
  42. .*_pb2.py
  43. )$
  44. - repo: local
  45. hooks:
  46. - id: check-executables
  47. name: Check File Permissions
  48. entry: tools/ci/check_executables.py --action executables
  49. language: python
  50. types: [executable]
  51. exclude: '\.pre-commit/.+'
  52. - id: check-executable-list
  53. name: Validate executable-list.txt
  54. entry: tools/ci/check_executables.py --action list
  55. language: python
  56. pass_filenames: false
  57. always_run: true
  58. - id: check-kconfigs
  59. name: Validate Kconfig files
  60. entry: tools/ci/check_kconfigs.py
  61. language: python
  62. files: '^Kconfig$|Kconfig.*$'
  63. - id: check-deprecated-kconfigs-options
  64. name: Check if any Kconfig Options Deprecated
  65. entry: tools/ci/check_deprecated_kconfigs.py
  66. language: python
  67. files: 'sdkconfig\.ci$|sdkconfig\.rename$|sdkconfig.*$'
  68. - id: cmake-lint
  69. name: Check CMake Files Format
  70. entry: cmakelint --linelength=120 --spaces=4 --filter=-whitespace/indent
  71. language: python
  72. additional_dependencies:
  73. - cmakelint==1.4.1
  74. files: 'CMakeLists.txt$|\.cmake$'
  75. exclude: '\/third_party\/'
  76. - id: check-codeowners
  77. name: Validate Codeowner File
  78. entry: tools/ci/check_codeowners.py ci-check
  79. language: python
  80. always_run: true
  81. files: '\.gitlab/CODEOWNERS'
  82. pass_filenames: false
  83. - id: check-rules-yml
  84. name: Check rules.yml all rules have at lease one job applied, all rules needed exist
  85. entry: tools/ci/check_rules_yml.py
  86. language: python
  87. files: '\.gitlab/ci/.+\.yml|\.gitlab-ci.yml|\.gitmodules'
  88. pass_filenames: false
  89. additional_dependencies:
  90. - PyYAML == 5.3.1
  91. - id: check-generated-rules
  92. name: Check rules are generated (based on .gitlab/ci/dependencies/dependencies.yml)
  93. entry: tools/ci/generate_rules.py
  94. language: python
  95. files: '\.gitlab/ci/dependencies/.+|\.gitlab/ci/.*\.yml'
  96. pass_filenames: false
  97. additional_dependencies:
  98. - PyYAML == 5.3.1
  99. - id: mypy-check
  100. name: Check type annotations in python files
  101. entry: tools/ci/check_type_comments.py
  102. additional_dependencies:
  103. - 'mypy==0.940'
  104. - 'mypy-extensions==0.4.3'
  105. - 'types-setuptools==57.4.14'
  106. - 'types-PyYAML==0.1.9'
  107. exclude: >
  108. (?x)^(
  109. .*_pb2.py
  110. )$
  111. language: python
  112. types: [python]
  113. - id: check-requirement-files
  114. name: Check requirement files
  115. entry: tools/ci/check_requirement_files.py
  116. additional_dependencies:
  117. - 'jsonschema'
  118. language: python
  119. files: 'tools/requirements.+|tools/requirements/.+'
  120. pass_filenames: false
  121. - id: check-tools-files-patterns
  122. name: Check tools dir files patterns
  123. entry: tools/ci/check_tools_files_patterns.py
  124. language: python
  125. files: '^tools/.+'
  126. additional_dependencies:
  127. - PyYAML == 5.3.1
  128. pass_filenames: false
  129. - id: check-generated-soc-caps-kconfig
  130. name: Check soc caps kconfig files are generated (based on components/soc/IDF_TARGET/include/soc/soc_caps.h)
  131. entry: tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py -d 'components/soc/*/include/soc/' 'components/esp_rom/*/' 'components/spi_flash/*/'
  132. language: python
  133. files: 'components/soc/.+/include/soc/.+_caps\.h|components/esp_rom/.+/.+_caps\.h|kconfig\.soc_caps.in|components/spi_flash/.+/.+_caps\.h'
  134. pass_filenames: false
  135. additional_dependencies:
  136. - pyparsing
  137. - id: check-all-apps-readmes
  138. name: Check if all apps readme files match given .build-test-rules.yml files. Modify the supported target tables
  139. entry: tools/ci/check_build_test_rules.py check-readmes
  140. language: python
  141. files: 'tools/test_apps/.+|examples/.+|components/.+|tools/idf_py_actions/constants.py|tools/ci/check_build_test_rules.py'
  142. require_serial: true
  143. additional_dependencies:
  144. - PyYAML == 5.3.1
  145. - idf_build_apps~=1.0
  146. - id: sort-build-test-rules-ymls
  147. name: sort .build-test-rules.yml files
  148. entry: tools/ci/check_build_test_rules.py sort-yaml
  149. language: python
  150. files: '\.build-test-rules\.yml'
  151. additional_dependencies:
  152. - PyYAML == 5.3.1
  153. - ruamel.yaml
  154. - id: submodule-sbom-hash-check
  155. name: Check if sbom-hash values for submodules in .gitmodules match submodules checkout hash in git tree
  156. entry: python tools/test_sbom/test_submodules.py
  157. language: python
  158. always_run: true
  159. pass_filenames: false
  160. - id: cleanup-ignore-lists
  161. name: Remove non-existing patterns from ignore lists
  162. entry: tools/ci/cleanup_ignore_lists.py
  163. language: python
  164. always_run: true
  165. require_serial: true
  166. - repo: https://github.com/pre-commit/pre-commit-hooks
  167. rev: v4.0.1
  168. hooks:
  169. - id: file-contents-sorter
  170. files: 'tools\/ci\/(executable-list\.txt|mypy_ignore_list\.txt|check_copyright_ignore\.txt)'
  171. - repo: https://github.com/espressif/check-copyright/
  172. rev: v1.0.3
  173. hooks:
  174. - id: check-copyright
  175. args: ['--ignore', 'tools/ci/check_copyright_ignore.txt', '--config', 'tools/ci/check_copyright_config.yaml']
  176. - repo: https://github.com/espressif/conventional-precommit-linter
  177. rev: v1.2.1
  178. hooks:
  179. - id: conventional-precommit-linter
  180. stages: [commit-msg]