mirror of
https://github.com/github/codeql-action.git
synced 2026-01-01 04:00:24 +08:00
Move UploadKind check into uploadSarif
This commit is contained in:
@@ -344,8 +344,10 @@ async function run() {
|
||||
}
|
||||
core.setOutput("db-locations", dbLocations);
|
||||
core.setOutput("sarif-output", path.resolve(outputDir));
|
||||
const uploadInput = actionsUtil.getOptionalInput("upload");
|
||||
if (runStats && actionsUtil.getUploadValue(uploadInput) === "always") {
|
||||
const uploadKind = actionsUtil.getUploadValue(
|
||||
actionsUtil.getOptionalInput("upload"),
|
||||
);
|
||||
if (runStats) {
|
||||
const checkoutPath = actionsUtil.getRequiredInput("checkout_path");
|
||||
const category = actionsUtil.getOptionalInput("category");
|
||||
|
||||
@@ -353,6 +355,7 @@ async function run() {
|
||||
uploadResults = await uploadSarif(
|
||||
logger,
|
||||
features,
|
||||
uploadKind,
|
||||
checkoutPath,
|
||||
outputDir,
|
||||
category,
|
||||
|
||||
@@ -93,6 +93,7 @@ async function run() {
|
||||
const uploadResults = await uploadSarif(
|
||||
logger,
|
||||
features,
|
||||
"always",
|
||||
checkoutPath,
|
||||
sarifPath,
|
||||
category,
|
||||
|
||||
@@ -64,7 +64,13 @@ const uploadSarifMacro = test.macro({
|
||||
fs.writeFileSync(sarifFile, "");
|
||||
}
|
||||
|
||||
const actual = await uploadSarif(logger, features, "", testPath);
|
||||
const actual = await uploadSarif(
|
||||
logger,
|
||||
features,
|
||||
"always",
|
||||
"",
|
||||
testPath,
|
||||
);
|
||||
|
||||
for (const analysisKind of Object.values(AnalysisKind)) {
|
||||
const analysisKindResult = expectedResult[analysisKind];
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { UploadKind } from "./actions-util";
|
||||
import * as analyses from "./analyses";
|
||||
import { FeatureEnablement } from "./feature-flags";
|
||||
import { Logger } from "./logging";
|
||||
@@ -14,6 +15,7 @@ export type UploadSarifResults = Partial<
|
||||
*
|
||||
* @param logger The logger to use.
|
||||
* @param features Information about enabled features.
|
||||
* @param uploadKind The kind of upload that is requested.
|
||||
* @param checkoutPath The path where the repository was checked out at.
|
||||
* @param sarifPath The path to the file or directory to upload.
|
||||
* @param category The analysis category.
|
||||
@@ -23,6 +25,7 @@ export type UploadSarifResults = Partial<
|
||||
export async function uploadSarif(
|
||||
logger: Logger,
|
||||
features: FeatureEnablement,
|
||||
uploadKind: UploadKind,
|
||||
checkoutPath: string,
|
||||
sarifPath: string,
|
||||
category?: string,
|
||||
@@ -46,12 +49,15 @@ export async function uploadSarif(
|
||||
analysisConfig,
|
||||
);
|
||||
|
||||
uploadResults[analysisKind] = await upload_lib.uploadProcessedFiles(
|
||||
logger,
|
||||
checkoutPath,
|
||||
analysisConfig,
|
||||
processingResults,
|
||||
);
|
||||
// Only perform the actual upload of the processed files, if `uploadKind` is `always`.
|
||||
if (uploadKind === "always") {
|
||||
uploadResults[analysisKind] = await upload_lib.uploadProcessedFiles(
|
||||
logger,
|
||||
checkoutPath,
|
||||
analysisConfig,
|
||||
processingResults,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return uploadResults;
|
||||
|
||||
Reference in New Issue
Block a user