From 293ccdb6e90bdef5f22a243d7215fcfac19b5b39 Mon Sep 17 00:00:00 2001 From: Eli Reisman Date: Mon, 16 Sep 2024 12:26:36 -0700 Subject: [PATCH] add truncation escape valve to new file summary to avoid overflow --- src/summary.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/summary.ts b/src/summary.ts index 53a860dba..35ac8750a 100644 --- a/src/summary.ts +++ b/src/summary.ts @@ -10,6 +10,8 @@ const icons = { warning: '⚠️' } +const MAX_SCANNED_FILES_BYTES = 1048576 + // generates the DR report summmary and caches it to the Action's core.summary. // returns the DR summary string, ready to be posted as a PR comment if the // final DR report is too large @@ -267,6 +269,21 @@ export function addScannedFiles(changes: Changes): void { const manifests = Array.from( groupDependenciesByManifest(changes).keys() ).sort() + + let sf_size = 0 + let trunc_at = -1 + + for (const [index, entry] of manifests.entries()) { + sf_size += entry.length + if (sf_size >= MAX_SCANNED_FILES_BYTES && trunc_at < 0) { + trunc_at = index + } + } + + if (trunc_at >= 0) { + manifests.slice(0, trunc_at) + } + core.summary.addHeading('Scanned Files', 2).addList(manifests) }