add truncation escape valve to new file summary to avoid overflow

This commit is contained in:
Eli Reisman
2024-09-16 12:26:36 -07:00
parent 83c7cc6aa7
commit 293ccdb6e9

View File

@@ -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)
}