Skip to content

Commit c54d34d

Browse files
committed
Return ComputedInput from getConfigFileInput and include in telemetry
1 parent 4c0a1f0 commit c54d34d

6 files changed

Lines changed: 70 additions & 58 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 47 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/config/file.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "../testing-utils";
1414

1515
import { getConfigFileInput, getRemoteConfig } from "./file";
16+
import { InputSource } from "./inputs";
1617

1718
setupTests(test);
1819

@@ -42,7 +43,7 @@ test("getConfigFileInput returns input value", async (t) => {
4243
})
4344
.withArgs(repositoryProperties)
4445
.logs(t, "Using configuration file input from workflow")
45-
.passes(t.is, testInput);
46+
.passes(t.deepEqual, { value: testInput, source: InputSource.Workflow });
4647
});
4748

4849
test("getConfigFileInput returns repository property value", async (t) => {
@@ -51,7 +52,10 @@ test("getConfigFileInput returns repository property value", async (t) => {
5152
.withFeatures([Feature.ConfigFileRepositoryProperty])
5253
.withArgs(repositoryProperties)
5354
.logs(t, "Using configuration file input from repository property")
54-
.passes(t.is, repositoryProperties[RepositoryPropertyName.CONFIG_FILE]);
55+
.passes(t.deepEqual, {
56+
value: repositoryProperties[RepositoryPropertyName.CONFIG_FILE],
57+
source: InputSource.RepositoryProperty,
58+
});
5559
});
5660

5761
test("getConfigFileInput ignores empty repository property value", async (t) => {

‎src/config/file.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { ConfigurationError } from "../util";
1010

1111
import { parseUserConfig, UserConfig } from "./db-config";
12+
import { InputSource, type ComputedInput } from "./inputs";
1213
import { parseRemoteFileAddress } from "./remote-file";
1314

1415
/**
@@ -34,12 +35,12 @@ export async function getConfigFileInput(
3435
features,
3536
}: ActionState<["Logger", "Actions", "FeatureFlags"]>,
3637
repositoryProperties: Partial<RepositoryProperties>,
37-
): Promise<string | undefined> {
38+
): Promise<ComputedInput | undefined> {
3839
const input = actions.getOptionalInput("config-file");
3940

4041
if (input !== undefined) {
4142
logger.info(`Using configuration file input from workflow: ${input}`);
42-
return input;
43+
return { value: input, source: InputSource.Workflow };
4344
}
4445

4546
const propertyValue =
@@ -55,7 +56,7 @@ export async function getConfigFileInput(
5556
logger.info(
5657
`Using configuration file input from repository property: ${propertyValue}`,
5758
);
58-
return propertyValue;
59+
return { value: propertyValue, source: InputSource.RepositoryProperty };
5960
} else {
6061
logger.info(
6162
"Ignoring configuration file input from repository property, because the corresponding feature flag is disabled.",

‎src/config/inputs.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77

88
/** Enumerates input names. */
99
export enum InputName {
10+
ConfigFile = "config-file",
1011
Tools = "tools",
1112
}
1213

‎src/init-action.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async function sendStartingStatusReport(
129129
async function sendCompletedStatusReport(
130130
startedAt: Date,
131131
config: configUtils.Config | undefined,
132-
configFile: string | undefined,
132+
configFileInput: ComputedInput | undefined,
133133
toolsInput: ComputedInput | undefined,
134134
toolsDownloadStatusReport: ToolsDownloadStatusReport | undefined,
135135
toolsFeatureFlagsValid: boolean | undefined,
@@ -168,6 +168,9 @@ async function sendCompletedStatusReport(
168168
if (toolsInput !== undefined) {
169169
initStatusReport.computed_inputs.tools = toolsInput;
170170
}
171+
if (configFileInput !== undefined) {
172+
initStatusReport.computed_inputs["config-file"] = configFileInput;
173+
}
171174

172175
const initToolsDownloadFields: InitToolsDownloadFields = {};
173176

@@ -185,7 +188,7 @@ async function sendCompletedStatusReport(
185188
await createInitWithConfigStatusReport(
186189
config,
187190
initStatusReport,
188-
configFile,
191+
configFileInput,
189192
Math.round(
190193
await getTotalCacheSize(Object.values(config.trapCaches), logger),
191194
),
@@ -212,7 +215,7 @@ async function run(
212215

213216
let apiDetails: GitHubApiCombinedDetails;
214217
let config: configUtils.Config | undefined;
215-
let configFile: string | undefined;
218+
let configFileInput: ComputedInput | undefined;
216219
let codeql: CodeQL;
217220
let features: FeatureEnablement;
218221
let sourceRoot: string;
@@ -263,7 +266,7 @@ async function run(
263266
core.exportVariable(EnvVar.INIT_ACTION_HAS_RUN, "true");
264267

265268
const actionStateWithFeatures = { ...actionState, features };
266-
configFile = await getConfigFileInput(
269+
configFileInput = await getConfigFileInput(
267270
actionStateWithFeatures,
268271
repositoryProperties,
269272
);
@@ -376,7 +379,7 @@ async function run(
376379
packsInput: getOptionalInput("packs"),
377380
buildModeInput: getOptionalInput("build-mode"),
378381
ramInput: getOptionalInput("ram"),
379-
configFile,
382+
configFile: configFileInput?.value,
380383
dbLocation: getOptionalInput("db-location"),
381384
configInput: getOptionalInput("config"),
382385
dependencyCachingEnabled: getDependencyCachingEnabled(),
@@ -782,7 +785,7 @@ async function run(
782785
await sendCompletedStatusReport(
783786
startedAt,
784787
config,
785-
configFile,
788+
configFileInput,
786789
toolsInput,
787790
toolsDownloadStatusReport,
788791
toolsFeatureFlagsValid,

‎src/status-report.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,15 +554,15 @@ export interface InitToolsDownloadFields {
554554
*
555555
* @param config The CodeQL Action configuration whose values should be added to the base status report.
556556
* @param initStatusReport The base status report.
557-
* @param configFile Optionally, the filename of the configuration file that was read.
557+
* @param configFileInput Optionally, the filename of the configuration file that was read.
558558
* @param totalCacheSize The computed total TRAP cache size.
559559
* @param overlayBaseDatabaseStats Statistics about the overlay database, if any.
560560
* @returns
561561
*/
562562
export async function createInitWithConfigStatusReport(
563563
config: Config,
564564
initStatusReport: InitStatusReport,
565-
configFile: string | undefined,
565+
configFileInput: ComputedInput | undefined,
566566
totalCacheSize: number,
567567
overlayBaseDatabaseStats: OverlayBaseDatabaseDownloadStats | undefined,
568568
dependencyCachingResults: DependencyCacheRestoreStatusReport | undefined,
@@ -601,7 +601,7 @@ export async function createInitWithConfigStatusReport(
601601

602602
return {
603603
...initStatusReport,
604-
config_file: configFile ?? "",
604+
config_file: configFileInput?.value ?? "",
605605
disable_default_queries: disableDefaultQueries,
606606
paths,
607607
paths_ignore: pathsIgnore,

0 commit comments

Comments
 (0)