mirror of
https://github.com/github/codeql-action.git
synced 2026-04-27 17:39:15 +00:00
Only store overlay status if analysis failed
This commit is contained in:
@@ -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",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user