Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templates: Break out build/test summaries #310

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 46 additions & 32 deletions kcidb/templates/build.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,43 @@
-}}
spbnick marked this conversation as resolved.
Show resolved Hide resolved
{% endmacro %}

{%- macro status(architecture,
invalid_build_count,
valid_build_count,
unknown_build_count,
build_fmt) -%}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be called architecture_status, as in "producing a summary for builds in an "architecture" container". However, it might turn out that we don't need this particular separate macro after all.

{{- build_fmt | format("?" if architecture is none
else architecture,
"❌" if invalid_build_count else "➖",
(invalid_build_count | string)
if invalid_build_count else "",
"✅" if valid_build_count else "➖",
(valid_build_count | string)
if valid_build_count else "",
"❓" if unknown_build_count else "➖",
(unknown_build_count | string)
if unknown_build_count else "") -}}
{% endmacro %}

{%- macro build_status(container, space="") -%}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be named something like container_status, since this is producing a build status summary for a container, not one particular build. Besides the file is already called build.j2 and having "build" in the name would be repeating ourselves.

{% set invalid_build_count =
container | selectattr("valid", "false") | list | length %}
{% set valid_build_count =
container | selectattr("valid", "true") | list | length %}
{% set unknown_build_count =
container | selectattr("valid", "none") | list | length %}
{% set build_fmt = get_build_format(space,
invalid_build_count,
valid_build_count,
unknown_build_count)
%}
{{- status("",
invalid_build_count,
valid_build_count,
unknown_build_count,
build_fmt) -}}
{% endmacro %}

{% macro container_summary(container, max_list_len) %}
{% if container.builds %}
{{- "\nBUILDS" }}
Expand All @@ -34,43 +71,20 @@
{% set unknown_builds =
container.builds | selectattr("valid", "none") | list %}
{{- "\n Status" }}
{% set invalid_build_count = invalid_builds | length %}
{% set valid_build_count = valid_builds | length %}
{% set unknown_build_count = unknown_builds | length %}
{% set space = (( 8 + (container.architecture_valid_builds |
map("default", "", true) | map("length") | max)) | string) %}
{% set build_fmt = get_build_format(space,
invalid_build_count,
valid_build_count,
unknown_build_count)
%}
{% macro status(architecture,
invalid_build_count,
valid_build_count,
unknown_build_count) %}
{{- build_fmt | format("?" if architecture is none
else architecture,
"❌" if invalid_build_count else "➖",
(invalid_build_count | string)
if invalid_build_count else "",
"✅" if valid_build_count else "➖",
(valid_build_count | string)
if valid_build_count else "",
"❓" if unknown_build_count else "➖",
(unknown_build_count | string)
if unknown_build_count else "") -}}
{% endmacro %}
{{- status("",
invalid_build_count,
valid_build_count,
unknown_build_count) }}
{{- build_status(container.builds, space) }}
{{- "\n Architectures" }}
{% for architecture, valid_builds
{% for architecture, arch_valid_builds
in container.architecture_valid_builds.items() %}
{{- status(architecture,
valid_builds[false] | length,
valid_builds[true] | length,
valid_builds[none] | length) }}
arch_valid_builds[false] | length,
arch_valid_builds[true] | length,
arch_valid_builds[none] | length,
get_build_format(space,
invalid_builds | length,
valid_builds | length,
unknown_builds | length)) }}
{% endfor %}
{% if invalid_builds %}
{{- " Failures" }}
Expand Down