mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Be more explicit about attempt to build overlay DB
This commit is contained in:
5
lib/init-action-post.js
generated
5
lib/init-action-post.js
generated
@@ -169801,9 +169801,10 @@ async function run(uploadAllAvailableDebugArtifacts, printDebugLogs2, codeql, co
|
||||
return uploadFailedSarifResult;
|
||||
}
|
||||
async function recordOverlayStatus(codeql, config, features, logger) {
|
||||
if (config.overlayDatabaseMode === "overlay-base" /* OverlayBase */ && process.env["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 */ && await features.getValue("overlay_analysis_status_save" /* OverlayAnalysisStatusSave */)) {
|
||||
const overlayStatus = {
|
||||
builtOverlayBaseDatabase: false
|
||||
attemptedToBuildOverlayBaseDatabase: true,
|
||||
builtOverlayBaseDatabase: process.env["CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */] === "true"
|
||||
};
|
||||
const diskUsage = await checkDiskUsage(logger);
|
||||
if (diskUsage === void 0) {
|
||||
|
||||
2
lib/init-action.js
generated
2
lib/init-action.js
generated
@@ -105714,7 +105714,7 @@ async function shouldSkipOverlayAnalysis(codeql, languages, diskUsage, logger) {
|
||||
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."
|
||||
);
|
||||
|
||||
@@ -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",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user