Skip to content

Commit 886b7d3

Browse files
Merge pull request #38 from github/upload_stats
Log some simple stats about the upload
2 parents 5c5f422 + 4e12efc commit 886b7d3

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

lib/upload-lib.js

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload-lib.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ export async function upload(input: string): Promise<boolean> {
128128
}
129129
}
130130

131+
// Counts the number of results in the given SARIF file
132+
export function countResultsInSarif(sarif: string): number {
133+
let numResults = 0;
134+
for (const run of JSON.parse(sarif).runs) {
135+
numResults += run.results.length;
136+
}
137+
return numResults;
138+
}
139+
131140
// Uploads the given set of sarif files.
132141
// Returns true iff the upload occurred and succeeded
133142
async function uploadFiles(sarifFiles: string[]): Promise<boolean> {
@@ -184,6 +193,11 @@ async function uploadFiles(sarifFiles: string[]): Promise<boolean> {
184193
"tool_names": toolNames,
185194
});
186195

196+
// Log some useful debug info about the info
197+
core.debug("Raw upload size: " + sarifPayload.length + " bytes");
198+
core.debug("Base64 zipped upload size: " + zipped_sarif.length + " bytes");
199+
core.debug("Number of results in upload: " + countResultsInSarif(sarifPayload));
200+
187201
// Make the upload
188202
succeeded = await uploadPayload(payload);
189203

0 commit comments

Comments
 (0)