Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #38 from github/upload_stats
Log some simple stats about the upload
Robert authored and GitHub committed May 18, 2020

Unverified

No user is associated with the committer email.
2 parents 5c5f422 + 4e12efc commit 886b7d3
Showing 3 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/upload-lib.js

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

2 changes: 1 addition & 1 deletion lib/upload-lib.js.map

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

14 changes: 14 additions & 0 deletions src/upload-lib.ts
@@ -128,6 +128,15 @@ export async function upload(input: string): Promise<boolean> {
}
}

// Counts the number of results in the given SARIF file
export function countResultsInSarif(sarif: string): number {
let numResults = 0;
for (const run of JSON.parse(sarif).runs) {
numResults += run.results.length;
}
return numResults;
}

// Uploads the given set of sarif files.
// Returns true iff the upload occurred and succeeded
async function uploadFiles(sarifFiles: string[]): Promise<boolean> {
@@ -184,6 +193,11 @@ async function uploadFiles(sarifFiles: string[]): Promise<boolean> {
"tool_names": toolNames,
});

// Log some useful debug info about the info
core.debug("Raw upload size: " + sarifPayload.length + " bytes");
core.debug("Base64 zipped upload size: " + zipped_sarif.length + " bytes");
core.debug("Number of results in upload: " + countResultsInSarif(sarifPayload));

// Make the upload
succeeded = await uploadPayload(payload);

0 comments on commit 886b7d3

Please sign in to comment.