mirror of
https://github.com/github/codeql-action.git
synced 2025-12-23 15:50:11 +08:00
Previously, we weren't catching any possible exceptions in `createStatusReportBase` and runs would fail if any of the telemetry sub-items threw exceptions. As telemetry should not block the analysis, we continue here even if the status report throws.
91 lines
4.6 KiB
JavaScript
Generated
91 lines
4.6 KiB
JavaScript
Generated
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const core = __importStar(require("@actions/core"));
|
|
const actionsUtil = __importStar(require("./actions-util"));
|
|
const actions_util_1 = require("./actions-util");
|
|
const api_client_1 = require("./api-client");
|
|
const logging_1 = require("./logging");
|
|
const repository_1 = require("./repository");
|
|
const status_report_1 = require("./status-report");
|
|
const upload_lib = __importStar(require("./upload-lib"));
|
|
const util_1 = require("./util");
|
|
async function sendSuccessStatusReport(startedAt, uploadStats, logger) {
|
|
const statusReportBase = await (0, status_report_1.createStatusReportBase)(status_report_1.ActionName.UploadSarif, "success", startedAt, undefined, await (0, util_1.checkDiskUsage)(), logger);
|
|
if (statusReportBase !== undefined) {
|
|
const statusReport = {
|
|
...statusReportBase,
|
|
...uploadStats,
|
|
};
|
|
await (0, status_report_1.sendStatusReport)(statusReport);
|
|
}
|
|
}
|
|
async function run() {
|
|
const startedAt = new Date();
|
|
const logger = (0, logging_1.getActionsLogger)();
|
|
(0, util_1.initializeEnvironment)((0, actions_util_1.getActionVersion)());
|
|
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
|
(0, util_1.checkActionVersion)((0, actions_util_1.getActionVersion)(), gitHubVersion);
|
|
const startingStatusReportBase = await (0, status_report_1.createStatusReportBase)(status_report_1.ActionName.UploadSarif, "starting", startedAt, undefined, await (0, util_1.checkDiskUsage)(), logger);
|
|
if (startingStatusReportBase !== undefined) {
|
|
await (0, status_report_1.sendStatusReport)(startingStatusReportBase);
|
|
}
|
|
try {
|
|
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), logger);
|
|
core.setOutput("sarif-id", uploadResult.sarifID);
|
|
// We don't upload results in test mode, so don't wait for processing
|
|
if ((0, util_1.isInTestMode)()) {
|
|
core.debug("In test mode. Waiting for processing is disabled.");
|
|
}
|
|
else if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
|
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), uploadResult.sarifID, logger);
|
|
}
|
|
await sendSuccessStatusReport(startedAt, uploadResult.statusReport, logger);
|
|
}
|
|
catch (unwrappedError) {
|
|
const error = !(0, status_report_1.isFirstPartyAnalysis)(status_report_1.ActionName.UploadSarif) &&
|
|
unwrappedError instanceof upload_lib.InvalidSarifUploadError
|
|
? new util_1.ConfigurationError(unwrappedError.message)
|
|
: (0, util_1.wrapError)(unwrappedError);
|
|
const message = error.message;
|
|
core.setFailed(message);
|
|
console.log(error);
|
|
const errorStatusReportBase = await (0, status_report_1.createStatusReportBase)(status_report_1.ActionName.UploadSarif, (0, status_report_1.getActionsStatus)(error), startedAt, undefined, await (0, util_1.checkDiskUsage)(), logger, message, error.stack);
|
|
if (errorStatusReportBase !== undefined) {
|
|
await (0, status_report_1.sendStatusReport)(errorStatusReportBase);
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
async function runWrapper() {
|
|
try {
|
|
await run();
|
|
}
|
|
catch (error) {
|
|
core.setFailed(`codeql/upload-sarif action failed: ${(0, util_1.wrapError)(error).message}`);
|
|
}
|
|
}
|
|
void runWrapper();
|
|
//# sourceMappingURL=upload-sarif-action.js.map
|