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 trap_caching_1 = require("./trap-caching");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
const workflow_1 = require("./workflow");
|
const workflow_1 = require("./workflow");
|
||||||
async function sendInitStatusReport(actionStatus, startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger) {
|
async function sendCompletedStatusReport(startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error) {
|
||||||
const statusReportBase = await (0, actions_util_1.createStatusReportBase)("init", actionStatus, startedAt);
|
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 workflowLanguages = (0, actions_util_1.getOptionalInput)("languages");
|
||||||
const initStatusReport = {
|
const initStatusReport = {
|
||||||
...statusReportBase,
|
...statusReportBase,
|
||||||
|
|
@ -187,12 +187,12 @@ async function run() {
|
||||||
core.setOutput("codeql-path", config.codeQLCmd);
|
core.setOutput("codeql-path", config.codeQLCmd);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(String(error));
|
core.setFailed(error instanceof Error ? error.message : String(error));
|
||||||
console.log(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;
|
return;
|
||||||
}
|
}
|
||||||
await sendInitStatusReport("success", startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger);
|
await sendCompletedStatusReport(startedAt, config, toolsDownloadDurationMs, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger);
|
||||||
}
|
}
|
||||||
function getTrapCachingEnabled() {
|
function getTrapCachingEnabled() {
|
||||||
// If the workflow specified something always respect that
|
// 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 * as core from "@actions/core";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ActionStatus,
|
|
||||||
createStatusReportBase,
|
createStatusReportBase,
|
||||||
getActionsStatus,
|
getActionsStatus,
|
||||||
getActionVersion,
|
getActionVersion,
|
||||||
|
|
@ -95,20 +94,22 @@ interface InitToolsDownloadFields {
|
||||||
tools_feature_flags_valid?: boolean;
|
tools_feature_flags_valid?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendInitStatusReport(
|
async function sendCompletedStatusReport(
|
||||||
actionStatus: ActionStatus,
|
|
||||||
startedAt: Date,
|
startedAt: Date,
|
||||||
config: configUtils.Config | undefined,
|
config: configUtils.Config | undefined,
|
||||||
toolsDownloadDurationMs: number | undefined,
|
toolsDownloadDurationMs: number | undefined,
|
||||||
toolsFeatureFlagsValid: boolean | undefined,
|
toolsFeatureFlagsValid: boolean | undefined,
|
||||||
toolsSource: ToolsSource,
|
toolsSource: ToolsSource,
|
||||||
toolsVersion: string,
|
toolsVersion: string,
|
||||||
logger: Logger
|
logger: Logger,
|
||||||
|
error?: Error
|
||||||
) {
|
) {
|
||||||
const statusReportBase = await createStatusReportBase(
|
const statusReportBase = await createStatusReportBase(
|
||||||
"init",
|
"init",
|
||||||
actionStatus,
|
getActionsStatus(error),
|
||||||
startedAt
|
startedAt,
|
||||||
|
error?.message,
|
||||||
|
error?.stack
|
||||||
);
|
);
|
||||||
|
|
||||||
const workflowLanguages = getOptionalInput("languages");
|
const workflowLanguages = getOptionalInput("languages");
|
||||||
|
|
@ -366,23 +367,21 @@ async function run() {
|
||||||
|
|
||||||
core.setOutput("codeql-path", config.codeQLCmd);
|
core.setOutput("codeql-path", config.codeQLCmd);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(String(error));
|
core.setFailed(error instanceof Error ? error.message : String(error));
|
||||||
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
await sendInitStatusReport(
|
await sendCompletedStatusReport(
|
||||||
getActionsStatus(error),
|
|
||||||
startedAt,
|
startedAt,
|
||||||
config,
|
config,
|
||||||
toolsDownloadDurationMs,
|
toolsDownloadDurationMs,
|
||||||
toolsFeatureFlagsValid,
|
toolsFeatureFlagsValid,
|
||||||
toolsSource,
|
toolsSource,
|
||||||
toolsVersion,
|
toolsVersion,
|
||||||
logger
|
logger,
|
||||||
|
error instanceof Error ? error : new Error(String(error))
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await sendInitStatusReport(
|
await sendCompletedStatusReport(
|
||||||
"success",
|
|
||||||
startedAt,
|
startedAt,
|
||||||
config,
|
config,
|
||||||
toolsDownloadDurationMs,
|
toolsDownloadDurationMs,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue