Skip to content

Commit

Permalink
add truncation escape valve to new file summary to avoid overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
elireisman committed Sep 16, 2024
1 parent 83c7cc6 commit 293ccdb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 293ccdb

Please sign in to comment.