.pre-commit-config.yaml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. exclude: &whitespace_excludes |
  15. (?x)^(
  16. .+\.(md|rst|map|bin)|
  17. .+test.*\/.*expected.*|
  18. .+\/testdata\/.+|
  19. .+test_idf_monitor\/tests\/.+
  20. )$
  21. - id: end-of-file-fixer
  22. exclude: *whitespace_excludes
  23. - id: check-executables-have-shebangs
  24. - id: mixed-line-ending
  25. args: ['-f=lf']
  26. - id: double-quote-string-fixer
  27. - repo: https://gitlab.com/pycqa/flake8
  28. rev: 3.9.2
  29. hooks:
  30. - id: flake8
  31. args: ['--config=.flake8', '--tee', '--benchmark']
  32. - repo: https://github.com/pycqa/isort
  33. rev: 5.9.3
  34. hooks:
  35. - id: isort
  36. name: isort (python)
  37. - repo: local
  38. hooks:
  39. - id: check-executables
  40. name: Check File Permissions
  41. entry: tools/ci/check_executables.py --action executables
  42. language: python
  43. types: [executable]
  44. exclude: '\.pre-commit/.+'
  45. - id: check-executable-list
  46. name: Validate executable-list.txt
  47. entry: tools/ci/check_executables.py --action list
  48. language: python
  49. pass_filenames: false
  50. always_run: true
  51. - id: check-kconfigs
  52. name: Validate Kconfig files
  53. entry: tools/ci/check_kconfigs.py
  54. language: python
  55. files: '^Kconfig$|Kconfig.*$'
  56. - id: check-deprecated-kconfigs-options
  57. name: Check if any Kconfig Options Deprecated
  58. entry: tools/ci/check_deprecated_kconfigs.py
  59. language: python
  60. files: 'sdkconfig\.ci$|sdkconfig\.rename$|sdkconfig.*$'
  61. - id: cmake-lint
  62. name: Check CMake Files Format
  63. entry: cmakelint --linelength=120 --spaces=4 --filter=-whitespace/indent
  64. language: python
  65. additional_dependencies:
  66. - cmakelint==1.4.1
  67. files: 'CMakeLists.txt$|\.cmake$'
  68. exclude: '\/third_party\/'
  69. - id: check-codeowners
  70. name: Validate Codeowner File
  71. entry: tools/ci/check_codeowners.py ci-check
  72. language: python
  73. files: '\.gitlab/CODEOWNERS'
  74. pass_filenames: false
  75. - id: check-rules-yml
  76. name: Check rules.yml all rules have at lease one job applied, all rules needed exist
  77. entry: tools/ci/check_rules_yml.py
  78. language: python
  79. files: '\.gitlab/ci/.+\.yml|\.gitlab-ci.yml'
  80. pass_filenames: false
  81. additional_dependencies:
  82. - PyYAML == 5.3.1
  83. - id: check-generated-rules
  84. name: Check rules are generated (based on .gitlab/ci/dependencies/dependencies.yml)
  85. entry: .gitlab/ci/dependencies/generate_rules.py
  86. language: python
  87. files: '\.gitlab/ci/dependencies/.+|\.gitlab/ci/rules\.yml'
  88. pass_filenames: false
  89. additional_dependencies:
  90. - PyYAML == 5.3.1
  91. - id: mypy-check
  92. name: Check type annotations in python files
  93. entry: tools/ci/check_type_comments.py
  94. additional_dependencies:
  95. - 'mypy==0.800'
  96. - 'mypy-extensions==0.4.3'
  97. language: python
  98. types: [python]
  99. - id: check-copyright
  100. name: Check copyright notices
  101. entry: tools/ci/check_copyright.py --verbose --replace
  102. additional_dependencies:
  103. - 'comment_parser == 1.2.3'
  104. - 'thefuzz == 0.19.0'
  105. - 'thefuzz[speedup] == 0.19.0; sys_platform != "win32"'
  106. # don't depend on python-Levenshtein on Windows, as it requires Microsoft C++ Build Tools to install
  107. language: python
  108. files: \.(py|c|h|cpp|hpp|ld)$
  109. require_serial: true
  110. - id: check-tools-files-patterns
  111. name: Check tools dir files patterns
  112. entry: tools/ci/check_tools_files_patterns.py
  113. language: python
  114. files: '^tools/.+'
  115. additional_dependencies:
  116. - PyYAML == 5.3.1
  117. pass_filenames: false
  118. - repo: https://github.com/pre-commit/pre-commit-hooks
  119. rev: v4.0.1
  120. hooks:
  121. - id: file-contents-sorter
  122. files: 'tools\/ci\/(executable-list\.txt|mypy_ignore_list\.txt|check_copyright_ignore\.txt|check_copyright_permanent_ignore\.txt)'