mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Generalise getToolsInput into getComputedInput
This commit is contained in:
17
lib/entry-points.js
generated
17
lib/entry-points.js
generated
@@ -148424,13 +148424,10 @@ function parseUserConfig(logger, pathInput, contents, validateConfig) {
|
||||
}
|
||||
|
||||
// src/config/inputs.ts
|
||||
async function getToolsInput(action, repositoryProperties) {
|
||||
const name = "tools" /* Tools */;
|
||||
async function getComputedInput(action, repositoryProperties, name, options) {
|
||||
const input = action.actions.getOptionalInput(name);
|
||||
const propertyValue = repositoryProperties["github-codeql-tools" /* TOOLS */];
|
||||
const allowRepositoryProperty = await action.features.getValue(
|
||||
"tools_repository_property" /* ToolsRepositoryProperty */
|
||||
);
|
||||
const allowRepositoryProperty = options.repositoryPropertyName !== void 0;
|
||||
const propertyValue = options.repositoryPropertyName !== void 0 ? repositoryProperties[options.repositoryPropertyName] : void 0;
|
||||
if (allowRepositoryProperty && propertyValue?.startsWith("!")) {
|
||||
action.logger.info(
|
||||
`Using ${name} input from repository property (enforced): ${propertyValue}`
|
||||
@@ -148456,6 +148453,14 @@ async function getToolsInput(action, repositoryProperties) {
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
async function getToolsInput(action, repositoryProperties) {
|
||||
const allowRepositoryProperty = await action.features.getValue(
|
||||
"tools_repository_property" /* ToolsRepositoryProperty */
|
||||
);
|
||||
return getComputedInput(action, repositoryProperties, "tools" /* Tools */, {
|
||||
repositoryPropertyName: allowRepositoryProperty ? "github-codeql-tools" /* TOOLS */ : void 0
|
||||
});
|
||||
}
|
||||
|
||||
// src/config/remote-file.ts
|
||||
var DEFAULT_CONFIG_FILE_NAME = ".github/codeql-action.yaml";
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Feature } from "../feature-flags";
|
||||
import {
|
||||
RepositoryProperties,
|
||||
RepositoryPropertyName,
|
||||
StringRepositoryPropertyNames,
|
||||
} from "../feature-flags/properties";
|
||||
|
||||
/** Enumerates input names. */
|
||||
@@ -29,23 +30,35 @@ export type ComputedInput = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the computed `tools` input. This comes from either the workflow or
|
||||
* Represents options for how to compute an input.
|
||||
*/
|
||||
export interface ComputedInputOptions {
|
||||
repositoryPropertyName?: StringRepositoryPropertyNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the computed input for `name`. This comes from either the workflow or
|
||||
* the repository property.
|
||||
*
|
||||
* @param action The Action state.
|
||||
* @param repositoryProperties The values of known repository properties.
|
||||
* @param name The name of the input to compute.
|
||||
* @param options Options for how to compute the input value.
|
||||
*
|
||||
* @returns The computed input or `undefined` if there is no input.
|
||||
*/
|
||||
export async function getToolsInput(
|
||||
export async function getComputedInput(
|
||||
action: ActionState<["Logger", "Actions", "FeatureFlags"]>,
|
||||
repositoryProperties: Partial<RepositoryProperties>,
|
||||
repositoryProperties: RepositoryProperties,
|
||||
name: InputName,
|
||||
options: ComputedInputOptions,
|
||||
): Promise<ComputedInput | undefined> {
|
||||
const name = InputName.Tools;
|
||||
const input = action.actions.getOptionalInput(name);
|
||||
const propertyValue = repositoryProperties[RepositoryPropertyName.TOOLS];
|
||||
const allowRepositoryProperty = await action.features.getValue(
|
||||
Feature.ToolsRepositoryProperty,
|
||||
);
|
||||
const allowRepositoryProperty = options.repositoryPropertyName !== undefined;
|
||||
const propertyValue =
|
||||
options.repositoryPropertyName !== undefined
|
||||
? repositoryProperties[options.repositoryPropertyName]
|
||||
: undefined;
|
||||
|
||||
// The repository property takes precedence if it starts with an '!'.
|
||||
if (allowRepositoryProperty && propertyValue?.startsWith("!")) {
|
||||
@@ -79,3 +92,25 @@ export async function getToolsInput(
|
||||
// There's no input.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the computed `tools` input. This comes from either the workflow or
|
||||
* the repository property.
|
||||
*
|
||||
* @param action The Action state.
|
||||
* @param repositoryProperties The values of known repository properties.
|
||||
* @returns The computed input or `undefined` if there is no input.
|
||||
*/
|
||||
export async function getToolsInput(
|
||||
action: ActionState<["Logger", "Actions", "FeatureFlags"]>,
|
||||
repositoryProperties: Partial<RepositoryProperties>,
|
||||
): Promise<ComputedInput | undefined> {
|
||||
const allowRepositoryProperty = await action.features.getValue(
|
||||
Feature.ToolsRepositoryProperty,
|
||||
);
|
||||
return getComputedInput(action, repositoryProperties, InputName.Tools, {
|
||||
repositoryPropertyName: allowRepositoryProperty
|
||||
? RepositoryPropertyName.TOOLS
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,6 +29,13 @@ export type AllRepositoryProperties = {
|
||||
[RepositoryPropertyName.TOOLS]: string;
|
||||
};
|
||||
|
||||
/** The subset of known repository properties which are of type `string`. */
|
||||
export type StringRepositoryPropertyNames = keyof {
|
||||
[K in keyof AllRepositoryProperties as AllRepositoryProperties[K] extends string
|
||||
? K
|
||||
: never]: AllRepositoryProperties[K];
|
||||
};
|
||||
|
||||
/** Parsed repository properties. */
|
||||
export type RepositoryProperties = Partial<AllRepositoryProperties>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user