.pre-commit-config.yaml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 - IDF monitor test data
  14. # 5 - protobuf auto-generated files
  15. exclude: &whitespace_excludes |
  16. (?x)^(
  17. .+\.(md|rst|map|bin)|
  18. .+test.*\/.*expected.*|
  19. .+\/testdata\/.+|
  20. .+test_idf_monitor\/tests\/.+|
  21. .*_pb2.py|
  22. .*.pb-c.h|
  23. .*.pb-c.c
  24. )$
  25. - id: end-of-file-fixer
  26. exclude: *whitespace_excludes
  27. - id: check-executables-have-shebangs
  28. - id: mixed-line-ending
  29. args: ['-f=lf']
  30. - id: double-quote-string-fixer
  31. - repo: https://gitlab.com/pycqa/flake8
  32. rev: 5.0.4
  33. hooks:
  34. - id: flake8
  35. args: ['--config=.flake8', '--tee', '--benchmark']
  36. - repo: https://github.com/pycqa/isort
  37. rev: 5.9.3
  38. hooks:
  39. - id: isort
  40. name: isort (python)
  41. exclude: >
  42. (?x)^(
  43. .*_pb2.py
  44. )$
  45. - repo: local
  46. hooks:
  47. - id: check-executables
  48. name: Check File Permissions
  49. entry: tools/ci/check_executables.py --action executables
  50. language: python
  51. types: [executable]
  52. exclude: '\.pre-commit/.+'
  53. - id: check-executable-list
  54. name: Validate executable-list.txt
  55. entry: tools/ci/check_executables.py --action list
  56. language: python
  57. pass_filenames: false
  58. always_run: true
  59. - id: check-kconfigs
  60. name: Validate Kconfig files
  61. entry: tools/ci/check_kconfigs.py
  62. language: python
  63. files: '^Kconfig$|Kconfig.*$'
  64. - id: check-deprecated-kconfigs-options
  65. name: Check if any Kconfig Options Deprecated
  66. entry: tools/ci/check_deprecated_kconfigs.py
  67. language: python
  68. files: 'sdkconfig\.ci$|sdkconfig\.rename$|sdkconfig.*$'
  69. - id: cmake-lint
  70. name: Check CMake Files Format
  71. entry: cmakelint --linelength=120 --spaces=4 --filter=-whitespace/indent
  72. language: python
  73. additional_dependencies:
  74. - cmakelint==1.4.1
  75. files: 'CMakeLists.txt$|\.cmake$'
  76. exclude: '\/third_party\/'
  77. - id: check-codeowners
  78. name: Validate Codeowner File
  79. entry: tools/ci/check_codeowners.py ci-check
  80. language: python
  81. always_run: true
  82. files: '\.gitlab/CODEOWNERS'
  83. pass_filenames: false
  84. - id: check-rules-yml
  85. name: Check rules.yml all rules have at lease one job applied, all rules needed exist
  86. entry: tools/ci/check_rules_yml.py
  87. language: python
  88. files: '\.gitlab/ci/.+\.yml|\.gitlab-ci.yml'
  89. pass_filenames: false
  90. additional_dependencies:
  91. - PyYAML == 5.3.1
  92. - id: check-generated-rules
  93. name: Check rules are generated (based on .gitlab/ci/dependencies/dependencies.yml)
  94. entry: .gitlab/ci/dependencies/generate_rules.py
  95. language: python
  96. files: '\.gitlab/ci/dependencies/.+|\.gitlab/ci/rules\.yml'
  97. pass_filenames: false
  98. additional_dependencies:
  99. - PyYAML == 5.3.1
  100. - id: mypy-check
  101. name: Check type annotations in python files
  102. entry: tools/ci/check_type_comments.py
  103. additional_dependencies:
  104. - 'mypy==0.940'
  105. - 'mypy-extensions==0.4.3'
  106. - 'types-setuptools==57.4.14'
  107. - 'types-PyYAML==0.1.9'
  108. exclude: >
  109. (?x)^(
  110. .*_pb2.py
  111. )$
  112. language: python
  113. types: [python]
  114. - id: check-requirement-files
  115. name: Check requirement files
  116. entry: tools/ci/check_requirement_files.py
  117. additional_dependencies:
  118. - 'jsonschema'
  119. language: python
  120. files: 'tools/requirements.+|tools/requirements/.+'
  121. pass_filenames: false
  122. - id: check-tools-files-patterns
  123. name: Check tools dir files patterns
  124. entry: tools/ci/check_tools_files_patterns.py
  125. language: python
  126. files: '^tools/.+'
  127. additional_dependencies:
  128. - PyYAML == 5.3.1
  129. pass_filenames: false
  130. - id: check-generated-soc-caps-kconfig
  131. name: Check soc caps kconfig files are generated (based on components/soc/IDF_TARGET/include/soc/soc_caps.h)
  132. entry: tools/gen_soc_caps_kconfig/gen_soc_caps_kconfig.py -d 'components/soc/*/include/soc/' 'components/esp_rom/*/'
  133. language: python
  134. files: 'components/soc/.+/include/soc/.+_caps\.h|components/esp_rom/.+/.+_caps\.h|kconfig\.soc_caps.in'
  135. pass_filenames: false
  136. additional_dependencies:
  137. - pyparsing
  138. - id: check-all-apps-readmes
  139. name: Check if all apps readme files match given .build-test-rules.yml files. Modify the supported target tables
  140. entry: tools/ci/check_build_test_rules.py check-readmes
  141. language: python
  142. files: 'tools/test_apps/.+|examples/.+|components/.+'
  143. additional_dependencies:
  144. - idf_build_apps
  145. - id: sort-build-test-rules-ymls
  146. name: sort .build-test-rules.yml files
  147. entry: tools/ci/check_build_test_rules.py sort-yaml
  148. language: python
  149. files: '\.build-test-rules\.yml'
  150. additional_dependencies:
  151. - ruamel.yaml
  152. - repo: https://github.com/pre-commit/pre-commit-hooks
  153. rev: v4.0.1
  154. hooks:
  155. - id: file-contents-sorter
  156. files: 'tools\/ci\/(executable-list\.txt|mypy_ignore_list\.txt|check_copyright_ignore\.txt)'
  157. - repo: https://github.com/espressif/check-copyright/
  158. rev: v1.0.1
  159. hooks:
  160. - id: check-copyright
  161. args: ['--ignore', 'tools/ci/check_copyright_ignore.txt', '--config', 'tools/ci/check_copyright_config.yaml']