formats/v1: properly format failed results

When the build fails, not all pipelines might have been built and
those pipelines will be missing from the results. Currently the
code assumes that all pipelines will have a result and this will
crash when trying to find an id for an pipeline that did not get
built.
This commit is contained in:
Christian Kellner 2021-01-19 15:54:21 +00:00
parent 4455b953ae
commit 673ea0dfca

View file

@ -110,8 +110,14 @@ def output(manifest: Manifest, res: Dict) -> Dict:
"""Convert a result into the v1 format"""
def result_for_pipeline(pipeline):
current = res[pipeline.id]
retval = {"success": current["success"]}
# The pipeline might not have been built one of its
# dependencies, i.e. its build pipeline, failed to
# build. We thus need to be tolerant of a missing
# result but still need to to recurse
current = res.get(pipeline.id, {})
retval = {
"success": current.get("success", False)
}
if pipeline.build:
build = manifest[pipeline.build]
retval["build"] = result_for_pipeline(build)