Send config file path to telemetry status report

This commit is contained in:
Dave Bartolomeo 2024-08-23 16:57:53 -04:00
parent fd5fa130e2
commit e885d9d725
3 changed files with 17 additions and 6 deletions

11
lib/init-action.js generated
View file

@ -44,7 +44,7 @@ const tools_features_1 = require("./tools-features");
const trap_caching_1 = require("./trap-caching");
const util_1 = require("./util");
const workflow_1 = require("./workflow");
async function sendCompletedStatusReport(startedAt, config, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error) {
async function sendCompletedStatusReport(startedAt, config, configFile, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error) {
const statusReportBase = await (0, status_report_1.createStatusReportBase)(status_report_1.ActionName.Init, (0, status_report_1.getActionsStatus)(error), startedAt, config, await (0, util_1.checkDiskUsage)(logger), logger, error?.message, error?.stack);
if (statusReportBase === undefined) {
return;
@ -104,6 +104,7 @@ async function sendCompletedStatusReport(startedAt, config, toolsDownloadStatusR
// Append fields that are dependent on `config`
const initWithConfigStatusReport = {
...initStatusReport,
config_file: configFile ?? "",
disable_default_queries: disableDefaultQueries,
paths,
paths_ignore: pathsIgnore,
@ -149,6 +150,7 @@ async function run() {
logger.info(`Job run UUID is ${jobRunUuid}.`);
core.exportVariable(environment_1.EnvVar.JOB_RUN_UUID, jobRunUuid);
core.exportVariable(environment_1.EnvVar.INIT_ACTION_HAS_RUN, "true");
const configFile = (0, actions_util_1.getOptionalInput)("config-file");
try {
const statusReportBase = await (0, status_report_1.createStatusReportBase)(status_report_1.ActionName.Init, "starting", startedAt, config, await (0, util_1.checkDiskUsage)(logger), logger);
if (statusReportBase !== undefined) {
@ -171,7 +173,7 @@ async function run() {
queriesInput: (0, actions_util_1.getOptionalInput)("queries"),
packsInput: (0, actions_util_1.getOptionalInput)("packs"),
buildModeInput: (0, actions_util_1.getOptionalInput)("build-mode"),
configFile: (0, actions_util_1.getOptionalInput)("config-file"),
configFile,
dbLocation: (0, actions_util_1.getOptionalInput)("db-location"),
configInput: (0, actions_util_1.getOptionalInput)("config"),
trapCachingEnabled: getTrapCachingEnabled(),
@ -368,13 +370,14 @@ async function run() {
catch (unwrappedError) {
const error = (0, util_1.wrapError)(unwrappedError);
core.setFailed(error.message);
await sendCompletedStatusReport(startedAt, config, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error);
await sendCompletedStatusReport(startedAt, config, undefined, // We only report config info on success.
toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error);
return;
}
finally {
(0, diagnostics_1.logUnwrittenDiagnostics)();
}
await sendCompletedStatusReport(startedAt, config, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger);
await sendCompletedStatusReport(startedAt, config, configFile, toolsDownloadStatusReport, 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

View file

@ -99,6 +99,8 @@ interface InitWithConfigStatusReport extends InitStatusReport {
registries: string;
/** Stringified JSON object representing a query-filters, from the 'query-filters' config field. **/
query_filters: string;
/** Path to the specified code scanning config file, from the 'config-file' config field. */
config_file: string;
}
/** Fields of the init status report populated when the tools source is `download`. */
@ -114,6 +116,7 @@ interface InitToolsDownloadFields {
async function sendCompletedStatusReport(
startedAt: Date,
config: configUtils.Config | undefined,
configFile: string | undefined,
toolsDownloadStatusReport: ToolsDownloadStatusReport | undefined,
toolsFeatureFlagsValid: boolean | undefined,
toolsSource: ToolsSource,
@ -210,6 +213,7 @@ async function sendCompletedStatusReport(
// Append fields that are dependent on `config`
const initWithConfigStatusReport: InitWithConfigStatusReport = {
...initStatusReport,
config_file: configFile ?? "",
disable_default_queries: disableDefaultQueries,
paths,
paths_ignore: pathsIgnore,
@ -278,6 +282,8 @@ async function run() {
core.exportVariable(EnvVar.INIT_ACTION_HAS_RUN, "true");
const configFile = getOptionalInput("config-file");
try {
const statusReportBase = await createStatusReportBase(
ActionName.Init,
@ -319,7 +325,7 @@ async function run() {
queriesInput: getOptionalInput("queries"),
packsInput: getOptionalInput("packs"),
buildModeInput: getOptionalInput("build-mode"),
configFile: getOptionalInput("config-file"),
configFile,
dbLocation: getOptionalInput("db-location"),
configInput: getOptionalInput("config"),
trapCachingEnabled: getTrapCachingEnabled(),
@ -628,6 +634,7 @@ async function run() {
await sendCompletedStatusReport(
startedAt,
config,
undefined, // We only report config info on success.
toolsDownloadStatusReport,
toolsFeatureFlagsValid,
toolsSource,
@ -642,6 +649,7 @@ async function run() {
await sendCompletedStatusReport(
startedAt,
config,
configFile,
toolsDownloadStatusReport,
toolsFeatureFlagsValid,
toolsSource,