diff --git a/src/init-action-post-helper.test.ts b/src/init-action-post-helper.test.ts index a2a167af0..13bba4bdb 100644 --- a/src/init-action-post-helper.test.ts +++ b/src/init-action-post-helper.test.ts @@ -411,18 +411,17 @@ test("does not save overlay status when OverlayAnalysisStatusSave feature flag i }); }); -test("saves overlay status recording successful build when analysis completed successfully", async (t) => { +test("does not save overlay status when build successful", 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"; - const diskUsage: util.DiskUsage = { + sinon.stub(util, "checkDiskUsage").resolves({ numAvailableBytes: 100 * 1024 * 1024 * 1024, numTotalBytes: 200 * 1024 * 1024 * 1024, - }; - sinon.stub(util, "checkDiskUsage").resolves(diskUsage); + }); const saveOverlayStatusStub = sinon .stub(overlayStatus, "saveOverlayStatus") @@ -443,16 +442,8 @@ test("saves overlay status recording successful build when analysis completed su ); t.true( - 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", + saveOverlayStatusStub.notCalled, + "saveOverlayStatus should not be called when build completed successfully", ); }); }); diff --git a/src/init-action-post-helper.ts b/src/init-action-post-helper.ts index 1f6e08798..e7b269fca 100644 --- a/src/init-action-post-helper.ts +++ b/src/init-action-post-helper.ts @@ -257,14 +257,16 @@ async function recordOverlayStatus( features: FeatureEnablement, logger: Logger, ) { + // Currently it is only important to store overlay status if the analysis attempted but failed + // to build an overlay base database. if ( config.overlayDatabaseMode === OverlayDatabaseMode.OverlayBase && + process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] !== "true" && (await features.getValue(Feature.OverlayAnalysisStatusSave)) ) { const overlayStatus = { attemptedToBuildOverlayBaseDatabase: true, - builtOverlayBaseDatabase: - process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] === "true", + builtOverlayBaseDatabase: false, } satisfies OverlayStatus; const diskUsage = await checkDiskUsage(logger);