Skip to content

Commit ef58c00

Browse files
committed
Only store overlay status if analysis failed
1 parent 7b7a951 commit ef58c00

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/init-action-post-helper.test.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,17 @@ test("does not save overlay status when OverlayAnalysisStatusSave feature flag i
411411
});
412412
});
413413

414-
test("saves overlay status recording successful build when analysis completed successfully", async (t) => {
414+
test("does not save overlay status when build successful", async (t) => {
415415
return await util.withTmpDir(async (tmpDir) => {
416416
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
417417
process.env["RUNNER_TEMP"] = tmpDir;
418418
// Mark analyze as having completed successfully.
419419
process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] = "true";
420420

421-
const diskUsage: util.DiskUsage = {
421+
sinon.stub(util, "checkDiskUsage").resolves({
422422
numAvailableBytes: 100 * 1024 * 1024 * 1024,
423423
numTotalBytes: 200 * 1024 * 1024 * 1024,
424-
};
425-
sinon.stub(util, "checkDiskUsage").resolves(diskUsage);
424+
});
426425

427426
const saveOverlayStatusStub = sinon
428427
.stub(overlayStatus, "saveOverlayStatus")
@@ -443,16 +442,8 @@ test("saves overlay status recording successful build when analysis completed su
443442
);
444443

445444
t.true(
446-
saveOverlayStatusStub.calledOnce,
447-
"saveOverlayStatus should be called exactly once",
448-
);
449-
t.deepEqual(
450-
saveOverlayStatusStub.firstCall.args[3],
451-
{
452-
attemptedToBuildOverlayBaseDatabase: true,
453-
builtOverlayBaseDatabase: true,
454-
},
455-
"fourth arg should be the overlay status recording a successful build attempt",
445+
saveOverlayStatusStub.notCalled,
446+
"saveOverlayStatus should not be called when build completed successfully",
456447
);
457448
});
458449
});

src/init-action-post-helper.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,16 @@ async function recordOverlayStatus(
257257
features: FeatureEnablement,
258258
logger: Logger,
259259
) {
260+
// Currently it is only important to store overlay status if the analysis attempted but failed
261+
// to build an overlay base database.
260262
if (
261263
config.overlayDatabaseMode === OverlayDatabaseMode.OverlayBase &&
264+
process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] !== "true" &&
262265
(await features.getValue(Feature.OverlayAnalysisStatusSave))
263266
) {
264267
const overlayStatus = {
265268
attemptedToBuildOverlayBaseDatabase: true,
266-
builtOverlayBaseDatabase:
267-
process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] === "true",
269+
builtOverlayBaseDatabase: false,
268270
} satisfies OverlayStatus;
269271

270272
const diskUsage = await checkDiskUsage(logger);

0 commit comments

Comments
 (0)