Add getConfigFileInput function

This commit is contained in:
Michael B. Gale
2026-06-16 12:21:33 +02:00
parent a0276b7dc4
commit ae7c3ea645
4 changed files with 48 additions and 2 deletions

11
lib/entry-points.js generated
View File

@@ -148162,6 +148162,9 @@ var Failure = class {
};
// src/actions-util.ts
function getActionsEnv() {
return { getOptionalInput };
}
var getRequiredInput = function(name) {
const value = core3.getInput(name);
if (!value) {
@@ -158528,6 +158531,11 @@ var github3 = __toESM(require_github());
var io7 = __toESM(require_io());
var semver10 = __toESM(require_semver2());
// src/config/file.ts
function getConfigFileInput(actions) {
return actions.getOptionalInput("config-file");
}
// src/workflow.ts
var fs26 = __toESM(require("fs"));
var path22 = __toESM(require("path"));
@@ -158868,6 +158876,7 @@ async function sendCompletedStatusReport2(startedAt, config, configFile, toolsDo
}
async function run3(startedAt) {
const logger = getActionsLogger();
const actionsEnv = getActionsEnv();
let apiDetails;
let config;
let configFile;
@@ -158906,7 +158915,7 @@ async function run3(startedAt) {
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 = getOptionalInput("config-file");
configFile = getConfigFileInput(actionsEnv);
sourceRoot = path23.resolve(
getRequiredEnvParam("GITHUB_WORKSPACE"),
getOptionalInput("source-root") || ""

26
src/config/file.test.ts Normal file
View File

@@ -0,0 +1,26 @@
import test from "ava";
import sinon from "sinon";
import { getTestActionsEnv, setupTests } from "../testing-utils";
import { getConfigFileInput } from "./file";
setupTests(test);
test("getConfigFileInput returns undefined by default", async (t) => {
const actionsEnv = getTestActionsEnv();
const result = getConfigFileInput(actionsEnv);
t.is(result, undefined);
});
test("getConfigFileInput returns input value", async (t) => {
const actionsEnv = getTestActionsEnv();
const testInput = "/some/path";
sinon
.stub(actionsEnv, "getOptionalInput")
.withArgs("config-file")
.returns(testInput);
const result = getConfigFileInput(actionsEnv);
t.is(result, testInput);
});

8
src/config/file.ts Normal file
View File

@@ -0,0 +1,8 @@
import { ActionsEnv } from "../actions-util";
/**
* Gets the value that is configured for the configuration file, if any.
*/
export function getConfigFileInput(actions: ActionsEnv): string | undefined {
return actions.getOptionalInput("config-file");
}

View File

@@ -9,6 +9,7 @@ import { v4 as uuidV4 } from "uuid";
import {
FileCmdNotFoundError,
getActionsEnv,
getActionVersion,
getFileType,
getOptionalInput,
@@ -24,6 +25,7 @@ import {
shouldRestoreCache,
} from "./caching-utils";
import { CodeQL } from "./codeql";
import { getConfigFileInput } from "./config/file";
import * as configUtils from "./config-utils";
import {
DependencyCacheRestoreStatusReport,
@@ -207,6 +209,7 @@ async function run(startedAt: Date) {
// possible, and only use safe functions outside.
const logger = getActionsLogger();
const actionsEnv = getActionsEnv();
let apiDetails: GitHubApiCombinedDetails;
let config: configUtils.Config | undefined;
@@ -259,7 +262,7 @@ async function run(startedAt: Date) {
core.exportVariable(EnvVar.INIT_ACTION_HAS_RUN, "true");
configFile = getOptionalInput("config-file");
configFile = getConfigFileInput(actionsEnv);
// path.resolve() respects the intended semantics of source-root. If
// source-root is relative, it is relative to the GITHUB_WORKSPACE. If