forked from espressif/esp-idf
ci: support build only label
This commit is contained in:
@@ -29,3 +29,5 @@ TEST_RELATED_APPS_DOWNLOAD_URLS_FILENAME = 'test_related_apps_download_urls.yml'
|
|||||||
REPORT_TEMPLATE_FILEPATH = os.path.join(
|
REPORT_TEMPLATE_FILEPATH = os.path.join(
|
||||||
IDF_PATH, 'tools', 'ci', 'dynamic_pipelines', 'templates', 'report.template.html'
|
IDF_PATH, 'tools', 'ci', 'dynamic_pipelines', 'templates', 'report.template.html'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
BUILD_ONLY_LABEL = 'For Maintainers: Only Build Tests'
|
||||||
|
@@ -100,6 +100,9 @@ def main(arguments: argparse.Namespace) -> None:
|
|||||||
)
|
)
|
||||||
build_jobs.append(non_test_apps_build_job)
|
build_jobs.append(non_test_apps_build_job)
|
||||||
|
|
||||||
|
if mr_labels := os.getenv('CI_MERGE_REQUEST_LABELS'):
|
||||||
|
print(f'MR labels: {mr_labels}')
|
||||||
|
|
||||||
# check if there's no jobs
|
# check if there's no jobs
|
||||||
if not build_jobs:
|
if not build_jobs:
|
||||||
print('No apps need to be built. Create one empty job instead')
|
print('No apps need to be built. Create one empty job instead')
|
||||||
|
@@ -15,8 +15,8 @@ import typing as t
|
|||||||
from collections import Counter, defaultdict
|
from collections import Counter, defaultdict
|
||||||
|
|
||||||
import __init__ # noqa: F401 # inject the system path
|
import __init__ # noqa: F401 # inject the system path
|
||||||
from dynamic_pipelines.constants import (DEFAULT_CASES_TEST_PER_JOB, DEFAULT_TARGET_TEST_CHILD_PIPELINE_FILEPATH,
|
from dynamic_pipelines.constants import (BUILD_ONLY_LABEL, DEFAULT_CASES_TEST_PER_JOB,
|
||||||
DEFAULT_TEST_PATHS)
|
DEFAULT_TARGET_TEST_CHILD_PIPELINE_FILEPATH, DEFAULT_TEST_PATHS)
|
||||||
from dynamic_pipelines.models import EmptyJob, Job, TargetTestJob
|
from dynamic_pipelines.models import EmptyJob, Job, TargetTestJob
|
||||||
from dynamic_pipelines.utils import dump_jobs_to_yaml
|
from dynamic_pipelines.utils import dump_jobs_to_yaml
|
||||||
from gitlab.v4.objects import Project
|
from gitlab.v4.objects import Project
|
||||||
@@ -41,7 +41,17 @@ def get_tags_with_amount(s: str) -> t.List[str]:
|
|||||||
return sorted(res)
|
return sorted(res)
|
||||||
|
|
||||||
|
|
||||||
def generate_target_test_child_pipeline(project: Project, paths: str, apps: t.List[App], output_filepath: str) -> None:
|
def get_target_test_jobs(project: Project, paths: str, apps: t.List[App]) -> t.Tuple[t.List[Job], t.List[str]]:
|
||||||
|
"""
|
||||||
|
Return the target test jobs and the extra yaml files to include
|
||||||
|
"""
|
||||||
|
if mr_labels := os.getenv('CI_MERGE_REQUEST_LABELS'):
|
||||||
|
print(f'MR labels: {mr_labels}')
|
||||||
|
|
||||||
|
if BUILD_ONLY_LABEL in mr_labels.split(','):
|
||||||
|
print('MR has build only label, skip generating target test child pipeline')
|
||||||
|
return [EmptyJob()], []
|
||||||
|
|
||||||
pytest_cases = get_pytest_cases(
|
pytest_cases = get_pytest_cases(
|
||||||
paths,
|
paths,
|
||||||
apps=apps,
|
apps=apps,
|
||||||
@@ -78,13 +88,18 @@ def generate_target_test_child_pipeline(project: Project, paths: str, apps: t.Li
|
|||||||
|
|
||||||
target_test_jobs.append(target_test_job)
|
target_test_jobs.append(target_test_job)
|
||||||
|
|
||||||
|
extra_include_yml: t.List[str] = []
|
||||||
if not target_test_jobs:
|
if not target_test_jobs:
|
||||||
print('No target test cases required, create one empty job instead')
|
print('No target test cases required, create one empty job instead')
|
||||||
target_test_jobs.append(EmptyJob())
|
target_test_jobs.append(EmptyJob())
|
||||||
extra_include_yml = []
|
|
||||||
else:
|
else:
|
||||||
extra_include_yml = ['tools/ci/dynamic_pipelines/templates/generate_target_test_report.yml']
|
extra_include_yml = ['tools/ci/dynamic_pipelines/templates/generate_target_test_report.yml']
|
||||||
|
|
||||||
|
return target_test_jobs, extra_include_yml
|
||||||
|
|
||||||
|
|
||||||
|
def generate_target_test_child_pipeline(project: Project, paths: str, apps: t.List[App], output_filepath: str) -> None:
|
||||||
|
target_test_jobs, extra_include_yml = get_target_test_jobs(project, paths, apps)
|
||||||
dump_jobs_to_yaml(target_test_jobs, output_filepath, extra_include_yml)
|
dump_jobs_to_yaml(target_test_jobs, output_filepath, extra_include_yml)
|
||||||
print(f'Generate child pipeline yaml file {output_filepath} with {sum(j.parallel for j in target_test_jobs)} jobs')
|
print(f'Generate child pipeline yaml file {output_filepath} with {sum(j.parallel for j in target_test_jobs)} jobs')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user