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 #320

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions kcidb/templates/build.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
{# Build template macros #}
{% import "test.j2" as test_macros %}

{% macro summary(build) %}
{{- [build.architecture, build.config_name,
none if build.comment is none else ('"' + build.comment + '"')] |
reject("none") | join(" ") | default(build.id, true) -}}
{% endmacro %}

{% macro container_emoji_counts(emoji_counts, container) %}
{% for emoji in test_macros.WAIVED_STATUS_EMOJIS.values() %}
{% set _ = emoji_counts.__setitem__(
emoji,
container.builds |
selectattr(
"valid",
"==",
{"❌": false, "✅": true, "❓": none}.get(emoji, {})
) | list | length
) %}
{% endfor %}
{% endmacro %}

{% macro container_summary(container, max_list_len) %}
{% if container.builds %}
{{- "\nBUILDS" }}
Expand Down
16 changes: 13 additions & 3 deletions kcidb/templates/checkout_description.txt.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% import "test.j2" as test_macros %}
{% import "build.j2" as build_macros %}
{% import "misc.j2" as misc_macros %}
{% import "overview.j2" as overview_macros %}
{# Maximum length of a list of things (builds/tests/etc.) #}
{% set max_list_len = 5 %}
Below is the summary of testing results Kernel CI database has recorded
Expand All @@ -11,13 +12,22 @@ for this checkout so far. See complete and up-to-date report at:

OVERVIEW

{%- set test_emoji_counts = {} %}
{% set _ = test_macros.container_emoji_counts(test_emoji_counts,
checkout) %}

{% set build_emoji_counts = {} %}
{%- set _ = build_macros.container_emoji_counts(build_emoji_counts,
checkout) %}

Checkout: {{ misc_macros.valid_badge(checkout.valid) }}
{% if checkout.builds %}
Builds: {{ misc_macros.valid_badge(checkout.builds_valid) }}
Builds: {{ overview_macros.emoji_counts(build_emoji_counts,
test_emoji_counts) }}
{% endif %}
{% if checkout.tests %}
Tests: {{ test_macros.waived_status_badge(checkout.tests_root.waived,
checkout.tests_root.status) }}
Tests: {{ overview_macros.emoji_counts(test_emoji_counts,
build_emoji_counts) }}
{% endif %}

CHECKOUT
Expand Down
48 changes: 48 additions & 0 deletions kcidb/templates/overview.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{# Overview template macros #}
{% import "test.j2" as test_macros %}

{%- macro emoji_counts() -%}
{%- set ns = namespace(
max_emojis={},
pieces=[],
trail=0
) -%}

{# Find maximum emoji counts accross all arguments #}
{%- for emoji in test_macros.WAIVED_STATUS_EMOJIS.values() -%}
{%- set _ = ns.max_emojis.__setitem__(
emoji, varargs | map(attribute=emoji) | max
) -%}
{%- endfor -%}

{# Build a list of "<emoji> <count>" pieces for all emojis #}
{%- for emoji, count in varargs[0].items() -%}
{%- if ns.max_emojis[emoji] > 0 -%}

{# Add an "<emoji> <count>" piece #}
{%- set _ = ns.pieces.extend([
(
"%s %" +
(ns.max_emojis[emoji] | string | length | string) +
"s"
) |
format(
"➖" if count == 0 else emoji,
"" if count == 0 else (count | string)
)
]) -%}

{# Get the number of trailling "➖" character #}
{%- if count -%}
{%- set ns.trail = 0 -%}
{%- else -%}
{%- set ns.trail = ns.trail + 1 -%}
{%- endif -%}

{%- endif -%}
{%- endfor -%}

{# Output the pieces of interest #}
{{- ns.pieces[:(ns.pieces | length) - ns.trail] | join(" ") -}}

{%- endmacro -%}
16 changes: 13 additions & 3 deletions kcidb/templates/revision_description.txt.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% import "test.j2" as test_macros %}
{% import "build.j2" as build_macros %}
{% import "misc.j2" as misc_macros %}
{% import "overview.j2" as overview_macros %}
{# Maximum length of a list of things (builds/tests/etc.) #}
{% set max_list_len = 5 %}
Below is the summary of results Kernel CI database has recorded
Expand All @@ -11,15 +12,24 @@ for this revision so far. See complete and up-to-date report at:

OVERVIEW

{% set test_emoji_counts = {} %}
{% set _ = test_macros.container_emoji_counts(test_emoji_counts,
revision) -%}

{% set build_emoji_counts = {} %}
{% set _ = build_macros.container_emoji_counts(build_emoji_counts,
revision) -%}

{% if revision.patchset_files %}
Patches: {{ misc_macros.valid_badge(revision.checkouts_valid) }}
{% endif %}
{% if revision.builds %}
Builds: {{ misc_macros.valid_badge(revision.builds_valid) }}
Builds: {{ overview_macros.emoji_counts(build_emoji_counts,
test_emoji_counts) }}
{% endif %}
{% if revision.tests %}
Tests: {{ test_macros.waived_status_badge(revision.tests_root.waived,
revision.tests_root.status) }}
Tests: {{ overview_macros.emoji_counts(test_emoji_counts,
build_emoji_counts) }}
{% endif %}

REVISION
Expand Down
49 changes: 39 additions & 10 deletions kcidb/templates/test.j2
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
{# Test macros #}

{# Waived value emojis in order of decreasing priority #}
{% set WAIVED_EMOJIS = {
false: "",
true: "🚧",
none: "❓",
} %}

{# Status value emojis in order of decreasing priority #}
{% set STATUS_EMOJIS = {
"FAIL": "❌",
"ERROR": "💥",
"PASS": "✅",
"DONE": "🆗",
"SKIP": "⏩",
none: "❓",
} %}

{# Combined waived and status values emojis in order of decreasing priority #}
{% set WAIVED_STATUS_EMOJIS = {} %}
{% for waived, waived_emoji in WAIVED_EMOJIS.items() %}
{% for status, status_emoji in STATUS_EMOJIS.items() %}
{% set _ = WAIVED_STATUS_EMOJIS.__setitem__(
(waived, status), waived_emoji + status_emoji
) %}
{% endfor %}
{% endfor %}

{% macro status_emoji(status) %}
{{- "💥" if status == "ERROR" else
"❌" if status == "FAIL" else
"✅" if status == "PASS" else
"🆗" if status == "DONE" else
"⏩" if status == "SKIP" else
"❓" -}}
{{- STATUS_EMOJI[status] -}}
{% endmacro %}

{% macro waived_emoji(waived) %}
{{- "🚧" if waived is true else
"" if waived is false else
"❓" -}}
{{- WAIVED_EMOJI(waived) -}}
{% endmacro %}

{% macro status_name(status) %}
Expand All @@ -24,7 +44,7 @@
{% endmacro %}

{% macro waived_status_emoji(waived, status) %}
{{- waived_emoji(waived) + status_emoji(status) -}}
{{- WAIVED_STATUS_EMOJIS[(waived, status)] -}}
{% endmacro %}

{% macro waived_status_badge(waived, status) %}
Expand All @@ -37,6 +57,15 @@
reject("none") | join(" ") | default(test.id, true) -}}
{% endmacro %}

{% macro container_emoji_counts(emoji_counts, container) %}
{% for (waived, status), emoji in WAIVED_STATUS_EMOJIS.items() %}
{% set _ = emoji_counts.__setitem__(
emoji,
container.tests_root.waived_status_nodes[waived][status] | length
) %}
{% endfor -%}
{% endmacro %}

{% macro container_summary(container, max_list_len) %}
{% if container.tests %}
{{- "\nTESTS" }}
Expand Down