in lib/litani_report.py [0:0]
def render(run, report_dir, pipeline_depgraph_renderer):
temporary_report_dir = litani.get_report_data_dir() / str(uuid.uuid4())
temporary_report_dir.mkdir(parents=True)
old_report_dir_path = litani.get_report_dir().resolve()
old_report_dir = litani.ExpireableDirectory(old_report_dir_path)
artifact_dir = temporary_report_dir / "artifacts"
shutil.copytree(litani.get_artifacts_dir(), artifact_dir)
template_dir = pathlib.Path(__file__).parent.parent / "templates"
env = jinja2.Environment(
loader=jinja2.FileSystemLoader(str(template_dir)),
autoescape=jinja2.select_autoescape(
enabled_extensions=('html'),
default_for_string=True))
render_artifact_indexes(artifact_dir, env)
gnuplot = Gnuplot()
svgs = get_dashboard_svgs(run, env, gnuplot)
litani_report_archive_path = os.getenv("LITANI_REPORT_ARCHIVE_PATH")
dash_templ = env.get_template("dashboard.jinja.html")
page = dash_templ.render(
run=run, svgs=svgs,
litani_version=litani.VERSION,
litani_report_archive_path=litani_report_archive_path,
summary=get_summary(run))
with litani.atomic_write(temporary_report_dir / "index.html") as handle:
print(page, file=handle)
with litani.atomic_write(temporary_report_dir / litani.RUN_FILE) as handle:
print(json.dumps(run, indent=2), file=handle)
pipe_templ = env.get_template("pipeline.jinja.html")
for pipe in run["pipelines"]:
pipeline_depgraph_renderer.render(
render_root=temporary_report_dir,
pipe_url=pathlib.Path(pipe["url"]), pipe=pipe)
for stage in pipe["ci_stages"]:
for job in stage["jobs"]:
if JobOutcomeTableRenderer.should_render(job):
JobOutcomeTableRenderer.render(
temporary_report_dir / pipe["url"], env, job)
if MemoryTraceRenderer.should_render(job):
MemoryTraceRenderer.render(
temporary_report_dir / pipe["url"], env, job, gnuplot)
pipe_page = pipe_templ.render(run=run, pipe=pipe)
with litani.atomic_write(
temporary_report_dir / pipe["url"] / "index.html") as handle:
print(pipe_page, file=handle)
temp_symlink_dir = report_dir.with_name(report_dir.name + str(uuid.uuid4()))
os.symlink(temporary_report_dir, temp_symlink_dir)
os.rename(temp_symlink_dir, report_dir)
# Release lock so that other processes can read from this directory
new_report_dir = litani.LockableDirectory(report_dir.resolve())
new_report_dir.release()
if old_report_dir_path.exists():
old_report_dir.expire()
litani.unlink_expired()