Avoid using a global for getOrInitCodeQL

This commit is contained in:
Michael B. Gale
2026-02-24 20:09:10 +00:00
parent 37f3bfc967
commit 6d90f4c71e
3 changed files with 24 additions and 16 deletions
+7 -7
View File
@@ -111370,19 +111370,18 @@ function filterAlertsByDiffRange(logger, sarif) {
}
// src/upload-sarif.ts
var cachedCodeQL2;
async function getOrInitCodeQL(logger, gitHubVersion, features, config) {
if (cachedCodeQL2 !== void 0) return cachedCodeQL2;
async function getOrInitCodeQL(actionState, logger, gitHubVersion, features, config) {
if (actionState.cachedCodeQL !== void 0) return actionState.cachedCodeQL;
if (config !== void 0) {
cachedCodeQL2 = await getCodeQL(config.codeQLCmd);
actionState.cachedCodeQL = await getCodeQL(config.codeQLCmd);
} else {
cachedCodeQL2 = await minimalInitCodeQL(
actionState.cachedCodeQL = await minimalInitCodeQL(
logger,
gitHubVersion,
features
);
}
return cachedCodeQL2;
return actionState.cachedCodeQL;
}
async function postProcessAndUploadSarif(logger, tempPath, features, getCodeQL2, uploadKind, checkoutPath, sarifPath, category, postProcessedOutputPath) {
const sarifGroups = await getGroupedSarifFilePaths(
@@ -111442,6 +111441,7 @@ async function sendSuccessStatusReport(startedAt, uploadStats, logger) {
}
async function run(startedAt) {
const logger = getActionsLogger();
const state = { cachedCodeQL: void 0 };
try {
initializeEnvironment(getActionVersion());
const gitHubVersion = await getGitHubVersion();
@@ -111477,7 +111477,7 @@ async function run(startedAt) {
logger,
tempDir,
features,
() => getOrInitCodeQL(logger, gitHubVersion, features, config),
() => getOrInitCodeQL(state, logger, gitHubVersion, features, config),
"always",
checkoutPath,
sarifPath,