Skip to content

Commit d149f93

Browse files
committed
Return mergedConfig instead of loading it again
1 parent 3707b44 commit d149f93

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

lib/entry-points.js

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

src/config-utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2474,7 +2474,7 @@ test("determineUserConfig - merges configs if FF is enabled in Default Setup", a
24742474
`Using merged configurations from 'config' input with configuration from '${configFilePath}': ${expectedConfigPath}`,
24752475
),
24762476
);
2477-
t.true(
2477+
t.false(
24782478
logger.hasMessage(`Using configuration file: ${expectedConfigPath}`),
24792479
);
24802480
t.false(logger.hasMessage("No configuration file was provided"));

src/config-utils.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,13 +1199,20 @@ export async function determineUserConfig(
11991199
validateConfig,
12001200
);
12011201

1202-
fs.writeFileSync(
1203-
computedConfigPath,
1204-
yaml.dump(mergeUserConfigs(logger, fromConfigInput, fromConfigFile)),
1202+
// Write the merged configuration to disk so that it can be loaded subsequently by
1203+
// the CLI or other CodeQL Action steps.
1204+
const mergedConfig = mergeUserConfigs(
1205+
logger,
1206+
fromConfigInput,
1207+
fromConfigFile,
12051208
);
1209+
fs.writeFileSync(computedConfigPath, yaml.dump(mergedConfig));
12061210
logger.debug(
12071211
`Using merged configurations from 'config' input with configuration from '${inputs.configFile}': ${computedConfigPath}`,
12081212
);
1213+
1214+
inputs.configFile = computedConfigPath;
1215+
return mergedConfig;
12091216
} else {
12101217
// If we are in this branch and there is a `config-file` input, then it means
12111218
// we didn't meet the conditions for merging the configurations. Warn the user
@@ -1218,10 +1225,9 @@ export async function determineUserConfig(
12181225

12191226
// Write the `config` input straight to disk.
12201227
fs.writeFileSync(computedConfigPath, inputs.configInput);
1221-
logger.debug(`Using config from action input: ${computedConfigPath}`);
1228+
inputs.configFile = computedConfigPath;
1229+
logger.debug(`Using config from action input: ${inputs.configFile}`);
12221230
}
1223-
1224-
inputs.configFile = computedConfigPath;
12251231
}
12261232

12271233
// Load whatever configuration file we have, if any.

0 commit comments

Comments
 (0)