Accept repository property as fallback

This commit is contained in:
Michael B. Gale
2026-06-16 12:28:17 +02:00
parent ae7c3ea645
commit 82036913c8
4 changed files with 35 additions and 10 deletions

8
lib/entry-points.js generated
View File

@@ -158532,8 +158532,8 @@ var io7 = __toESM(require_io());
var semver10 = __toESM(require_semver2());
// src/config/file.ts
function getConfigFileInput(actions) {
return actions.getOptionalInput("config-file");
function getConfigFileInput(actions, repositoryProperties) {
return actions.getOptionalInput("config-file") || repositoryProperties["github-codeql-config-file" /* CONFIG_FILE */];
}
// src/workflow.ts
@@ -158911,11 +158911,12 @@ async function run3(startedAt) {
repositoryNwo,
logger
);
const repositoryProperties = repositoryPropertiesResult.orElse({});
const jobRunUuid = v4_default();
logger.info(`Job run UUID is ${jobRunUuid}.`);
core20.exportVariable("JOB_RUN_UUID" /* JOB_RUN_UUID */, jobRunUuid);
core20.exportVariable("CODEQL_ACTION_INIT_HAS_RUN" /* INIT_ACTION_HAS_RUN */, "true");
configFile = getConfigFileInput(actionsEnv);
configFile = getConfigFileInput(actionsEnv, repositoryProperties);
sourceRoot = path23.resolve(
getRequiredEnvParam("GITHUB_WORKSPACE"),
getOptionalInput("source-root") || ""
@@ -158977,7 +158978,6 @@ async function run3(startedAt) {
}
analysisKinds = await getAnalysisKinds(logger, features);
const debugMode = getOptionalInput("debug") === "true" || core20.isDebug();
const repositoryProperties = repositoryPropertiesResult.orElse({});
const fileCoverageResult = await getFileCoverageInformationEnabled(
debugMode,
codeql,

View File

@@ -1,6 +1,7 @@
import test from "ava";
import sinon from "sinon";
import { RepositoryPropertyName } from "../feature-flags/properties";
import { getTestActionsEnv, setupTests } from "../testing-utils";
import { getConfigFileInput } from "./file";
@@ -9,10 +10,14 @@ setupTests(test);
test("getConfigFileInput returns undefined by default", async (t) => {
const actionsEnv = getTestActionsEnv();
const result = getConfigFileInput(actionsEnv);
const result = getConfigFileInput(actionsEnv, {});
t.is(result, undefined);
});
const repositoryProperties = {
[RepositoryPropertyName.CONFIG_FILE]: "/path/from/property",
};
test("getConfigFileInput returns input value", async (t) => {
const actionsEnv = getTestActionsEnv();
const testInput = "/some/path";
@@ -21,6 +26,16 @@ test("getConfigFileInput returns input value", async (t) => {
.withArgs("config-file")
.returns(testInput);
const result = getConfigFileInput(actionsEnv);
// Even though both an input and repository property are configured,
// we prefer the direct input to the Action.
const result = getConfigFileInput(actionsEnv, repositoryProperties);
t.is(result, testInput);
});
test("getConfigFileInput returns repository property value", async (t) => {
const actionsEnv = getTestActionsEnv();
// Since there is no direct input, we should use the repository property.
const result = getConfigFileInput(actionsEnv, repositoryProperties);
t.is(result, repositoryProperties[RepositoryPropertyName.CONFIG_FILE]);
});

View File

@@ -1,8 +1,18 @@
import { ActionsEnv } from "../actions-util";
import {
RepositoryProperties,
RepositoryPropertyName,
} from "../feature-flags/properties";
/**
* Gets the value that is configured for the configuration file, if any.
*/
export function getConfigFileInput(actions: ActionsEnv): string | undefined {
return actions.getOptionalInput("config-file");
export function getConfigFileInput(
actions: ActionsEnv,
repositoryProperties: Partial<RepositoryProperties>,
): string | undefined {
return (
actions.getOptionalInput("config-file") ||
repositoryProperties[RepositoryPropertyName.CONFIG_FILE]
);
}

View File

@@ -254,6 +254,7 @@ async function run(startedAt: Date) {
repositoryNwo,
logger,
);
const repositoryProperties = repositoryPropertiesResult.orElse({});
// Create a unique identifier for this run.
const jobRunUuid = uuidV4();
@@ -262,7 +263,7 @@ async function run(startedAt: Date) {
core.exportVariable(EnvVar.INIT_ACTION_HAS_RUN, "true");
configFile = getConfigFileInput(actionsEnv);
configFile = getConfigFileInput(actionsEnv, repositoryProperties);
// path.resolve() respects the intended semantics of source-root. If
// source-root is relative, it is relative to the GITHUB_WORKSPACE. If
@@ -353,7 +354,6 @@ async function run(startedAt: Date) {
analysisKinds = await getAnalysisKinds(logger, features);
const debugMode = getOptionalInput("debug") === "true" || core.isDebug();
const repositoryProperties = repositoryPropertiesResult.orElse({});
const fileCoverageResult = await getFileCoverageInformationEnabled(
debugMode,
codeql,