From 44dc31e67631169c80b1d82afa27fab8010d6aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 12 Dec 2024 13:23:06 +0100 Subject: [PATCH] ci/eval/compare: truncate step summary to 1024k --- ci/eval/compare/generate-step-summary.jq | 27 ++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/ci/eval/compare/generate-step-summary.jq b/ci/eval/compare/generate-step-summary.jq index 28597eaec371f..961877cd27974 100644 --- a/ci/eval/compare/generate-step-summary.jq +++ b/ci/eval/compare/generate-step-summary.jq @@ -4,12 +4,27 @@ def truncate(xs; n): end; def itemize_packages(xs): - # we truncate the list to stay below the GitHub limit of 1MB per step summary. - truncate(xs; 3000) | map("- [\(.)](https://search.nixos.org/packages?channel=unstable&show=\(.)&from=0&size=50&sort=relevance&type=packages&query=\(.))") | join("\n"); + truncate(xs; 2000) | + map("- [\(.)](https://search.nixos.org/packages?channel=unstable&show=\(.)&from=0&size=50&sort=relevance&type=packages&query=\(.))") | + join("\n"); + +def get_title(s; xs): + s + " (" + (xs | length | tostring) + ")"; def section(title; xs): - "
" + title + " (" + (xs | length | tostring) + ")\n\n" + itemize_packages(xs) + "
"; + "
" + get_title(title; xs) + "\n\n" + itemize_packages(xs) + "
"; + +def fallback_document(content; n): + if content | utf8bytelength > n then + get_title("Added packages"; .attrdiff.added) + "\n\n" + + get_title("Removed packages"; .attrdiff.removed) + "\n\n" + + get_title("Changed packages"; .attrdiff.changed) + else content + end; -section("Added packages"; .attrdiff.added) + "\n\n" + -section("Removed packages"; .attrdiff.removed) + "\n\n" + -section("Changed packages"; .attrdiff.changed) +# we truncate the list to stay below the GitHub limit of 1MB per step summary. +fallback_document( + section("Added packages"; .attrdiff.added) + "\n\n" + + section("Removed packages"; .attrdiff.removed) + "\n\n" + + section("Changed packages"; .attrdiff.changed); 1000 * 1000 +)