Report exceptions to telemetry in init Action
This commit is contained in:
parent
f32426ba96
commit
555b602b2f
3 changed files with 18 additions and 19 deletions
10
lib/init-action.js
generated
10
lib/init-action.js
generated
|
|
@ -36,8 +36,8 @@ const repository_1 = require("./repository");
|
|||
const trap_caching_1 = require("./trap-caching");
|
||||
const util_1 = require("./util");
|
||||
const workflow_1 = require("./workflow");
|
||||
async function sendInitStatusReport(actionStatus, startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger) {
|
||||
const statusReportBase = await (0, actions_util_1.createStatusReportBase)("init", actionStatus, startedAt);
|
||||
async function sendCompletedStatusReport(startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error) {
|
||||
const statusReportBase = await (0, actions_util_1.createStatusReportBase)("init", (0, actions_util_1.getActionsStatus)(error), startedAt, error?.message, error?.stack);
|
||||
const workflowLanguages = (0, actions_util_1.getOptionalInput)("languages");
|
||||
const initStatusReport = {
|
||||
...statusReportBase,
|
||||
|
|
@ -187,12 +187,12 @@ async function run() {
|
|||
core.setOutput("codeql-path", config.codeQLCmd);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(String(error));
|
||||
core.setFailed(error instanceof Error ? error.message : String(error));
|
||||
console.log(error);
|
||||
await sendInitStatusReport((0, actions_util_1.getActionsStatus)(error), startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger);
|
||||
await sendCompletedStatusReport(startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error instanceof Error ? error : new Error(String(error)));
|
||||
return;
|
||||
}
|
||||
await sendInitStatusReport("success", startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger);
|
||||
await sendCompletedStatusReport(startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger);
|
||||
}
|
||||
function getTrapCachingEnabled() {
|
||||
// If the workflow specified something always respect that
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -3,7 +3,6 @@ import * as path from "path";
|
|||
import * as core from "@actions/core";
|
||||
|
||||
import {
|
||||
ActionStatus,
|
||||
createStatusReportBase,
|
||||
getActionsStatus,
|
||||
getActionVersion,
|
||||
|
|
@ -95,20 +94,22 @@ interface InitToolsDownloadFields {
|
|||
tools_feature_flags_valid?: boolean;
|
||||
}
|
||||
|
||||
async function sendInitStatusReport(
|
||||
actionStatus: ActionStatus,
|
||||
async function sendCompletedStatusReport(
|
||||
startedAt: Date,
|
||||
config: configUtils.Config | undefined,
|
||||
toolsDownloadDurationMs: number | undefined,
|
||||
toolsFeatureFlagsValid: boolean | undefined,
|
||||
toolsSource: ToolsSource,
|
||||
toolsVersion: string,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
error?: Error
|
||||
) {
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"init",
|
||||
actionStatus,
|
||||
startedAt
|
||||
getActionsStatus(error),
|
||||
startedAt,
|
||||
error?.message,
|
||||
error?.stack
|
||||
);
|
||||
|
||||
const workflowLanguages = getOptionalInput("languages");
|
||||
|
|
@ -366,23 +367,21 @@ async function run() {
|
|||
|
||||
core.setOutput("codeql-path", config.codeQLCmd);
|
||||
} catch (error) {
|
||||
core.setFailed(String(error));
|
||||
|
||||
core.setFailed(error instanceof Error ? error.message : String(error));
|
||||
console.log(error);
|
||||
await sendInitStatusReport(
|
||||
getActionsStatus(error),
|
||||
await sendCompletedStatusReport(
|
||||
startedAt,
|
||||
config,
|
||||
toolsDownloadDurationMs,
|
||||
toolsFeatureFlagsValid,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
logger
|
||||
logger,
|
||||
error instanceof Error ? error : new Error(String(error))
|
||||
);
|
||||
return;
|
||||
}
|
||||
await sendInitStatusReport(
|
||||
"success",
|
||||
await sendCompletedStatusReport(
|
||||
startedAt,
|
||||
config,
|
||||
toolsDownloadDurationMs,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue