[CI] Allow multiple grep options for clang-tidy (#10004)

This commit is contained in:
Jesse Hills 2025-08-01 21:40:53 +12:00 committed by GitHub
parent 20ad1ab4eb
commit d8a46c7482
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View File

@ -281,7 +281,7 @@ jobs:
pio_cache_key: tidyesp32-idf pio_cache_key: tidyesp32-idf
- id: clang-tidy - id: clang-tidy
name: Run script/clang-tidy for ZEPHYR name: Run script/clang-tidy for ZEPHYR
options: --environment nrf52-tidy --grep USE_ZEPHYR options: --environment nrf52-tidy --grep USE_ZEPHYR --grep USE_NRF52
pio_cache_key: tidy-zephyr pio_cache_key: tidy-zephyr
ignore_errors: false ignore_errors: false

View File

@ -205,7 +205,12 @@ def main():
parser.add_argument( parser.add_argument(
"-c", "--changed", action="store_true", help="only run on changed files" "-c", "--changed", action="store_true", help="only run on changed files"
) )
parser.add_argument("-g", "--grep", help="only run on files containing value") parser.add_argument(
"-g",
"--grep",
action="append",
help="only run on files containing value",
)
parser.add_argument( parser.add_argument(
"--split-num", type=int, help="split the files into X jobs.", default=None "--split-num", type=int, help="split the files into X jobs.", default=None
) )

View File

@ -338,12 +338,12 @@ def filter_changed(files: list[str]) -> list[str]:
return files return files
def filter_grep(files: list[str], value: str) -> list[str]: def filter_grep(files: list[str], value: list[str]) -> list[str]:
matched = [] matched = []
for file in files: for file in files:
with open(file, encoding="utf-8") as handle: with open(file, encoding="utf-8") as handle:
contents = handle.read() contents = handle.read()
if value in contents: if any(v in contents for v in value):
matched.append(file) matched.append(file)
return matched return matched