Try to load failed config if normal config is unavailable

Adapt relevant functions by narrowing their types or skipping steps that would otherwise have been skipped as well
This commit is contained in:
Michael B. Gale
2026-10-12 11:25:00 +01:00
parent 653a997aa3
commit 0a9e57aaa3
8 changed files with 92 additions and 29 deletions

27
lib/entry-points.js generated
View File

@@ -166100,6 +166100,11 @@ var toolrunner = __toESM(require_toolrunner());
var github = __toESM(require_github());
var io2 = __toESM(require_io());
// src/config/action-config.ts
function hasConfigKey(config, key) {
return config[key] !== void 0;
}
// src/environment.ts
var core = __toESM(require_core());
function getRequiredEnvVar(env, paramName) {
@@ -170210,6 +170215,9 @@ function getWorkflowEvent(env = getEnv()) {
}
}
async function printDebugLogs(config) {
if (!hasConfigKey(config, "languages") || !hasConfigKey(config, "dbLocation")) {
return;
}
for (const language of config.languages) {
const databaseDirectory = getCodeQLDatabasePath(config, language);
const logsDirectory = path2.join(databaseDirectory, "log");
@@ -175158,6 +175166,12 @@ async function getConfig(tempDir, logger2) {
const configFile = getPathToParsedConfigFile(tempDir);
return readConfigFile(logger2, configFile);
}
function getAbortedInitConfig(action, tempDir) {
if (action.name !== "init-post" /* InitPost */) {
return void 0;
}
return readConfigFile(action.logger, getPathToFailedConfigFile(tempDir));
}
async function generateRegistries(registriesInput, tempDir, logger2) {
const registries = parseRegistries(registriesInput);
let registriesAuthTokens;
@@ -187052,7 +187066,7 @@ async function uploadFailureInfo(uploadAllAvailableDebugArtifacts, printDebugLog
);
}
}
if (config.debugMode) {
if (config.debugMode && hasConfigKey(config, "dbLocation")) {
logger2.info(
"Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts..."
);
@@ -187065,7 +187079,7 @@ async function uploadFailureInfo(uploadAllAvailableDebugArtifacts, printDebugLog
);
await printDebugLogs2(config);
}
if (isSelfHostedRunner()) {
if (isSelfHostedRunner() && config.dbLocation) {
try {
fs31.rmSync(config.dbLocation, {
recursive: true,
@@ -187101,7 +187115,7 @@ function isConclusiveJobStatus(jobStatus) {
}
}
async function recordOverlayStatus(codeql, config, features, jobStatus, env, logger2) {
if (config.overlayDatabaseMode !== "overlay-base" /* OverlayBase */ || env.getOptional("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */) === "true" || !await features.getValue("overlay_analysis_status_save" /* OverlayAnalysisStatusSave */)) {
if (config.overlayDatabaseMode !== "overlay-base" /* OverlayBase */ || env.getOptional("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */) === "true" || !await features.getValue("overlay_analysis_status_save" /* OverlayAnalysisStatusSave */) || config.languages === void 0) {
return;
}
if (!isConclusiveJobStatus(jobStatus) && !didCodeQlReportError(env)) {
@@ -187215,6 +187229,9 @@ async function run4(action) {
restoreInputs(logger2);
const tmpDir = getTemporaryDirectory();
config = await getConfig(tmpDir, logger2);
if (config === void 0) {
config = getAbortedInitConfig(action, tmpDir);
}
const gitHubVersion = config?.gitHubVersion ?? await getGitHubVersion();
checkGitHubVersionInRange(gitHubVersion, logger2);
const repositoryNwo = getRepositoryNwo();
@@ -187224,7 +187241,7 @@ async function run4(action) {
getTemporaryDirectory(),
logger2
);
if (config === void 0) {
if (config?.codeQLCmd === void 0) {
logger2.warning(
"Debugging artifacts are unavailable since the 'init' Action failed before it could produce any."
);
@@ -187241,7 +187258,7 @@ async function run4(action) {
getEnv(),
logger2
);
if (await isAnalyzingDefaultBranch() && config.dependencyCachingEnabled !== "none" /* None */) {
if (await isAnalyzingDefaultBranch() && hasConfigKey(config, "dependencyCachingEnabled") && config.dependencyCachingEnabled !== "none" /* None */) {
dependencyCachingUsage = await getDependencyCacheUsage(logger2);
}
}