mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 19:54:56 +00:00
ci: make bringup process for check_build_test_rules.py more friendly
This commit is contained in:
@@ -12,6 +12,7 @@ from io import StringIO
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
import yaml
|
||||
from idf_ci_utils import IDF_PATH, get_pytest_cases, get_ttfw_cases
|
||||
|
||||
YES = u'\u2713'
|
||||
@@ -53,7 +54,11 @@ def doublequote(s: str) -> str:
|
||||
return f'"{s}"'
|
||||
|
||||
|
||||
def check_readme(paths: List[str], exclude_dirs: Optional[List[str]] = None) -> None:
|
||||
def check_readme(
|
||||
paths: List[str],
|
||||
exclude_dirs: Optional[List[str]] = None,
|
||||
extra_default_build_targets: Optional[List[str]] = None,
|
||||
) -> None:
|
||||
from idf_build_apps import App, find_apps
|
||||
from idf_build_apps.constants import SUPPORTED_TARGETS
|
||||
|
||||
@@ -142,6 +147,7 @@ def check_readme(paths: List[str], exclude_dirs: Optional[List[str]] = None) ->
|
||||
manifest_files=[
|
||||
str(p) for p in Path(IDF_PATH).glob('**/.build-test-rules.yml')
|
||||
],
|
||||
default_build_targets=SUPPORTED_TARGETS + extra_default_build_targets,
|
||||
)
|
||||
)
|
||||
exit_code = 0
|
||||
@@ -199,7 +205,11 @@ def check_readme(paths: List[str], exclude_dirs: Optional[List[str]] = None) ->
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
def check_test_scripts(paths: List[str], exclude_dirs: Optional[List[str]] = None) -> None:
|
||||
def check_test_scripts(
|
||||
paths: List[str],
|
||||
exclude_dirs: Optional[List[str]] = None,
|
||||
bypass_check_test_targets: Optional[List[str]] = None,
|
||||
) -> None:
|
||||
from idf_build_apps import App, find_apps
|
||||
|
||||
# takes long time, run only in CI
|
||||
@@ -245,7 +255,7 @@ def check_test_scripts(paths: List[str], exclude_dirs: Optional[List[str]] = Non
|
||||
actual_extra_tested_targets = set(actual_verified_targets) - set(
|
||||
_app.verified_targets
|
||||
)
|
||||
if actual_extra_tested_targets:
|
||||
if actual_extra_tested_targets - set(bypass_check_test_targets or []):
|
||||
print(
|
||||
inspect.cleandoc(
|
||||
f'''
|
||||
@@ -401,9 +411,21 @@ if __name__ == '__main__':
|
||||
|
||||
_check_readme = action.add_parser('check-readmes')
|
||||
_check_readme.add_argument('paths', nargs='+', help='check under paths')
|
||||
_check_readme.add_argument(
|
||||
'-c',
|
||||
'--config',
|
||||
default=os.path.join(IDF_PATH, '.gitlab', 'ci', 'default-build-test-rules.yml'),
|
||||
help='default build test rules config file',
|
||||
)
|
||||
|
||||
_check_test_scripts = action.add_parser('check-test-scripts')
|
||||
_check_test_scripts.add_argument('paths', nargs='+', help='check under paths')
|
||||
_check_test_scripts.add_argument(
|
||||
'-c',
|
||||
'--config',
|
||||
default=os.path.join(IDF_PATH, '.gitlab', 'ci', 'default-build-test-rules.yml'),
|
||||
help='default build test rules config file',
|
||||
)
|
||||
|
||||
_sort_yaml = action.add_parser('sort-yaml')
|
||||
_sort_yaml.add_argument('files', nargs='+', help='all specified yaml files')
|
||||
@@ -411,7 +433,9 @@ if __name__ == '__main__':
|
||||
arg = parser.parse_args()
|
||||
|
||||
# Since this script is executed from the pre-commit hook environment, make sure IDF_PATH is set
|
||||
os.environ['IDF_PATH'] = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
os.environ['IDF_PATH'] = os.path.realpath(
|
||||
os.path.join(os.path.dirname(__file__), '..', '..')
|
||||
)
|
||||
|
||||
if arg.action == 'sort-yaml':
|
||||
sort_yaml(arg.files)
|
||||
@@ -420,7 +444,9 @@ if __name__ == '__main__':
|
||||
|
||||
# check if *_caps.h files changed
|
||||
check_all = False
|
||||
soc_caps_header_files = list((Path(IDF_PATH) / 'components' / 'soc').glob('**/*_caps.h'))
|
||||
soc_caps_header_files = list(
|
||||
(Path(IDF_PATH) / 'components' / 'soc').glob('**/*_caps.h')
|
||||
)
|
||||
for p in arg.paths:
|
||||
if Path(p).resolve() in soc_caps_header_files:
|
||||
check_all = True
|
||||
@@ -437,7 +463,29 @@ if __name__ == '__main__':
|
||||
else:
|
||||
_exclude_dirs = []
|
||||
|
||||
extra_default_build_targets: List[str] = []
|
||||
bypass_check_test_targets: List[str] = []
|
||||
if arg.config:
|
||||
with open(arg.config) as fr:
|
||||
configs = yaml.safe_load(fr)
|
||||
|
||||
if configs:
|
||||
extra_default_build_targets = (
|
||||
configs.get('extra_default_build_targets') or []
|
||||
)
|
||||
bypass_check_test_targets = (
|
||||
configs.get('bypass_check_test_targets') or []
|
||||
)
|
||||
|
||||
if arg.action == 'check-readmes':
|
||||
check_readme(list(check_dirs), _exclude_dirs)
|
||||
check_readme(
|
||||
list(check_dirs),
|
||||
exclude_dirs=_exclude_dirs,
|
||||
extra_default_build_targets=extra_default_build_targets,
|
||||
)
|
||||
elif arg.action == 'check-test-scripts':
|
||||
check_test_scripts(list(check_dirs), _exclude_dirs)
|
||||
check_test_scripts(
|
||||
list(check_dirs),
|
||||
exclude_dirs=_exclude_dirs,
|
||||
bypass_check_test_targets=bypass_check_test_targets,
|
||||
)
|
||||
|
Reference in New Issue
Block a user