From 79fe3a1270f5a101a20367147a05eb6d8ed533af Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Thu, 17 Sep 2026 19:04:38 +0100 Subject: [PATCH] Move download telemetry into the status-report directory Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- lib/entry-points.js | 46 ++++++++------- src/init-action.ts | 2 +- src/setup-codeql-action.ts | 2 +- src/status-report.ts | 59 ------------------- .../tools-download.test.ts} | 5 +- src/status-report/tools-download.ts | 59 +++++++++++++++++++ 6 files changed, 88 insertions(+), 85 deletions(-) rename src/{tools-download-status-report.test.ts => status-report/tools-download.test.ts} (94%) create mode 100644 src/status-report/tools-download.ts diff --git a/lib/entry-points.js b/lib/entry-points.js index ada8ee4ee..53532f2f7 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -147625,28 +147625,6 @@ async function sendStatusReport(statusReport) { ); } } -function createInitToolsDownloadFields(report, toolsFeatureFlagsValid) { - const fields = {}; - if (report?.downloadDurationMs !== void 0) { - fields.tools_download_duration_ms = report.downloadDurationMs; - } - if (report?.extractionDurationMs !== void 0) { - fields.tools_extraction_duration_ms = report.extractionDurationMs; - } - if (report?.totalDurationMs !== void 0) { - fields.tools_total_duration_ms = report.totalDurationMs; - } - if (report?.bundleLanguage !== void 0) { - fields.tools_bundle_language = report.bundleLanguage; - } - if (report?.perLanguageBundleFallback !== void 0) { - fields.tools_per_language_bundle_fallback = report.perLanguageBundleFallback; - } - if (toolsFeatureFlagsValid !== void 0) { - fields.tools_feature_flags_valid = toolsFeatureFlagsValid; - } - return fields; -} async function createInitWithConfigStatusReport(config, initStatusReport, configFile, totalCacheSize, overlayBaseDatabaseStats, dependencyCachingResults) { const languages = config.languages.join(","); const paths = (config.originalUserInput.paths || []).join(","); @@ -161882,6 +161860,30 @@ async function getToolsInput(action, repositoryProperties) { return void 0; } +// src/status-report/tools-download.ts +function createInitToolsDownloadFields(report, toolsFeatureFlagsValid) { + const fields = {}; + if (report?.downloadDurationMs !== void 0) { + fields.tools_download_duration_ms = report.downloadDurationMs; + } + if (report?.extractionDurationMs !== void 0) { + fields.tools_extraction_duration_ms = report.extractionDurationMs; + } + if (report?.totalDurationMs !== void 0) { + fields.tools_total_duration_ms = report.totalDurationMs; + } + if (report?.bundleLanguage !== void 0) { + fields.tools_bundle_language = report.bundleLanguage; + } + if (report?.perLanguageBundleFallback !== void 0) { + fields.tools_per_language_bundle_fallback = report.perLanguageBundleFallback; + } + if (toolsFeatureFlagsValid !== void 0) { + fields.tools_feature_flags_valid = toolsFeatureFlagsValid; + } + return fields; +} + // src/workflow.ts var fs28 = __toESM(require("fs")); var path24 = __toESM(require("path")); diff --git a/src/init-action.ts b/src/init-action.ts index 6cf50b8c2..79c509a5b 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -65,11 +65,11 @@ import { InitStatusReport, InitWithConfigStatusReport, createInitWithConfigStatusReport, - createInitToolsDownloadFields, createStatusReportBase, getActionsStatus, sendStatusReport, } from "./status-report"; +import { createInitToolsDownloadFields } from "./status-report/tools-download"; import { ToolsDownloadStatusReport } from "./tools-download"; import { ToolsFeature } from "./tools-features"; import { getCombinedTracerConfig } from "./tracer-config"; diff --git a/src/setup-codeql-action.ts b/src/setup-codeql-action.ts index e78ee7ec9..4bd53e517 100644 --- a/src/setup-codeql-action.ts +++ b/src/setup-codeql-action.ts @@ -22,11 +22,11 @@ import { ToolsSource } from "./setup-codeql"; import { ActionName, InitStatusReport, - createInitToolsDownloadFields, createStatusReportBase, getActionsStatus, sendStatusReport, } from "./status-report"; +import { createInitToolsDownloadFields } from "./status-report/tools-download"; import { ToolsDownloadStatusReport } from "./tools-download"; import { checkDiskUsage, diff --git a/src/status-report.ts b/src/status-report.ts index f6e6e16ca..c392b5192 100644 --- a/src/status-report.ts +++ b/src/status-report.ts @@ -31,7 +31,6 @@ import type { OverlayBaseDatabaseDownloadStats } from "./overlay/caching"; import { getRepositoryNwo } from "./repository"; import type { ToolsSource } from "./setup-codeql"; import { registryBaseSchema } from "./start-proxy/types"; -import type { ToolsDownloadStatusReport } from "./tools-download"; import { ConfigurationError, getRequiredEnvParam, @@ -625,64 +624,6 @@ export interface InitWithConfigStatusReport extends InitStatusReport { config_file: string; } -/** Fields of the init status report populated when the tools source is `download`. */ -export interface InitToolsDownloadFields { - /** - * Time taken to download the bundle, in milliseconds. Not populated when the bundle is downloaded - * and extracted concurrently. - */ - tools_download_duration_ms?: ToolsDownloadStatusReport["downloadDurationMs"]; - /** - * Time taken to extract the bundle, in milliseconds. Not populated when the bundle is downloaded - * and extracted concurrently. - */ - tools_extraction_duration_ms?: ToolsDownloadStatusReport["extractionDurationMs"]; - /** - * Total time taken to make the bundle available on disk, including failed download attempts - * before a fallback, in milliseconds. - */ - tools_total_duration_ms?: ToolsDownloadStatusReport["totalDurationMs"]; - /** - * Whether the relevant tools dotcom feature flags have been misconfigured. - * Only populated if we attempt to determine the default version based on the dotcom feature flags. */ - tools_feature_flags_valid?: boolean; - /** The language of the single-language bundle that was downloaded, if any. */ - tools_bundle_language?: ToolsDownloadStatusReport["bundleLanguage"]; - /** - * Whether we tried to download a single-language bundle, but it did not exist and we fell back to - * the combined bundle. - */ - tools_per_language_bundle_fallback?: ToolsDownloadStatusReport["perLanguageBundleFallback"]; -} - -/** Converts download results to telemetry fields shared by the init and setup-codeql Actions. */ -export function createInitToolsDownloadFields( - report: ToolsDownloadStatusReport | undefined, - toolsFeatureFlagsValid: boolean | undefined, -): InitToolsDownloadFields { - const fields: InitToolsDownloadFields = {}; - if (report?.downloadDurationMs !== undefined) { - fields.tools_download_duration_ms = report.downloadDurationMs; - } - if (report?.extractionDurationMs !== undefined) { - fields.tools_extraction_duration_ms = report.extractionDurationMs; - } - if (report?.totalDurationMs !== undefined) { - fields.tools_total_duration_ms = report.totalDurationMs; - } - if (report?.bundleLanguage !== undefined) { - fields.tools_bundle_language = report.bundleLanguage; - } - if (report?.perLanguageBundleFallback !== undefined) { - fields.tools_per_language_bundle_fallback = - report.perLanguageBundleFallback; - } - if (toolsFeatureFlagsValid !== undefined) { - fields.tools_feature_flags_valid = toolsFeatureFlagsValid; - } - return fields; -} - /** * Composes a `InitWithConfigStatusReport` from the given values. * diff --git a/src/tools-download-status-report.test.ts b/src/status-report/tools-download.test.ts similarity index 94% rename from src/tools-download-status-report.test.ts rename to src/status-report/tools-download.test.ts index 36cd318b0..9b3924217 100644 --- a/src/tools-download-status-report.test.ts +++ b/src/status-report/tools-download.test.ts @@ -1,7 +1,8 @@ import test from "ava"; -import { BuiltInLanguage } from "./languages"; -import { createInitToolsDownloadFields } from "./status-report"; +import { BuiltInLanguage } from "../languages"; + +import { createInitToolsDownloadFields } from "./tools-download"; test("createInitToolsDownloadFields omits absent download data", (t) => { t.deepEqual(createInitToolsDownloadFields(undefined, undefined), {}); diff --git a/src/status-report/tools-download.ts b/src/status-report/tools-download.ts new file mode 100644 index 000000000..d9698ffea --- /dev/null +++ b/src/status-report/tools-download.ts @@ -0,0 +1,59 @@ +import type { ToolsDownloadStatusReport } from "../tools-download"; + +/** Fields of the init status report populated when the tools source is `download`. */ +export interface InitToolsDownloadFields { + /** + * Time taken to download the bundle, in milliseconds. Not populated when the bundle is downloaded + * and extracted concurrently. + */ + tools_download_duration_ms?: ToolsDownloadStatusReport["downloadDurationMs"]; + /** + * Time taken to extract the bundle, in milliseconds. Not populated when the bundle is downloaded + * and extracted concurrently. + */ + tools_extraction_duration_ms?: ToolsDownloadStatusReport["extractionDurationMs"]; + /** + * Total time taken to make the bundle available on disk, including failed download attempts + * before a fallback, in milliseconds. + */ + tools_total_duration_ms?: ToolsDownloadStatusReport["totalDurationMs"]; + /** + * Whether the relevant tools dotcom feature flags have been misconfigured. + * Only populated if we attempt to determine the default version based on the dotcom feature flags. */ + tools_feature_flags_valid?: boolean; + /** The language of the single-language bundle that was downloaded, if any. */ + tools_bundle_language?: ToolsDownloadStatusReport["bundleLanguage"]; + /** + * Whether we tried to download a single-language bundle, but it did not exist and we fell back to + * the combined bundle. + */ + tools_per_language_bundle_fallback?: ToolsDownloadStatusReport["perLanguageBundleFallback"]; +} + +/** Converts download results to telemetry fields shared by the init and setup-codeql Actions. */ +export function createInitToolsDownloadFields( + report: ToolsDownloadStatusReport | undefined, + toolsFeatureFlagsValid: boolean | undefined, +): InitToolsDownloadFields { + const fields: InitToolsDownloadFields = {}; + if (report?.downloadDurationMs !== undefined) { + fields.tools_download_duration_ms = report.downloadDurationMs; + } + if (report?.extractionDurationMs !== undefined) { + fields.tools_extraction_duration_ms = report.extractionDurationMs; + } + if (report?.totalDurationMs !== undefined) { + fields.tools_total_duration_ms = report.totalDurationMs; + } + if (report?.bundleLanguage !== undefined) { + fields.tools_bundle_language = report.bundleLanguage; + } + if (report?.perLanguageBundleFallback !== undefined) { + fields.tools_per_language_bundle_fallback = + report.perLanguageBundleFallback; + } + if (toolsFeatureFlagsValid !== undefined) { + fields.tools_feature_flags_valid = toolsFeatureFlagsValid; + } + return fields; +}