in docker_etl/ci_config.py [0:0]
def update_config(dry_run: bool = False) -> str:
"""Collect job and workflow configs per job and create new config."""
template_loader = jinja2.FileSystemLoader(CI_DIR)
template_env = jinja2.Environment(loader=template_loader)
config_template = template_env.get_template("config.template.yml")
job_configs = sorted(find_file_in_jobs(CI_JOB_NAME))
workflow_configs = sorted(find_file_in_jobs(CI_WORKFLOW_NAME))
invalid_configs = [
str(conf.relative_to(ROOT_DIR))
for conf in job_configs + workflow_configs
if not validate_yaml(conf)
]
if len(invalid_configs) > 0:
print("Error: Invalid CI configs", file=sys.stderr)
print("\n".join(invalid_configs), file=sys.stderr)
sys.exit(1)
config_text = config_template.render(
config_header=CI_CONFIG_HEADER,
jobs="\n\n".join([file_path.read_text() for file_path in job_configs]),
workflows="\n\n".join(
[file_path.read_text() for file_path in workflow_configs]
),
)
if dry_run:
print(config_text)
else:
with open(ROOT_DIR / ".circleci" / "config.yml", "w") as f:
f.write(config_text)
return config_text