Merge pull request #4086 from github/mbg/thread-action-state-to-codeql

Make a `Logger` available to `getCodeQLForCmd`
This commit is contained in:
Michael B. Gale
2026-08-13 10:03:46 +00:00
committed by GitHub
13 changed files with 38 additions and 44 deletions

41
lib/entry-points.js generated
View File

@@ -151912,7 +151912,7 @@ async function setupCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliV
`Unsupported platform: ${process.platform}`
);
}
cachedCodeQL = await getCodeQLForCmd(codeqlCmd, checkVersion);
cachedCodeQL = await getCodeQLForCmd(logger, codeqlCmd, checkVersion);
return {
codeql: cachedCodeQL,
toolsDownloadStatusReport,
@@ -151929,13 +151929,13 @@ Details: ${e.stack}` : ""}`
);
}
}
async function getCodeQL(cmd) {
async function getCodeQL(logger, cmd) {
if (cachedCodeQL === void 0) {
cachedCodeQL = await getCodeQLForCmd(cmd, true);
cachedCodeQL = await getCodeQLForCmd(logger, cmd, true);
}
return cachedCodeQL;
}
async function getCodeQLForCmd(cmd, checkVersion) {
async function getCodeQLForCmd(logger, cmd, checkVersion) {
const codeql = {
getPath() {
return cmd;
@@ -151972,7 +151972,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
async isScannedLanguage(language) {
return !await this.isTracedLanguage(language);
},
async databaseInitCluster(config, sourceRoot, processName, qlconfigFile, logger) {
async databaseInitCluster(config, sourceRoot, processName, qlconfigFile) {
const extraArgs = config.languages.map(
(language) => `--language=${language}`
);
@@ -152528,7 +152528,7 @@ async function setupCppAutobuild(codeql, logger) {
}
async function runAutobuild(config, language, logger) {
logger.startGroup(`Attempting to automatically build ${language} code`);
const codeQL = await getCodeQL(config.codeQLCmd);
const codeQL = await getCodeQL(logger, config.codeQLCmd);
if (language === "cpp" /* cpp */) {
await setupCppAutobuild(codeQL, logger);
}
@@ -154555,7 +154555,7 @@ async function initConfig2(actionState, inputs) {
return await initConfig(actionState, inputs);
});
}
async function runDatabaseInitCluster(databaseInitEnvironment, codeql, config, sourceRoot, processName, qlconfigFile, logger) {
async function runDatabaseInitCluster(databaseInitEnvironment, codeql, config, sourceRoot, processName, qlconfigFile) {
fs19.mkdirSync(config.dbLocation, { recursive: true });
await wrapEnvironment(
databaseInitEnvironment,
@@ -154563,8 +154563,7 @@ async function runDatabaseInitCluster(databaseInitEnvironment, codeql, config, s
config,
sourceRoot,
processName,
qlconfigFile,
logger
qlconfigFile
)
);
}
@@ -154868,7 +154867,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
let tempDir = getTemporaryDirectory();
const config = await getConfig(tempDir, logger);
if (config !== void 0) {
codeQL = await getCodeQL(config.codeQLCmd);
codeQL = await getCodeQL(logger, config.codeQLCmd);
tempDir = config.tempDir;
} else {
logger.info(
@@ -155605,7 +155604,7 @@ async function run({ startedAt, logger }) {
"Config file could not be found at expected location. Has the 'init' action been called?"
);
}
const codeql = await getCodeQL(config.codeQLCmd);
const codeql = await getCodeQL(logger, config.codeQLCmd);
if (hasBadExpectErrorInput()) {
throw new ConfigurationError(
"`expect-error` input parameter is for internal use only. It should only be set by codeql-action or a fork."
@@ -160728,7 +160727,7 @@ async function runWrapper2() {
logger
);
if (config !== void 0) {
const codeql = await getCodeQL(config.codeQLCmd);
const codeql = await getCodeQL(logger, config.codeQLCmd);
const version = await codeql.getVersion();
await uploadCombinedSarifArtifacts(
logger,
@@ -160808,7 +160807,7 @@ async function run2({ startedAt, logger }) {
"Config file could not be found at expected location. Has the 'init' action been called?"
);
}
const codeql = await getCodeQL(config.codeQLCmd);
const codeql = await getCodeQL(logger, config.codeQLCmd);
languages = await determineAutobuildLanguages(codeql, config, logger);
if (languages !== void 0) {
const workingDirectory = getOptionalInput("working-directory");
@@ -161578,8 +161577,7 @@ exec ${goBinaryPath} "$@"`
config,
sourceRoot,
"Runner.Worker.exe",
qlconfigFile,
logger
qlconfigFile
);
if (config.overlayDatabaseMode !== "none" /* None */ && !await checkPacksForOverlayCompatibility(codeql, config, logger)) {
logger.info(
@@ -161595,8 +161593,7 @@ exec ${goBinaryPath} "$@"`
config,
sourceRoot,
"Runner.Worker.exe",
qlconfigFile,
logger
qlconfigFile
);
}
const tracerConfig = await getCombinedTracerConfig(codeql, config);
@@ -161698,6 +161695,7 @@ async function prepareFailedSarif(logger, features, config) {
const category = `/language:${language}`;
const checkoutPath = ".";
const result = await generateFailedSarif(
logger,
features,
config,
category,
@@ -161718,6 +161716,7 @@ async function prepareFailedSarif(logger, features, config) {
const category = getCategoryInputOrThrow(workflow, jobName, matrix);
const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix);
const result = await generateFailedSarif(
logger,
features,
config,
category,
@@ -161726,9 +161725,9 @@ async function prepareFailedSarif(logger, features, config) {
return new Success(result);
}
}
async function generateFailedSarif(features, config, category, checkoutPath, sarifFile) {
async function generateFailedSarif(logger, features, config, category, checkoutPath, sarifFile) {
const databasePath = config.dbLocation;
const codeql = await getCodeQL(config.codeQLCmd);
const codeql = await getCodeQL(logger, config.codeQLCmd);
if (sarifFile === void 0) {
sarifFile = "../codeql-failed-run.sarif";
}
@@ -161994,7 +161993,7 @@ async function run4(startedAt) {
"Debugging artifacts are unavailable since the 'init' Action failed before it could produce any."
);
} else {
const codeql = await getCodeQL(config.codeQLCmd);
const codeql = await getCodeQL(logger, config.codeQLCmd);
uploadFailedSarifResult = await uploadFailureInfo(
tryUploadAllAvailableDebugArtifacts,
printDebugLogs,
@@ -162097,7 +162096,7 @@ var core23 = __toESM(require_core());
// src/resolve-environment.ts
async function runResolveBuildEnvironment(cmd, logger, workingDir, language) {
logger.startGroup(`Attempting to resolve build environment for ${language}`);
const codeql = await getCodeQL(cmd);
const codeql = await getCodeQL(logger, cmd);
if (workingDir !== void 0) {
logger.info(`Using ${workingDir} as the working directory.`);
}