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

ci/eval/compare: truncate step summary to 1024k #365366

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
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
)
Loading