Skip to content

Commit

Permalink
ci/eval/compare: truncate step summary to 1024k (#365366)
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil authored Dec 20, 2024
2 parents 247e9b2 + 44dc31e commit 4fbf4bc
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions ci/eval/compare/generate-step-summary.jq
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"<details> <summary>" + title + " (" + (xs | length | tostring) + ")</summary>\n\n" + itemize_packages(xs) + "</details>";
"<details> <summary>" + get_title(title; xs) + "</summary>\n\n" + itemize_packages(xs) + "</details>";

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
)

0 comments on commit 4fbf4bc

Please sign in to comment.