diff --git a/kcidb/templates/build.j2 b/kcidb/templates/build.j2 index 721472ff..2de5608b 100644 --- a/kcidb/templates/build.j2 +++ b/kcidb/templates/build.j2 @@ -1,4 +1,5 @@ {# Build template macros #} +{% import "test.j2" as test_macros %} {% macro summary(build) %} {{- [build.architecture, build.config_name, @@ -6,6 +7,20 @@ 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" }} diff --git a/kcidb/templates/checkout_description.txt.j2 b/kcidb/templates/checkout_description.txt.j2 index 10f0f746..39242c26 100644 --- a/kcidb/templates/checkout_description.txt.j2 +++ b/kcidb/templates/checkout_description.txt.j2 @@ -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 @@ -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 diff --git a/kcidb/templates/overview.j2 b/kcidb/templates/overview.j2 new file mode 100644 index 00000000..0c698621 --- /dev/null +++ b/kcidb/templates/overview.j2 @@ -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 " " pieces for all emojis #} + {%- for emoji, count in varargs[0].items() -%} + {%- if ns.max_emojis[emoji] > 0 -%} + + {# Add an " " 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 -%} diff --git a/kcidb/templates/revision_description.txt.j2 b/kcidb/templates/revision_description.txt.j2 index db83b243..4ecab2b8 100644 --- a/kcidb/templates/revision_description.txt.j2 +++ b/kcidb/templates/revision_description.txt.j2 @@ -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 @@ -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 diff --git a/kcidb/templates/test.j2 b/kcidb/templates/test.j2 index a83f5d6e..75e653d1 100644 --- a/kcidb/templates/test.j2 +++ b/kcidb/templates/test.j2 @@ -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) %} @@ -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) %} @@ -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" }}