.pre-commit-config.yaml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. - id: no-commit-to-branch
  31. name: Do not use more than one slash in the branch name
  32. args: ['--pattern', '^[^/]*/[^/]*/']
  33. - id: no-commit-to-branch
  34. name: Do not use uppercase letters in the branch name
  35. args: ['--pattern', '^[^A-Z]*[A-Z]']
  36. - repo: https://github.com/PyCQA/flake8
  37. rev: 5.0.4
  38. hooks:
  39. - id: flake8
  40. args: ['--config=.flake8', '--tee', '--benchmark']
  41. - repo: https://github.com/pycqa/isort
  42. rev: 5.12.0 # python 3.8 compatible
  43. hooks:
  44. - id: isort
  45. name: isort (python)
  46. exclude: >
  47. (?x)^(
  48. .*_pb2.py
  49. )$
  50. - repo: local
  51. hooks:
  52. - id: check-executables
  53. name: Check File Permissions
  54. entry: tools/ci/check_executables.py --action executables
  55. language: python
  56. types: [executable]
  57. exclude: '\.pre-commit/.+'
  58. - id: check-executable-list
  59. name: Validate executable-list.txt
  60. entry: tools/ci/check_executables.py --action list
  61. language: python
  62. pass_filenames: false
  63. always_run: true
  64. - id: check-kconfigs
  65. name: Validate Kconfig files
  66. entry: tools/ci/check_kconfigs.py
  67. language: python
  68. additional_dependencies:
  69. - esp-idf-kconfig
  70. files: '^Kconfig$|Kconfig.*$'
  71. - id: check-deprecated-kconfigs-options
  72. name: Check if any Kconfig Options Deprecated
  73. entry: tools/ci/check_deprecated_kconfigs.py
  74. language: python
  75. files: 'sdkconfig\.ci$|sdkconfig\.rename$|sdkconfig.*$'
  76. - id: cmake-lint
  77. name: Check CMake Files Format
  78. entry: cmakelint --linelength=120 --spaces=4 --filter=-whitespace/indent
  79. language: python
  80. additional_dependencies:
  81. - cmakelint==1.4.1
  82. files: 'CMakeLists.txt$|\.cmake$'
  83. exclude: '\/third_party\/'
  84. - id: check-codeowners
  85. name: Validate Codeowner File
  86. entry: tools/ci/check_codeowners.py ci-check
  87. language: python
  88. always_run: true
  89. files: '\.gitlab/CODEOWNERS'
  90. pass_filenames: false
  91. - id: check-rules-yml
  92. name: Check rules.yml all rules have at lease one job applied, all rules needed exist
  93. entry: tools/ci/check_rules_yml.py
  94. language: python
  95. files: '\.gitlab/ci/.+\.yml|\.gitlab-ci.yml|\.gitmodules'
  96. pass_filenames: false
  97. additional_dependencies:
  98. - PyYAML == 5.3.1
  99. - id: check-generated-rules
  100. name: Check rules are generated (based on .gitlab/ci/dependencies/dependencies.yml)
  101. entry: tools/ci/generate_rules.py
  102. language: python
  103. files: '\.gitlab/ci/dependencies/.+|\.gitlab/ci/.*\.yml'
  104. pass_filenames: false
  105. additional_dependencies:
  106. - PyYAML == 5.3.1
  107. - id: mypy-check
  108. name: Check type annotations in python files
  109. entry: tools/ci/check_type_comments.py
  110. additional_dependencies:
  111. - 'mypy==0.940'
  112. - 'mypy-extensions==0.4.3'
  113. - 'types-setuptools==57.4.14'
  114. - 'types-PyYAML==0.1.9'
  115. exclude: >
  116. (?x)^(
  117. .*_pb2.py
  118. )$
  119. language: python
  120. types: [python]
  121. - id: check-requirement-files
  122. name: Check requirement files
  123. entry: tools/ci/check_requirement_files.py
  124. additional_dependencies:
  125. - 'jsonschema'
  126. language: python
  127. files: 'tools/requirements.+|tools/requirements/.+'
  128. pass_filenames: false
  129. - id: check-tools-files-patterns
  130. name: Check tools dir files patterns
  131. entry: tools/ci/check_tools_files_patterns.py
  132. language: python
  133. files: '^tools/.+'
  134. additional_dependencies:
  135. - PyYAML == 5.3.1
  136. pass_filenames: false
  137. - id: check-rules-components-patterns
  138. name: check patterns-build_components in rules.yml
  139. entry: tools/ci/check_rules_components_patterns.py
  140. language: python
  141. files: 'components/.+|.gitlab/ci/rules.yml'
  142. additional_dependencies:
  143. - PyYAML == 5.3.1
  144. pass_filenames: false
  145. - id: check-generated-soc-caps-kconfig
  146. name: Check soc caps kconfig files are generated (based on components/soc/IDF_TARGET/include/soc/soc_caps.h)
  147. entry: tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py -d 'components/soc/*/include/soc/' 'components/esp_rom/*/' 'components/spi_flash/*/'
  148. language: python
  149. files: 'components/soc/.+/include/soc/.+_caps\.h|components/esp_rom/.+/.+_caps\.h|kconfig\.soc_caps.in|components/spi_flash/.+/.+_caps\.h'
  150. pass_filenames: false
  151. additional_dependencies:
  152. - pyparsing
  153. - id: check-all-apps-readmes
  154. name: Check if all apps readme files match given .build-test-rules.yml files. Modify the supported target tables
  155. entry: tools/ci/check_build_test_rules.py check-readmes
  156. language: python
  157. files: 'tools/test_apps/.+|examples/.+|components/.+|tools/idf_py_actions/constants.py|tools/ci/check_build_test_rules.py'
  158. require_serial: true
  159. additional_dependencies:
  160. - PyYAML == 5.3.1
  161. - idf_build_apps~=1.0
  162. - id: sort-build-test-rules-ymls
  163. name: sort .build-test-rules.yml files
  164. entry: tools/ci/check_build_test_rules.py sort-yaml
  165. language: python
  166. files: '\.build-test-rules\.yml'
  167. additional_dependencies:
  168. - PyYAML == 5.3.1
  169. - ruamel.yaml
  170. - id: check-build-test-rules-path-exists
  171. name: check path in .build-test-rules.yml exists
  172. entry: tools/ci/check_build_test_rules.py check-exist
  173. language: python
  174. additional_dependencies:
  175. - PyYAML == 5.3.1
  176. always_run: true
  177. pass_filenames: false
  178. require_serial: true
  179. - id: submodule-sbom-hash-check
  180. name: Check if sbom-hash values for submodules in .gitmodules match submodules checkout hash in git tree
  181. entry: python tools/test_sbom/test_submodules.py
  182. language: python
  183. always_run: true
  184. pass_filenames: false
  185. - id: cleanup-ignore-lists
  186. name: Remove non-existing patterns from ignore lists
  187. entry: tools/ci/cleanup_ignore_lists.py
  188. language: python
  189. always_run: true
  190. require_serial: true
  191. - repo: https://github.com/pre-commit/pre-commit-hooks
  192. rev: v4.0.1
  193. hooks:
  194. - id: file-contents-sorter
  195. files: 'tools\/ci\/(executable-list\.txt|mypy_ignore_list\.txt|check_copyright_ignore\.txt)'
  196. - repo: https://github.com/espressif/check-copyright/
  197. rev: v1.0.3
  198. hooks:
  199. - id: check-copyright
  200. args: ['--ignore', 'tools/ci/check_copyright_ignore.txt', '--config', 'tools/ci/check_copyright_config.yaml']
  201. - repo: https://github.com/espressif/conventional-precommit-linter
  202. rev: v1.2.1
  203. hooks:
  204. - id: conventional-precommit-linter
  205. stages: [commit-msg]
  206. - repo: https://github.com/espressif/astyle_py.git
  207. rev: v1.0.2
  208. hooks:
  209. - id: astyle_py
  210. # If you are modifying astyle version, update tools/format.sh as well
  211. args: ['--astyle-version=3.4.7', '--rules=tools/ci/astyle-rules.yml']
  212. - repo: https://github.com/shellcheck-py/shellcheck-py
  213. rev: v0.9.0.5
  214. hooks:
  215. - id: shellcheck
  216. name: shellcheck bash
  217. args: ['--shell', 'bash', '-x']
  218. files: 'install.sh|export.sh'
  219. - id: shellcheck
  220. name: shellcheck dash (export.sh)
  221. args: ['--shell', 'dash', '-x']
  222. files: 'export.sh'