mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-03 00:21:44 +01:00
ci: add pre-commit to cleanup ignore lists
This commit is contained in:
63
tools/ci/cleanup_ignore_lists.py
Executable file
63
tools/ci/cleanup_ignore_lists.py
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import glob
|
||||
import os
|
||||
import typing as t
|
||||
|
||||
from idf_ci_utils import IDF_PATH
|
||||
|
||||
|
||||
def print_list(_list: t.Iterable[str], title: t.Optional[str] = None) -> None:
|
||||
if not _list:
|
||||
return
|
||||
|
||||
if title:
|
||||
print(title)
|
||||
|
||||
for i in _list:
|
||||
print('- ', i)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.chdir(IDF_PATH)
|
||||
ignore_lists = set()
|
||||
ignore_lists.update(glob.glob('tools/ci/*.txt', recursive=True))
|
||||
ignore_lists.remove('tools/ci/ignore_build_warnings.txt')
|
||||
ignore_lists.remove('tools/ci/check_ldgen_mapping_exceptions.txt')
|
||||
print_list(ignore_lists, 'Ignore lists:')
|
||||
|
||||
updated_files = []
|
||||
for f in ignore_lists:
|
||||
print('Checking file:', f)
|
||||
|
||||
updated = False
|
||||
lines = []
|
||||
with open(f) as fr:
|
||||
for line in map(str.strip, fr.readlines()):
|
||||
if line.startswith('#'):
|
||||
lines.append(line)
|
||||
continue
|
||||
|
||||
if not line:
|
||||
lines.append(line)
|
||||
continue
|
||||
|
||||
glob_pattern = line
|
||||
if not list(glob.glob(glob_pattern, recursive=True)):
|
||||
print(' - No match:', glob_pattern)
|
||||
updated = True
|
||||
else:
|
||||
lines.append(glob_pattern)
|
||||
lines.append('')
|
||||
|
||||
if updated:
|
||||
updated_files.append(f)
|
||||
with open(f, 'w') as fw:
|
||||
fw.write('\n'.join(lines))
|
||||
|
||||
if updated_files:
|
||||
print_list(updated_files, 'Updated files:')
|
||||
exit(1)
|
||||
Reference in New Issue
Block a user