From c979850d28a0a5c610702dfb7e15bea3c63b1755 Mon Sep 17 00:00:00 2001 From: David Verdeguer Date: Fri, 8 May 2020 16:06:35 +0200 Subject: [PATCH] Add test mode --- .github/workflows/integration-testing.yml | 7 +++++-- lib/upload-lib.js | 5 +++++ src/upload-lib.ts | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-testing.yml b/.github/workflows/integration-testing.yml index 1b3461fd2..ba838d218 100644 --- a/.github/workflows/integration-testing.yml +++ b/.github/workflows/integration-testing.yml @@ -22,7 +22,8 @@ jobs: shell: bash run: ./build.sh - uses: ./../action/analyze - + env: + TEST_MODE: true multi-language-repo/test-custom-queries: strategy: @@ -45,4 +46,6 @@ jobs: - name: Build code shell: bash run: ./build.sh - - uses: ./../action/analyze \ No newline at end of file + - uses: ./../action/analyze + env: + TEST_MODE: true \ No newline at end of file diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 6c8100d58..e092e0623 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -58,6 +58,11 @@ exports.combineSarifFiles = combineSarifFiles; // If the request fails then this will retry a small number of times. async function uploadPayload(payload) { core.info('Uploading results'); + // If in test mode we don't want to upload the results + const testMode = process.env['TEST_MODE'] === 'true' || false; + if (testMode) { + return true; + } const githubToken = core.getInput('token'); const ph = new auth.BearerCredentialHandler(githubToken); const client = new http.HttpClient('Code Scanning : Upload SARIF', [ph]); diff --git a/src/upload-lib.ts b/src/upload-lib.ts index 7eb44a635..0ceb6cf63 100644 --- a/src/upload-lib.ts +++ b/src/upload-lib.ts @@ -52,6 +52,12 @@ export function combineSarifFiles(sarifFiles: string[]): string { async function uploadPayload(payload): Promise { core.info('Uploading results'); + // If in test mode we don't want to upload the results + const testMode = process.env['TEST_MODE'] === 'true' || false; + if (testMode) { + return true; + } + const githubToken = core.getInput('token'); const ph: auth.BearerCredentialHandler = new auth.BearerCredentialHandler(githubToken); const client = new http.HttpClient('Code Scanning : Upload SARIF', [ph]);