Merge branch 'master' into upload_twice

This commit is contained in:
Robert Brignull
2020-05-18 14:29:49 +01:00
7 changed files with 70 additions and 2 deletions

13
lib/upload-lib.js generated
View File

@@ -112,6 +112,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) {
@@ -158,6 +167,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);
}