ci: support diff manifest sha with the base commit

This commit is contained in:
Fu Hanxi 2024-08-27 14:15:16 +02:00
parent 2913b72482
commit 56f8b7158c
No known key found for this signature in database
GPG Key ID: 19399699CF3C4B16
5 changed files with 37 additions and 0 deletions

1
.gitignore vendored
View File

@ -102,6 +102,7 @@ pytest_embedded_log/
list_job*.txt list_job*.txt
size_info*.txt size_info*.txt
XUNIT_RESULT*.xml XUNIT_RESULT*.xml
.manifest_sha
# clang config (for LSP) # clang config (for LSP)
.clangd .clangd

View File

@ -300,6 +300,8 @@ generate_build_child_pipeline:
dependencies: # set dependencies to null to avoid missing artifacts issue dependencies: # set dependencies to null to avoid missing artifacts issue
needs: needs:
- pipeline_variables - pipeline_variables
- job: baseline_manifest_sha
optional: true
artifacts: artifacts:
paths: paths:
- build_child_pipeline.yml - build_child_pipeline.yml

View File

@ -169,6 +169,26 @@ pipeline_variables:
expire_in: 1 week expire_in: 1 week
when: always when: always
baseline_manifest_sha:
extends:
- .pre_check_template
- .rules:dev-push
tags: [fast_run, shiny]
script:
- |
if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
git fetch origin $CI_MERGE_REQUEST_DIFF_BASE_SHA --depth=1
git checkout FETCH_HEAD
idf-build-apps dump-manifest-sha \
--manifest-files $(find . -name ".build-test-rules.yml" | xargs) \
--output .manifest_sha
fi
artifacts:
paths:
- .manifest_sha
expire_in: 1 week
when: always
redundant_pass_job: redundant_pass_job:
stage: pre_check stage: pre_check
tags: [shiny, fast_run] tags: [shiny, fast_run]

View File

@ -90,6 +90,7 @@ def main(arguments: argparse.Namespace) -> None:
marker_expr='not host_test', marker_expr='not host_test',
config_rules_str=DEFAULT_CONFIG_RULES_STR, config_rules_str=DEFAULT_CONFIG_RULES_STR,
extra_default_build_targets=extra_default_build_targets, extra_default_build_targets=extra_default_build_targets,
compare_manifest_sha_filepath=arguments.compare_manifest_sha_filepath,
modified_components=arguments.modified_components, modified_components=arguments.modified_components,
modified_files=arguments.modified_files, modified_files=arguments.modified_files,
ignore_app_dependencies_components=arguments.ignore_app_dependencies_components, ignore_app_dependencies_components=arguments.ignore_app_dependencies_components,
@ -167,6 +168,11 @@ if __name__ == '__main__':
default=os.path.join(IDF_PATH, '.gitlab', 'ci', 'default-build-test-rules.yml'), default=os.path.join(IDF_PATH, '.gitlab', 'ci', 'default-build-test-rules.yml'),
help='default build test rules config file', help='default build test rules config file',
) )
parser.add_argument(
'--compare-manifest-sha-filepath',
default=os.path.join(IDF_PATH, '.manifest_sha'),
help='Path to the recorded manifest sha file generated by `idf-build-apps dump-manifest-sha`'
)
parser.add_argument( parser.add_argument(
'--modified-components', '--modified-components',
type=_separate_str_to_list, type=_separate_str_to_list,
@ -244,4 +250,8 @@ if __name__ == '__main__':
# setting default values # setting default values
args.ignore_app_dependencies_filepatterns = DEFAULT_FULL_BUILD_TEST_FILEPATTERNS args.ignore_app_dependencies_filepatterns = DEFAULT_FULL_BUILD_TEST_FILEPATTERNS
if not os.path.isfile(args.compare_manifest_sha_filepath):
# ignore if the file does not exist
args.compare_manifest_sha_filepath = None
main(args) main(args)

View File

@ -128,6 +128,7 @@ def get_all_apps(
config_rules_str: t.Optional[t.List[str]] = None, config_rules_str: t.Optional[t.List[str]] = None,
preserve_all: bool = False, preserve_all: bool = False,
extra_default_build_targets: t.Optional[t.List[str]] = None, extra_default_build_targets: t.Optional[t.List[str]] = None,
compare_manifest_sha_filepath: t.Optional[str] = None,
modified_components: t.Optional[t.List[str]] = None, modified_components: t.Optional[t.List[str]] = None,
modified_files: t.Optional[t.List[str]] = None, modified_files: t.Optional[t.List[str]] = None,
ignore_app_dependencies_components: t.Optional[t.List[str]] = None, ignore_app_dependencies_components: t.Optional[t.List[str]] = None,
@ -143,8 +144,10 @@ def get_all_apps(
:param config_rules_str: config rules string :param config_rules_str: config rules string
:param preserve_all: preserve all apps :param preserve_all: preserve all apps
:param extra_default_build_targets: extra default build targets :param extra_default_build_targets: extra default build targets
:param compare_manifest_sha_filepath: check manifest sha filepath
:param modified_components: modified components :param modified_components: modified components
:param modified_files: modified files :param modified_files: modified files
:param ignore_app_dependencies_components: ignore app dependencies components
:param ignore_app_dependencies_filepatterns: ignore app dependencies filepatterns :param ignore_app_dependencies_filepatterns: ignore app dependencies filepatterns
:return: tuple of test-required apps and non-test-related apps :return: tuple of test-required apps and non-test-related apps
""" """
@ -162,6 +165,7 @@ def get_all_apps(
size_json_filename='size.json', size_json_filename='size.json',
check_warnings=True, check_warnings=True,
manifest_rootpath=IDF_PATH, manifest_rootpath=IDF_PATH,
compare_manifest_sha_filepath=compare_manifest_sha_filepath,
manifest_files=get_all_manifest_files(), manifest_files=get_all_manifest_files(),
default_build_targets=SUPPORTED_TARGETS + (extra_default_build_targets or []), default_build_targets=SUPPORTED_TARGETS + (extra_default_build_targets or []),
modified_components=modified_components, modified_components=modified_components,