Make FF explicit in ComputedInputOptions

This commit is contained in:
Michael B. Gale
2026-07-24 17:17:43 +01:00
parent c5d7d6b3ac
commit 479e61c602
2 changed files with 25 additions and 19 deletions

14
lib/entry-points.js generated
View File

@@ -148426,9 +148426,8 @@ function parseUserConfig(logger, pathInput, contents, validateConfig) {
// src/config/inputs.ts
async function getComputedInput(action, repositoryProperties, name, options) {
const input = action.actions.getOptionalInput(name);
const allowRepositoryProperty = options.repositoryPropertyName !== void 0;
const propertyValue = options.repositoryPropertyName !== void 0 ? repositoryProperties[options.repositoryPropertyName] : void 0;
if (allowRepositoryProperty && options.allowForcedRepositoryPropertyValue && propertyValue?.startsWith("!")) {
const propertyValue = repositoryProperties[options.repositoryPropertyName];
if (options.repositoryPropertyFeatureEnabled && options.allowForcedRepositoryPropertyValue && propertyValue?.startsWith("!")) {
action.logger.info(
`Using ${name} input from repository property (enforced): ${propertyValue}`
);
@@ -148442,7 +148441,7 @@ async function getComputedInput(action, repositoryProperties, name, options) {
action.logger.info(`Using ${name} input from workflow: ${input}`);
return { value: input, source: "workflow" /* Workflow */ };
}
if (allowRepositoryProperty && propertyValue !== void 0) {
if (options.repositoryPropertyFeatureEnabled && propertyValue !== void 0) {
action.logger.info(
`Using ${name} input from repository property: ${propertyValue}`
);
@@ -148450,6 +148449,10 @@ async function getComputedInput(action, repositoryProperties, name, options) {
value: propertyValue,
source: "repository-property" /* RepositoryProperty */
};
} else if (propertyValue !== void 0) {
action.logger.info(
`Ignoring ${name} input from repository property, because the corresponding feature flag is disabled.`
);
}
return void 0;
}
@@ -148458,8 +148461,9 @@ async function getToolsInput(action, repositoryProperties) {
"tools_repository_property" /* ToolsRepositoryProperty */
);
return getComputedInput(action, repositoryProperties, "tools" /* Tools */, {
repositoryPropertyFeatureEnabled: allowRepositoryProperty,
allowForcedRepositoryPropertyValue: true,
repositoryPropertyName: allowRepositoryProperty ? "github-codeql-tools" /* TOOLS */ : void 0
repositoryPropertyName: "github-codeql-tools" /* TOOLS */
});
}

View File

@@ -34,15 +34,18 @@ export type ComputedInput = {
*/
export interface ComputedInputOptions {
/**
* The name of the repository property to try and get the input value from.
* Repository properties are ignored if this is `undefined`.
* Whether the FF for the repository property (if any) is enabled.
*/
repositoryPropertyName?: StringRepositoryPropertyNames;
repositoryPropertyFeatureEnabled: boolean;
/**
* The name of the repository property to try and get the input value from.
*/
repositoryPropertyName: StringRepositoryPropertyNames;
/**
* Whether the repository property value may start with `!` to take precedence
* over any input value provided in the workflow file.
*/
allowForcedRepositoryPropertyValue?: boolean;
allowForcedRepositoryPropertyValue: boolean;
}
/**
@@ -63,15 +66,11 @@ export async function getComputedInput(
options: ComputedInputOptions,
): Promise<ComputedInput | undefined> {
const input = action.actions.getOptionalInput(name);
const allowRepositoryProperty = options.repositoryPropertyName !== undefined;
const propertyValue =
options.repositoryPropertyName !== undefined
? repositoryProperties[options.repositoryPropertyName]
: undefined;
const propertyValue = repositoryProperties[options.repositoryPropertyName];
// The repository property takes precedence if it starts with an '!'.
if (
allowRepositoryProperty &&
options.repositoryPropertyFeatureEnabled &&
options.allowForcedRepositoryPropertyValue &&
propertyValue?.startsWith("!")
) {
@@ -92,7 +91,7 @@ export async function getComputedInput(
}
// Use the repository property if there's no workflow input.
if (allowRepositoryProperty && propertyValue !== undefined) {
if (options.repositoryPropertyFeatureEnabled && propertyValue !== undefined) {
action.logger.info(
`Using ${name} input from repository property: ${propertyValue}`,
);
@@ -100,6 +99,10 @@ export async function getComputedInput(
value: propertyValue,
source: InputSource.RepositoryProperty,
};
} else if (propertyValue !== undefined) {
action.logger.info(
`Ignoring ${name} input from repository property, because the corresponding feature flag is disabled.`,
);
}
// There's no input.
@@ -122,9 +125,8 @@ export async function getToolsInput(
Feature.ToolsRepositoryProperty,
);
return getComputedInput(action, repositoryProperties, InputName.Tools, {
repositoryPropertyFeatureEnabled: allowRepositoryProperty,
allowForcedRepositoryPropertyValue: true,
repositoryPropertyName: allowRepositoryProperty
? RepositoryPropertyName.TOOLS
: undefined,
repositoryPropertyName: RepositoryPropertyName.TOOLS,
});
}