mirror of
https://github.com/github/codeql-action.git
synced 2026-04-26 16:58:47 +00:00
Refactor prepareFailedSarif out of maybeUploadFailedSarif
This commit is contained in:
Generated
+47
-7
@@ -163855,6 +163855,34 @@ async function asyncSome(array, predicate) {
|
||||
const results = await Promise.all(array.map(predicate));
|
||||
return results.some((result) => result);
|
||||
}
|
||||
var Success = class {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
isSuccess() {
|
||||
return true;
|
||||
}
|
||||
isFailure() {
|
||||
return false;
|
||||
}
|
||||
orElse(_defaultValue) {
|
||||
return this.value;
|
||||
}
|
||||
};
|
||||
var Failure = class {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
isSuccess() {
|
||||
return false;
|
||||
}
|
||||
isFailure() {
|
||||
return true;
|
||||
}
|
||||
orElse(defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
// src/actions-util.ts
|
||||
var pkg = require_package();
|
||||
@@ -169755,9 +169783,11 @@ function createFailedUploadFailedSarifResult(error3) {
|
||||
upload_failed_run_stack_trace: wrappedError.stack
|
||||
};
|
||||
}
|
||||
async function maybeUploadFailedSarif(config, repositoryNwo, features, logger) {
|
||||
async function prepareFailedSarif(logger, features, config) {
|
||||
if (!config.codeQLCmd) {
|
||||
return { upload_failed_run_skipped_because: "CodeQL command not found" };
|
||||
return new Failure({
|
||||
upload_failed_run_skipped_because: "CodeQL command not found"
|
||||
});
|
||||
}
|
||||
const workflow = await getWorkflow(logger);
|
||||
const jobName = getRequiredEnvParam("GITHUB_JOB");
|
||||
@@ -169766,7 +169796,9 @@ async function maybeUploadFailedSarif(config, repositoryNwo, features, logger) {
|
||||
if (!["always", "failure-only"].includes(
|
||||
getUploadValue(shouldUpload)
|
||||
) || shouldSkipSarifUpload()) {
|
||||
return { upload_failed_run_skipped_because: "SARIF upload is disabled" };
|
||||
return new Failure({
|
||||
upload_failed_run_skipped_because: "SARIF upload is disabled"
|
||||
});
|
||||
}
|
||||
const category = getCategoryInputOrThrow(workflow, jobName, matrix);
|
||||
const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix);
|
||||
@@ -169778,11 +169810,19 @@ async function maybeUploadFailedSarif(config, repositoryNwo, features, logger) {
|
||||
} else {
|
||||
await codeql.databaseExportDiagnostics(databasePath, sarifFile, category);
|
||||
}
|
||||
logger.info(`Uploading failed SARIF file ${sarifFile}`);
|
||||
return new Success({ sarifFile, category, checkoutPath });
|
||||
}
|
||||
async function maybeUploadFailedSarif(config, repositoryNwo, features, logger) {
|
||||
const failedSarifResult = await prepareFailedSarif(logger, features, config);
|
||||
if (failedSarifResult.isFailure()) {
|
||||
return failedSarifResult.value;
|
||||
}
|
||||
const failedSarif = failedSarifResult.value;
|
||||
logger.info(`Uploading failed SARIF file ${failedSarif.sarifFile}`);
|
||||
const uploadResult = await uploadFiles(
|
||||
sarifFile,
|
||||
checkoutPath,
|
||||
category,
|
||||
failedSarif.sarifFile,
|
||||
failedSarif.checkoutPath,
|
||||
failedSarif.category,
|
||||
features,
|
||||
logger,
|
||||
CodeScanning
|
||||
|
||||
Reference in New Issue
Block a user