log some stats about the upload

This commit is contained in:
Robert Brignull 2020-05-15 17:25:34 +01:00
parent 6507fba7ec
commit b366432cb3
3 changed files with 28 additions and 1 deletions

13
lib/upload-lib.js generated
View file

@ -125,6 +125,15 @@ async function upload(input) {
}
}
exports.upload = upload;
// Counts the number of results in the given SARIF file
function countResultsInSarif(sarif) {
let numResults = 0;
for (const run of JSON.parse(sarif).runs) {
numResults += run.results.length;
}
return numResults;
}
exports.countResultsInSarif = countResultsInSarif;
// Uploads the given set of sarif files.
// Returns true iff the upload occurred and succeeded
async function uploadFiles(sarifFiles) {
@ -173,6 +182,10 @@ async function uploadFiles(sarifFiles) {
"started_at": startedAt,
"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);
// Mark that we have made an upload

File diff suppressed because one or more lines are too long