From 16df8cfcd9947d14023fb4f6a6cada492bef0628 Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Wed, 28 Aug 2024 16:58:31 +0530 Subject: [PATCH] stable-rc: use common templates created for `stable` Use common templates such as `stable_build.j2`, `stable_revision.j2`, `stable_revision_summary.j2`, and `common.j2` to avoid duplication in `stable-rc` and `stable-rt` report templates. Signed-off-by: Jeny Sadadia --- .../monitor/subscriptions/linux_stable_rc.py | 2 +- kcidb/templates/stable_rc.j2 | 3 -- kcidb/templates/stable_rc_build.j2 | 48 ------------------- kcidb/templates/stable_rc_revision.j2 | 34 ------------- .../stable_rc_revision_description.txt.j2 | 6 +-- .../stable_rc_revision_summary.txt.j2 | 3 -- kcidb/templates/stable_rc_test.j2 | 9 ++-- 7 files changed, 8 insertions(+), 97 deletions(-) delete mode 100644 kcidb/templates/stable_rc.j2 delete mode 100644 kcidb/templates/stable_rc_build.j2 delete mode 100644 kcidb/templates/stable_rc_revision.j2 delete mode 100644 kcidb/templates/stable_rc_revision_summary.txt.j2 diff --git a/kcidb/monitor/subscriptions/linux_stable_rc.py b/kcidb/monitor/subscriptions/linux_stable_rc.py index a743056c..912540c6 100644 --- a/kcidb/monitor/subscriptions/linux_stable_rc.py +++ b/kcidb/monitor/subscriptions/linux_stable_rc.py @@ -26,7 +26,7 @@ def match_revision(revision): # Send notification 3 hours after a revision is created/updated return (Message( subject='KernelCI report for stable-rc: ' - '{% include "stable_rc_revision_summary.txt.j2" %}', + '{% include "stable_revision_summary.txt.j2" %}', to=["Jeny Sadadia ", "Gustavo Padovan ", "Shreeya Patel "], diff --git a/kcidb/templates/stable_rc.j2 b/kcidb/templates/stable_rc.j2 deleted file mode 100644 index 4b904fb2..00000000 --- a/kcidb/templates/stable_rc.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{# stable-rc macros #} -{% set selected_origins = ['maestro', 'broonie'] %} -{% set indent = " " %} diff --git a/kcidb/templates/stable_rc_build.j2 b/kcidb/templates/stable_rc_build.j2 deleted file mode 100644 index d74b8987..00000000 --- a/kcidb/templates/stable_rc_build.j2 +++ /dev/null @@ -1,48 +0,0 @@ -{# Build template macros #} -{% import "stable_rc.j2" as stable_rc_macros %} -{% from "stable_rc.j2" import indent %} - -{% macro build_stats(container) %} - {% if container.builds %} - {% set invalid_builds = - container.builds | selectattr("valid", "false") | - selectattr('origin', 'in', stable_rc_macros.selected_origins) | list %} - {% set valid_builds = - container.builds | selectattr("valid", "true") | - selectattr('origin', 'in', stable_rc_macros.selected_origins) | list %} - {% set invalid_build_count = invalid_builds | length %} - {% set valid_build_count = valid_builds | length %} - {{- valid_build_count | string + " passed, " + - invalid_build_count | string + " failed" }} - {% endif %} -{% endmacro %} - -{% macro container_summary(container, max_list_len) %} - {% if container.builds %} - {{- "\nBUILDS" }} - {% set invalid_builds = - container.builds | selectattr("valid", "false") | - selectattr('origin', 'in', stable_rc_macros.selected_origins) | - rejectattr('architecture', 'none') | list %} - {% set invalid_build_count = invalid_builds | length %} - {% if invalid_builds %} - {{- "\n Failures" }} - {% for origin, builds in invalid_builds|groupby("origin") %} - {% for build in builds %} - {{- [( indent + '-') + build.architecture, - none if build.config_name is none else ('(' + build.config_name + ')')] | - reject("none") | join(" ") -}} - {{- "\n" + indent + "Build detail: https://kcidb.kernelci.org/d/build/build?orgId=1&var-id=" + build.id}} - {% if build.log_excerpt %} - {{- indent + "Build error: " + build.log_error }} - {% endif %} - {% endfor %} - {{- indent + "CI system: " + origin + "\n\n"-}} - {% endfor %} - {% else %} - {{- "\n No build failures found" }} - {% endif %} - {% else %} - {{- "\n No builds found" }} - {% endif %} -{% endmacro %} diff --git a/kcidb/templates/stable_rc_revision.j2 b/kcidb/templates/stable_rc_revision.j2 deleted file mode 100644 index 75e7861d..00000000 --- a/kcidb/templates/stable_rc_revision.j2 +++ /dev/null @@ -1,34 +0,0 @@ -{# Revision template macros #} - -{% macro summary(revision) %} - {% set git_repository_url = - revision.repo_branch_checkouts | list | first %} - {% set git_repository_branch = - revision.repo_branch_checkouts[git_repository_url] | list | first %} - {% set location = none - if git_repository_url is none - else (git_repository_branch | - reject("none") | join("")) %} - {% set commit = (none - if revision.git_commit_hash is none - else revision.git_commit_hash[:12]) - if revision.git_commit_name is none - else revision.git_commit_name %} - {% set location_commit = [location, commit] | reject("none") | - join("@") | default(none, true) %} - {% set patches = ("+" + (revision.patchset_files | length | string) + "P") - if revision.patchset_files - else none %} - {% set location_commit_patches = - none - if location_commit is none - else ([location_commit, patches] | reject("none") | join("")) %} - {% set comment = - revision.repo_branch_checkouts[git_repository_url] - [git_repository_branch] | - map(attribute="comment") | reject("none") | first | default(none) - %} - {{- [location_commit_patches, - none if comment is none else ('"' + comment + '"')] | - reject("none") | join(" ") -}} -{% endmacro %} diff --git a/kcidb/templates/stable_rc_revision_description.txt.j2 b/kcidb/templates/stable_rc_revision_description.txt.j2 index a03c7979..c3a0b719 100644 --- a/kcidb/templates/stable_rc_revision_description.txt.j2 +++ b/kcidb/templates/stable_rc_revision_description.txt.j2 @@ -1,7 +1,7 @@ {# Revision description template #} -{% import "stable_rc.j2" as stable_rc_macros %} +{% from "common.j2" import selected_origins %} {% import "stable_rc_test.j2" as test_macros %} -{% import "stable_rc_build.j2" as build_macros %} +{% import "stable_build.j2" as build_macros %} {% import "misc.j2" as misc_macros %} {# Maximum length of a list of things (builds/tests/etc.) #} {% set max_list_len = 5 %} @@ -18,7 +18,7 @@ OVERVIEW Boot tests: {{ test_macros.tests_stats(revision) }} {% endif %} CI systems: {{ revision.checkouts | map(attribute="origin") | - unique | sort | select('in', stable_rc_macros.selected_origins) | join(", ") }} + unique | sort | select('in', selected_origins) | join(", ") }} REVISION diff --git a/kcidb/templates/stable_rc_revision_summary.txt.j2 b/kcidb/templates/stable_rc_revision_summary.txt.j2 deleted file mode 100644 index 9d80a493..00000000 --- a/kcidb/templates/stable_rc_revision_summary.txt.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{# Revision (single-line) summary template #} -{% import "stable_rc_revision.j2" as revision_macros %} -{{- revision_macros.summary(revision) -}} diff --git a/kcidb/templates/stable_rc_test.j2 b/kcidb/templates/stable_rc_test.j2 index fd918356..a181f313 100644 --- a/kcidb/templates/stable_rc_test.j2 +++ b/kcidb/templates/stable_rc_test.j2 @@ -1,12 +1,11 @@ {# Test macros #} -{% import "stable_rc.j2" as stable_rc_macros %} -{% from "stable_rc.j2" import indent %} +{% from "common.j2" import selected_origins, indent %} {% macro tests_stats(container) %} {% if container.tests %} {% set boot_tests = container.tests_root["boot"].waived_status_tests %} - {% set failed_tests = boot_tests[false]["FAIL"] | selectattr('origin', 'in', stable_rc_macros.selected_origins) | list %} - {% set passed_tests = boot_tests[false]["PASS"] | selectattr('origin', 'in', stable_rc_macros.selected_origins) | list %} + {% set failed_tests = boot_tests[false]["FAIL"] | selectattr('origin', 'in', selected_origins) | list %} + {% set passed_tests = boot_tests[false]["PASS"] | selectattr('origin', 'in', selected_origins) | list %} {{- passed_tests | length | string + " passed, " + failed_tests | length | string + " failed" }} {% endif %} @@ -16,7 +15,7 @@ {{- "\nBOOT TESTS" }} {% if container.tests %} {% set failed_boot_tests = container.tests_root["boot"].waived_status_tests[false]["FAIL"] | - selectattr('origin', 'in', stable_rc_macros.selected_origins) | list %} + selectattr('origin', 'in', selected_origins) | list %} {% if failed_boot_tests %} {{- "\n Failures" }} {% for origin, boot_tests in failed_boot_tests|groupby("origin") %}