def build_tasks_hierarchy(swarmci_config, task_factory):
stages_from_yaml = swarmci_config.pop('stages', None)
if stages_from_yaml is None:
raise SwarmCIError('Did not find "stages" key in the .swarmci file.')
elif type(stages_from_yaml) is not list:
raise SwarmCIError('The value of the "stages" key should be a list in the .swarmci file.')
thread_pool_executor = ThreadPoolExecutor(max_workers=25)
stage_tasks = []
for stage in stages_from_yaml:
job_tasks = []
for job in stage['jobs']:
commands = []
for cmd in job['commands']:
commands.append(task_factory.create(TaskType.COMMAND, cmd=cmd))
job_tasks.append(task_factory.create(TaskType.JOB, job=job, commands=commands))
stage_tasks.append(
task_factory.create(TaskType.STAGE, stage=stage, jobs=job_tasks, thread_pool_executor=thread_pool_executor))
return task_factory.create(TaskType.BUILD, stages=stage_tasks)
评论列表
文章目录