mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Always skip database upload if AnalysisKind.CodeScanning is not enabled
This commit is contained in:
6
lib/analyze-action.js
generated
6
lib/analyze-action.js
generated
@@ -94082,6 +94082,12 @@ async function uploadDatabases(repositoryNwo, codeql, config, apiDetails, logger
|
|||||||
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!config.analysisKinds.includes("code-scanning" /* CodeScanning */)) {
|
||||||
|
logger.debug(
|
||||||
|
`Not uploading database because 'analysis-kinds: ${"code-scanning" /* CodeScanning */}' is not enabled.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isInTestMode()) {
|
if (isInTestMode()) {
|
||||||
logger.debug("In test mode. Skipping database upload.");
|
logger.debug("In test mode. Skipping database upload.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import test from "ava";
|
|||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
import * as actionsUtil from "./actions-util";
|
||||||
|
import { AnalysisKind } from "./analyses";
|
||||||
import { GitHubApiDetails } from "./api-client";
|
import { GitHubApiDetails } from "./api-client";
|
||||||
import * as apiClient from "./api-client";
|
import * as apiClient from "./api-client";
|
||||||
import { createStubCodeQL } from "./codeql";
|
import { createStubCodeQL } from "./codeql";
|
||||||
@@ -108,6 +109,39 @@ test("Abort database upload if 'upload-database' input set to false", async (t)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Abort database upload if 'analysis-kinds: code-scanning' is not enabled", async (t) => {
|
||||||
|
await withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
sinon
|
||||||
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
|
.withArgs("upload-database")
|
||||||
|
.returns("true");
|
||||||
|
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
|
|
||||||
|
await mockHttpRequests(201);
|
||||||
|
|
||||||
|
const loggedMessages = [];
|
||||||
|
await uploadDatabases(
|
||||||
|
testRepoName,
|
||||||
|
getCodeQL(),
|
||||||
|
{
|
||||||
|
...getTestConfig(tmpDir),
|
||||||
|
analysisKinds: [AnalysisKind.CodeQuality],
|
||||||
|
},
|
||||||
|
testApiDetails,
|
||||||
|
getRecordingLogger(loggedMessages),
|
||||||
|
);
|
||||||
|
t.assert(
|
||||||
|
loggedMessages.find(
|
||||||
|
(v: LoggedMessage) =>
|
||||||
|
v.type === "debug" &&
|
||||||
|
v.message ===
|
||||||
|
"Not uploading database because 'analysis-kinds: code-scanning' is not enabled.",
|
||||||
|
) !== undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("Abort database upload if running against GHES", async (t) => {
|
test("Abort database upload if running against GHES", async (t) => {
|
||||||
await withTmpDir(async (tmpDir) => {
|
await withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
import * as actionsUtil from "./actions-util";
|
||||||
|
import { AnalysisKind } from "./analyses";
|
||||||
import { getApiClient, GitHubApiDetails } from "./api-client";
|
import { getApiClient, GitHubApiDetails } from "./api-client";
|
||||||
import { type CodeQL } from "./codeql";
|
import { type CodeQL } from "./codeql";
|
||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
@@ -22,6 +23,13 @@ export async function uploadDatabases(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!config.analysisKinds.includes(AnalysisKind.CodeScanning)) {
|
||||||
|
logger.debug(
|
||||||
|
`Not uploading database because 'analysis-kinds: ${AnalysisKind.CodeScanning}' is not enabled.`,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (util.isInTestMode()) {
|
if (util.isInTestMode()) {
|
||||||
logger.debug("In test mode. Skipping database upload.");
|
logger.debug("In test mode. Skipping database upload.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user