From 5d2700f9cbcdfd67a172405ed36c95850ccf35bf Mon Sep 17 00:00:00 2001 From: Chris Gavin Date: Fri, 1 May 2020 11:07:58 +0100 Subject: [PATCH 1/3] Increase the log level of the message showing what SARIF files were uploaded. --- lib/upload-lib.js | 2 +- src/upload-lib.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/upload-lib.js b/lib/upload-lib.js index f28f085a4..2136fee71 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -85,7 +85,7 @@ async function uploadFiles(sarifFiles) { const ref = util.getRequiredEnvParam('GITHUB_REF'); // it's in the form "refs/heads/master" const analysisName = util.getRequiredEnvParam('GITHUB_WORKFLOW'); const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT]; - core.debug("Uploading sarif files: " + JSON.stringify(sarifFiles)); + core.info("Uploading sarif files: " + JSON.stringify(sarifFiles)); let sarifPayload = combineSarifFiles(sarifFiles); sarifPayload = fingerprints.addFingerprints(sarifPayload); const zipped_sarif = zlib_1.default.gzipSync(sarifPayload).toString('base64'); diff --git a/src/upload-lib.ts b/src/upload-lib.ts index 8c6a31e4e..105e440b1 100644 --- a/src/upload-lib.ts +++ b/src/upload-lib.ts @@ -79,7 +79,7 @@ async function uploadFiles(sarifFiles: string[]) { const analysisName = util.getRequiredEnvParam('GITHUB_WORKFLOW'); const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT]; - core.debug("Uploading sarif files: " + JSON.stringify(sarifFiles)); + core.info("Uploading sarif files: " + JSON.stringify(sarifFiles)); let sarifPayload = combineSarifFiles(sarifFiles); sarifPayload = fingerprints.addFingerprints(sarifPayload); From b6a0306228047c89bc6638afbf4606fca113562b Mon Sep 17 00:00:00 2001 From: Chris Gavin Date: Fri, 1 May 2020 11:12:15 +0100 Subject: [PATCH 2/3] Fail the upload action if uploading a folder with no SARIF files in. --- lib/upload-lib.js | 3 +++ src/upload-lib.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 2136fee71..568d2934f 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -61,6 +61,9 @@ async function upload(input) { const sarifFiles = fs.readdirSync(input) .filter(f => f.endsWith(".sarif")) .map(f => path.resolve(input, f)); + if (sarifFiles.length === 0) { + core.setFailed("No SARIF files found to upload in \"" + input + "\"."); + } await uploadFiles(sarifFiles); } else { diff --git a/src/upload-lib.ts b/src/upload-lib.ts index 105e440b1..a4959ae36 100644 --- a/src/upload-lib.ts +++ b/src/upload-lib.ts @@ -54,6 +54,9 @@ export async function upload(input: string) { const sarifFiles = fs.readdirSync(input) .filter(f => f.endsWith(".sarif")) .map(f => path.resolve(input, f)); + if (sarifFiles.length === 0) { + core.setFailed("No SARIF files found to upload in \"" + input + "\"."); + } await uploadFiles(sarifFiles); } else { await uploadFiles([input]); From 4e9886ad2bf3b89c655a3c6c66a849ba06ae5b1e Mon Sep 17 00:00:00 2001 From: Chris Gavin Date: Fri, 1 May 2020 15:27:32 +0100 Subject: [PATCH 3/3] Stop the upload action early if no files will be uploaded. --- lib/upload-lib.js | 1 + src/upload-lib.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 568d2934f..a9abfb900 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -63,6 +63,7 @@ async function upload(input) { .map(f => path.resolve(input, f)); if (sarifFiles.length === 0) { core.setFailed("No SARIF files found to upload in \"" + input + "\"."); + return; } await uploadFiles(sarifFiles); } diff --git a/src/upload-lib.ts b/src/upload-lib.ts index a4959ae36..443a95e86 100644 --- a/src/upload-lib.ts +++ b/src/upload-lib.ts @@ -56,6 +56,7 @@ export async function upload(input: string) { .map(f => path.resolve(input, f)); if (sarifFiles.length === 0) { core.setFailed("No SARIF files found to upload in \"" + input + "\"."); + return; } await uploadFiles(sarifFiles); } else {