| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ import test from "ava"; | |||
| 5 | 5 | import * as sinon from "sinon"; | |
| 6 | 6 | ||
| 7 | 7 | import * as actionsUtil from "./actions-util"; | |
| 8 | + import { AnalysisKind } from "./analyses"; | ||
| 8 | 9 | import { GitHubApiDetails } from "./api-client"; | |
| 9 | 10 | import * as apiClient from "./api-client"; | |
| 10 | 11 | import { createStubCodeQL } from "./codeql"; | |
@@ -108,6 +109,39 @@ test("Abort database upload if 'upload-database' input set to false", async (t) | |||
| 108 | 109 | }); | |
| 109 | 110 | }); | |
| 110 | 111 | ||
| 112 | + test("Abort database upload if 'analysis-kinds: code-scanning' is not enabled", async (t) => { | ||
| 113 | + await withTmpDir(async (tmpDir) => { | ||
| 114 | + setupActionsVars(tmpDir, tmpDir); | ||
| 115 | + sinon | ||
| 116 | + .stub(actionsUtil, "getRequiredInput") | ||
| 117 | + .withArgs("upload-database") | ||
| 118 | + .returns("true"); | ||
| 119 | + sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true); | ||
| 120 | + | ||
| 121 | + await mockHttpRequests(201); | ||
| 122 | + | ||
| 123 | + const loggedMessages = []; | ||
| 124 | + await uploadDatabases( | ||
| 125 | + testRepoName, | ||
| 126 | + getCodeQL(), | ||
| 127 | + { | ||
| 128 | + ...getTestConfig(tmpDir), | ||
| 129 | + analysisKinds: [AnalysisKind.CodeQuality], | ||
| 130 | + }, | ||
| 131 | + testApiDetails, | ||
| 132 | + getRecordingLogger(loggedMessages), | ||
| 133 | + ); | ||
| 134 | + t.assert( | ||
| 135 | + loggedMessages.find( | ||
| 136 | + (v: LoggedMessage) => | ||
| 137 | + v.type === "debug" && | ||
| 138 | + v.message === | ||
| 139 | + "Not uploading database because 'analysis-kinds: code-scanning' is not enabled.", | ||
| 140 | + ) !== undefined, | ||
| 141 | + ); | ||
| 142 | + }); | ||
| 143 | + }); | ||
| 144 | + | ||
| 111 | 145 | test("Abort database upload if running against GHES", async (t) => { | |
| 112 | 146 | await withTmpDir(async (tmpDir) => { | |
| 113 | 147 | setupActionsVars(tmpDir, tmpDir); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | import * as fs from "fs"; | |
| 2 | 2 | ||
| 3 | 3 | import * as actionsUtil from "./actions-util"; | |
| 4 | + import { AnalysisKind } from "./analyses"; | ||
| 4 | 5 | import { getApiClient, GitHubApiDetails } from "./api-client"; | |
| 5 | 6 | import { type CodeQL } from "./codeql"; | |
| 6 | 7 | import { Config } from "./config-utils"; | |
@@ -22,6 +23,13 @@ export async function uploadDatabases( | |||
| 22 | 23 | return; | |
| 23 | 24 | } | |
| 24 | 25 | ||
| 26 | + if (!config.analysisKinds.includes(AnalysisKind.CodeScanning)) { | ||
| 27 | + logger.debug( | ||
| 28 | + `Not uploading database because 'analysis-kinds: ${AnalysisKind.CodeScanning}' is not enabled.`, | ||
| 29 | + ); | ||
| 30 | + return; | ||
| 31 | + } | ||
| 32 | + | ||
| 25 | 33 | if (util.isInTestMode()) { | |
| 26 | 34 | logger.debug("In test mode. Skipping database upload."); | |
| 27 | 35 | return; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments