Add event name to status report

This commit is contained in:
Henry Mercer 2024-02-26 19:36:37 +00:00
parent e4a536270d
commit 60465730fb
24 changed files with 83 additions and 38 deletions

View file

@ -32,8 +32,8 @@ 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) {
const statusReportBase = await (0, status_report_1.createStatusReportBase)("upload-sarif", "success", startedAt, undefined, await (0, util_1.checkDiskUsage)());
async function sendSuccessStatusReport(startedAt, uploadStats, logger) {
const statusReportBase = await (0, status_report_1.createStatusReportBase)("upload-sarif", "success", startedAt, undefined, await (0, util_1.checkDiskUsage)(), logger);
const statusReport = {
...statusReportBase,
...uploadStats,
@ -46,7 +46,7 @@ async function run() {
(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);
await (0, status_report_1.sendStatusReport)(await (0, status_report_1.createStatusReportBase)("upload-sarif", "starting", startedAt, undefined, await (0, util_1.checkDiskUsage)()));
await (0, status_report_1.sendStatusReport)(await (0, status_report_1.createStatusReportBase)("upload-sarif", "starting", startedAt, undefined, await (0, util_1.checkDiskUsage)(), logger));
try {
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), logger, { considerInvalidRequestConfigError: true });
core.setOutput("sarif-id", uploadResult.sarifID);
@ -57,14 +57,14 @@ async function run() {
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);
await sendSuccessStatusReport(startedAt, uploadResult.statusReport, logger);
}
catch (unwrappedError) {
const error = (0, util_1.wrapError)(unwrappedError);
const message = error.message;
core.setFailed(message);
console.log(error);
await (0, status_report_1.sendStatusReport)(await (0, status_report_1.createStatusReportBase)("upload-sarif", (0, status_report_1.getActionsStatus)(error), startedAt, undefined, await (0, util_1.checkDiskUsage)(), message, error.stack));
await (0, status_report_1.sendStatusReport)(await (0, status_report_1.createStatusReportBase)("upload-sarif", (0, status_report_1.getActionsStatus)(error), startedAt, undefined, await (0, util_1.checkDiskUsage)(), logger, message, error.stack));
return;
}
}