diff --git a/lib/entry-points.js b/lib/entry-points.js index 56ff81be2..0c950ec4b 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -174821,17 +174821,6 @@ async function applyIncrementalAnalysisSettings(config, hasDiffRanges, codeql, l }); } } -async function parseConfigInput({ logger: logger2, features }, configInput) { - if (configInput === void 0) { - return void 0; - } - return parseUserConfig( - logger2, - "`config` input", - configInput, - await features.getValue("validate_db_config" /* ValidateDbConfig */) - ); -} async function determineUserConfig(action, tempDir, inputs) { if (inputs.configInput !== void 0) { const computedConfigPath = userConfigFromActionPath(tempDir); @@ -186371,9 +186360,12 @@ async function run3(actionState) { const rawLanguages = getRawLanguagesNoAutodetect( getOptionalInput("languages") ); - const configInput = await parseConfigInput( - actionStateWithFeatures, - getOptionalInput("config") + const rawConfigInput = getOptionalInput("config"); + const configInput = rawConfigInput === void 0 ? void 0 : parseUserConfig( + logger2, + "`config` input", + rawConfigInput, + await features.getValue("validate_db_config" /* ValidateDbConfig */) ); const queriesInput = getOptionalInput("queries"); const otherLanguagePacksReason = getOtherLanguagePacksReason({ diff --git a/src/config-utils.test.ts b/src/config-utils.test.ts index c757f4f95..88d61b5cc 100644 --- a/src/config-utils.test.ts +++ b/src/config-utils.test.ts @@ -2347,40 +2347,6 @@ test("applyIncrementalAnalysisSettings: adds exclusions for diff-informed-only r ]); }); -test("parseConfigInput - returns undefined when the input isn't set", async (t) => { - await callee(configUtils.parseConfigInput) - .withArgs(undefined) - .passes(t.is, undefined); -}); - -test("parseConfigInput - parses the input as YAML", async (t) => { - await callee(configUtils.parseConfigInput) - .withArgs(simpleConfigFileContents) - .passes(t.deepEqual, { - name: "my config", - queries: [{ uses: "./foo_file" }], - }); -}); - -test("parseConfigInput - throws a ConfigurationError naming the input if it isn't valid YAML", async (t) => { - await callee(configUtils.parseConfigInput) - .withArgs("queries: [") - .throws(t, { - instanceOf: ConfigurationError, - message: /^Cannot parse "`config` input"/, - }); -}); - -test("parseConfigInput - throws a ConfigurationError naming the input if validation fails", async (t) => { - await callee(configUtils.parseConfigInput) - .withFeatures([Feature.ValidateDbConfig]) - .withArgs("queries: 1") - .throws(t, { - instanceOf: ConfigurationError, - message: /^The configuration file "`config` input" is invalid/, - }); -}); - test("determineUserConfig - empty config when neither input is specified", async (t) => { await withTmpDir(async (tmpDir) => { const target = callee(configUtils.determineUserConfig) diff --git a/src/config-utils.ts b/src/config-utils.ts index ec5d03eea..46640c344 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -1044,29 +1044,6 @@ export async function applyIncrementalAnalysisSettings( } } -/** - * Parses the `config` input, which contains a configuration in YAML. - * - * @returns The configuration, or `undefined` if the input isn't set. Unless configuration validation - * is enabled, the configuration might not be a mapping. - * @throws A `ConfigurationError` if the input isn't valid YAML or, when configuration validation is - * enabled, isn't a valid configuration. - */ -export async function parseConfigInput( - { logger, features }: ActionState<["Logger", "FeatureFlags"]>, - configInput: string | undefined, -): Promise { - if (configInput === undefined) { - return undefined; - } - return parseUserConfig( - logger, - "`config` input", - configInput, - await features.getValue(Feature.ValidateDbConfig), - ); -} - /** * Determines where to load the `UserConfig` for the CLI from and loads it. * diff --git a/src/init-action.ts b/src/init-action.ts index 2b3c95e0b..31414bd80 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -23,6 +23,7 @@ import { shouldRestoreCache, } from "./caching-utils"; import { CodeQL } from "./codeql"; +import { parseUserConfig } from "./config/db-config"; import { getConfigFileInput } from "./config/file"; import { ComputedInput, getToolsInput } from "./config/inputs"; import * as configUtils from "./config-utils"; @@ -306,10 +307,16 @@ async function run( const rawLanguages = configUtils.getRawLanguagesNoAutodetect( getOptionalInput("languages"), ); - const configInput = await configUtils.parseConfigInput( - actionStateWithFeatures, - getOptionalInput("config"), - ); + const rawConfigInput = getOptionalInput("config"); + const configInput = + rawConfigInput === undefined + ? undefined + : parseUserConfig( + logger, + "`config` input", + rawConfigInput, + await features.getValue(Feature.ValidateDbConfig), + ); const queriesInput = getOptionalInput("queries"); const otherLanguagePacksReason = getOtherLanguagePacksReason({ configFile,