mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Use getComputedInput for getConfigFileInput
This commit is contained in:
36
lib/entry-points.js
generated
36
lib/entry-points.js
generated
@@ -148550,33 +148550,15 @@ async function parseRemoteFileAddress(actionState, configFile) {
|
||||
// src/config/file.ts
|
||||
var LOCAL_PATH_PREFIX = "./";
|
||||
var REMOTE_PATH_PREFIX = "remote=";
|
||||
async function getConfigFileInput({
|
||||
logger,
|
||||
actions,
|
||||
features
|
||||
}, repositoryProperties) {
|
||||
const input = actions.getOptionalInput("config-file");
|
||||
if (input !== void 0) {
|
||||
logger.info(`Using configuration file input from workflow: ${input}`);
|
||||
return { value: input, source: "workflow" /* Workflow */ };
|
||||
}
|
||||
const propertyValue = repositoryProperties["github-codeql-config-file" /* CONFIG_FILE */];
|
||||
if (propertyValue !== void 0 && propertyValue.trim().length > 0) {
|
||||
const useRepositoryProperty = await features.getValue(
|
||||
"config_file_repository_property" /* ConfigFileRepositoryProperty */
|
||||
);
|
||||
if (useRepositoryProperty) {
|
||||
logger.info(
|
||||
`Using configuration file input from repository property: ${propertyValue}`
|
||||
);
|
||||
return { value: propertyValue, source: "repository-property" /* RepositoryProperty */ };
|
||||
} else {
|
||||
logger.info(
|
||||
"Ignoring configuration file input from repository property, because the corresponding feature flag is disabled."
|
||||
);
|
||||
}
|
||||
}
|
||||
return void 0;
|
||||
async function getConfigFileInput(action, repositoryProperties) {
|
||||
const useRepositoryProperty = await action.features.getValue(
|
||||
"config_file_repository_property" /* ConfigFileRepositoryProperty */
|
||||
);
|
||||
return getComputedInput(action, repositoryProperties, "config-file" /* ConfigFile */, {
|
||||
repositoryPropertyFeatureEnabled: useRepositoryProperty,
|
||||
allowForcedRepositoryPropertyValue: false,
|
||||
repositoryPropertyName: "github-codeql-config-file" /* CONFIG_FILE */
|
||||
});
|
||||
}
|
||||
async function getRemoteConfig(actionState, configFile, apiDetails) {
|
||||
const address = await parseRemoteFileAddress(actionState, configFile);
|
||||
|
||||
@@ -42,7 +42,7 @@ test("getConfigFileInput returns input value", async (t) => {
|
||||
.returns(testInput);
|
||||
})
|
||||
.withArgs(repositoryProperties)
|
||||
.logs(t, "Using configuration file input from workflow")
|
||||
.logs(t, "Using config-file input from workflow")
|
||||
.passes(t.deepEqual, { value: testInput, source: InputSource.Workflow });
|
||||
});
|
||||
|
||||
@@ -51,30 +51,22 @@ test("getConfigFileInput returns repository property value", async (t) => {
|
||||
await callee(getConfigFileInput)
|
||||
.withFeatures([Feature.ConfigFileRepositoryProperty])
|
||||
.withArgs(repositoryProperties)
|
||||
.logs(t, "Using configuration file input from repository property")
|
||||
.logs(t, "Using config-file input from repository property")
|
||||
.passes(t.deepEqual, {
|
||||
value: repositoryProperties[RepositoryPropertyName.CONFIG_FILE],
|
||||
source: InputSource.RepositoryProperty,
|
||||
});
|
||||
});
|
||||
|
||||
test("getConfigFileInput ignores empty repository property value", async (t) => {
|
||||
// Since the repository property value is an empty/whitespace string, we should ignore it.
|
||||
await callee(getConfigFileInput)
|
||||
.withFeatures([Feature.ConfigFileRepositoryProperty])
|
||||
.withArgs({ [RepositoryPropertyName.CONFIG_FILE]: " " })
|
||||
.passes(t.is, undefined);
|
||||
});
|
||||
|
||||
test("getConfigFileInput ignores repository property value when FF is off", async (t) => {
|
||||
// Since the FF is off, we should ignore the repository property value.
|
||||
await callee(getConfigFileInput)
|
||||
.withFeatures([])
|
||||
.withArgs(repositoryProperties)
|
||||
.notLogs(t, "Using configuration file input from repository property")
|
||||
.notLogs(t, "Using config-file input from repository property")
|
||||
.logs(
|
||||
t,
|
||||
"Ignoring configuration file input from repository property, because the corresponding feature flag is disabled.",
|
||||
"Ignoring config-file input from repository property, because the corresponding feature flag is disabled.",
|
||||
)
|
||||
.passes(t.is, undefined);
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import { ConfigurationError } from "../util";
|
||||
|
||||
import { parseUserConfig, UserConfig } from "./db-config";
|
||||
import { InputSource, type ComputedInput } from "./inputs";
|
||||
import { getComputedInput, InputName, type ComputedInput } from "./inputs";
|
||||
import { parseRemoteFileAddress } from "./remote-file";
|
||||
|
||||
/**
|
||||
@@ -29,42 +29,19 @@ export const REMOTE_PATH_PREFIX = "remote=";
|
||||
* Gets the value that is configured for the configuration file, if any.
|
||||
*/
|
||||
export async function getConfigFileInput(
|
||||
{
|
||||
logger,
|
||||
actions,
|
||||
features,
|
||||
}: ActionState<["Logger", "Actions", "FeatureFlags"]>,
|
||||
action: ActionState<["Logger", "Actions", "FeatureFlags"]>,
|
||||
repositoryProperties: Partial<RepositoryProperties>,
|
||||
): Promise<ComputedInput | undefined> {
|
||||
const input = actions.getOptionalInput("config-file");
|
||||
// Only use the repository property value if the FF is enabled.
|
||||
const useRepositoryProperty = await action.features.getValue(
|
||||
Feature.ConfigFileRepositoryProperty,
|
||||
);
|
||||
|
||||
if (input !== undefined) {
|
||||
logger.info(`Using configuration file input from workflow: ${input}`);
|
||||
return { value: input, source: InputSource.Workflow };
|
||||
}
|
||||
|
||||
const propertyValue =
|
||||
repositoryProperties[RepositoryPropertyName.CONFIG_FILE];
|
||||
|
||||
if (propertyValue !== undefined && propertyValue.trim().length > 0) {
|
||||
// Only use the repository property value if the FF is enabled.
|
||||
const useRepositoryProperty = await features.getValue(
|
||||
Feature.ConfigFileRepositoryProperty,
|
||||
);
|
||||
|
||||
if (useRepositoryProperty) {
|
||||
logger.info(
|
||||
`Using configuration file input from repository property: ${propertyValue}`,
|
||||
);
|
||||
return { value: propertyValue, source: InputSource.RepositoryProperty };
|
||||
} else {
|
||||
logger.info(
|
||||
"Ignoring configuration file input from repository property, because the corresponding feature flag is disabled.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return getComputedInput(action, repositoryProperties, InputName.ConfigFile, {
|
||||
repositoryPropertyFeatureEnabled: useRepositoryProperty,
|
||||
allowForcedRepositoryPropertyValue: false,
|
||||
repositoryPropertyName: RepositoryPropertyName.CONFIG_FILE,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user