Be more explicit about attempt to build overlay DB

This commit is contained in:
Henry Mercer
2026-02-17 13:38:06 +00:00
parent 827bba691f
commit 6c405c2562
5 changed files with 33 additions and 14 deletions
+20 -8
View File
@@ -365,8 +365,11 @@ test("saves overlay status when overlay-base analysis did not complete successfu
);
t.deepEqual(
saveOverlayStatusStub.firstCall.args[3],
{ builtOverlayBaseDatabase: false },
"fourth arg should be the overlay status with builtOverlayBaseDatabase: false",
{
attemptedToBuildOverlayBaseDatabase: true,
builtOverlayBaseDatabase: false,
},
"fourth arg should be the overlay status recording an unsuccessful build attempt",
);
});
});
@@ -408,17 +411,18 @@ test("does not save overlay status when OverlayAnalysisStatusSave feature flag i
});
});
test("does not save overlay status when analysis completed successfully", async (t) => {
test("saves overlay status recording successful build when analysis completed successfully", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
process.env["RUNNER_TEMP"] = tmpDir;
// Mark analyze as having completed successfully.
process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] = "true";
sinon.stub(util, "checkDiskUsage").resolves({
const diskUsage: util.DiskUsage = {
numAvailableBytes: 100 * 1024 * 1024 * 1024,
numTotalBytes: 200 * 1024 * 1024 * 1024,
});
};
sinon.stub(util, "checkDiskUsage").resolves(diskUsage);
const saveOverlayStatusStub = sinon
.stub(overlayStatus, "saveOverlayStatus")
@@ -434,13 +438,21 @@ test("does not save overlay status when analysis completed successfully", async
overlayDatabaseMode: OverlayDatabaseMode.OverlayBase,
}),
parseRepositoryNwo("github/codeql-action"),
createFeatures([]),
createFeatures([Feature.OverlayAnalysisStatusSave]),
getRunnerLogger(true),
);
t.true(
saveOverlayStatusStub.notCalled,
"saveOverlayStatus should not be called when analysis completed successfully",
saveOverlayStatusStub.calledOnce,
"saveOverlayStatus should be called exactly once",
);
t.deepEqual(
saveOverlayStatusStub.firstCall.args[3],
{
attemptedToBuildOverlayBaseDatabase: true,
builtOverlayBaseDatabase: true,
},
"fourth arg should be the overlay status recording a successful build attempt",
);
});
});
+3 -2
View File
@@ -259,11 +259,12 @@ async function recordOverlayStatus(
) {
if (
config.overlayDatabaseMode === OverlayDatabaseMode.OverlayBase &&
process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] !== "true" &&
(await features.getValue(Feature.OverlayAnalysisStatusSave))
) {
const overlayStatus = {
builtOverlayBaseDatabase: false,
attemptedToBuildOverlayBaseDatabase: true,
builtOverlayBaseDatabase:
process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] === "true",
} satisfies OverlayStatus;
const diskUsage = await checkDiskUsage(logger);
+6 -1
View File
@@ -30,6 +30,8 @@ const STATUS_FILE_NAME = "overlay-status.json";
/** Status of an overlay analysis for a set of languages. */
export interface OverlayStatus {
/** Whether the job attempted to build an overlay base database. */
attemptedToBuildOverlayBaseDatabase: boolean;
/** Whether the job successfully built an overlay base database. */
builtOverlayBaseDatabase: boolean;
}
@@ -48,7 +50,10 @@ export async function shouldSkipOverlayAnalysis(
logger.debug("No cached overlay status found.");
return false;
}
if (!status.builtOverlayBaseDatabase) {
if (
status.attemptedToBuildOverlayBaseDatabase &&
!status.builtOverlayBaseDatabase
) {
logger.info(
"Cached overlay status indicates that building an overlay base database was unsuccessful, so will skip overlay analysis.",
);