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

Quick Fix: truncate oversized core.summary outputs #788

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,13 @@ async function run(): Promise<void> {
summary.addScannedDependencies(changes)
printScannedDependencies(changes)

// include full summary in output; Actions will truncate if oversized
// core.summary output must also be kept below 1024k
let rendered = core.summary.stringify()
if (rendered.length >= summary.MAX_SUMMARY_LENGTH) {
rendered = rendered.substring(0, summary.MAX_SUMMARY_LENGTH)
core.summary.clear()
core.summary.addRaw(rendered)
}
core.setOutput('comment-content', rendered)

// if the summary is oversized, replace with minimal version
Expand Down
2 changes: 2 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: '⚠️'
}

export const MAX_SUMMARY_LENGTH = 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