mirror of
https://github.com/github/codeql-action.git
synced 2025-12-19 13:59:30 +08:00
build: refresh js files
This commit is contained in:
34
lib/overlay-database-utils.js
generated
34
lib/overlay-database-utils.js
generated
@@ -213,51 +213,67 @@ async function uploadOverlayBaseDatabaseToCache(codeql, config, logger) {
|
||||
* @param codeql The CodeQL instance
|
||||
* @param config The configuration object
|
||||
* @param logger The logger instance
|
||||
* @returns A promise that resolves to true if the download was performed and
|
||||
* successfully completed, or false otherwise
|
||||
* @returns A promise that resolves to download statistics if an overlay-base
|
||||
* database was successfully downloaded, or undefined if the download was
|
||||
* either not performed or failed.
|
||||
*/
|
||||
async function downloadOverlayBaseDatabaseFromCache(codeql, config, logger) {
|
||||
const overlayDatabaseMode = config.augmentationProperties.overlayDatabaseMode;
|
||||
if (overlayDatabaseMode !== OverlayDatabaseMode.Overlay) {
|
||||
logger.debug(`Overlay database mode is ${overlayDatabaseMode}. ` +
|
||||
"Skip downloading overlay-base database from cache.");
|
||||
return false;
|
||||
return undefined;
|
||||
}
|
||||
if (!config.augmentationProperties.useOverlayDatabaseCaching) {
|
||||
logger.debug("Overlay database caching is disabled. " +
|
||||
"Skip downloading overlay-base database from cache.");
|
||||
return false;
|
||||
return undefined;
|
||||
}
|
||||
if ((0, util_1.isInTestMode)()) {
|
||||
logger.debug("In test mode. Skip downloading overlay-base database from cache.");
|
||||
return false;
|
||||
return undefined;
|
||||
}
|
||||
const dbLocation = config.dbLocation;
|
||||
const codeQlVersion = (await codeql.getVersion()).version;
|
||||
const restoreKey = getCacheRestoreKey(config, codeQlVersion);
|
||||
logger.info(`Looking in Actions cache for overlay-base database with restore key ${restoreKey}`);
|
||||
let databaseDownloadDurationMs = 0;
|
||||
try {
|
||||
const databaseDownloadStart = performance.now();
|
||||
const foundKey = await (0, util_1.withTimeout)(MAX_CACHE_OPERATION_MS, actionsCache.restoreCache([dbLocation], restoreKey), () => {
|
||||
logger.info("Timed out downloading overlay-base database from cache");
|
||||
});
|
||||
databaseDownloadDurationMs = Math.round(performance.now() - databaseDownloadStart);
|
||||
if (foundKey === undefined) {
|
||||
logger.info("No overlay-base database found in Actions cache");
|
||||
return false;
|
||||
return undefined;
|
||||
}
|
||||
logger.info(`Downloaded overlay-base database in cache with key ${foundKey}`);
|
||||
}
|
||||
catch (error) {
|
||||
logger.warning("Failed to download overlay-base database from cache: " +
|
||||
`${error instanceof Error ? error.message : String(error)}`);
|
||||
return false;
|
||||
return undefined;
|
||||
}
|
||||
const databaseIsValid = checkOverlayBaseDatabase(config, logger, "Downloaded overlay-base database is invalid");
|
||||
if (!databaseIsValid) {
|
||||
logger.warning("Downloaded overlay-base database failed validation");
|
||||
return false;
|
||||
return undefined;
|
||||
}
|
||||
const databaseSizeBytes = await (0, util_1.tryGetFolderBytes)(dbLocation, logger);
|
||||
if (databaseSizeBytes === undefined) {
|
||||
logger.info("Filesystem error while accessing downloaded overlay-base database");
|
||||
// The problem that warrants reporting download failure is not that we are
|
||||
// unable to determine the size of the database. Rather, it is that we
|
||||
// encountered a filesystem error while accessing the database, which
|
||||
// indicates that an overlay analysis will likely fail.
|
||||
return undefined;
|
||||
}
|
||||
logger.info(`Successfully downloaded overlay-base database to ${dbLocation}`);
|
||||
return true;
|
||||
return {
|
||||
databaseSizeBytes: Math.round(databaseSizeBytes),
|
||||
databaseDownloadDurationMs,
|
||||
};
|
||||
}
|
||||
async function generateCacheKey(config, codeQlVersion, checkoutPath) {
|
||||
const sha = await (0, git_utils_1.getCommitOid)(checkoutPath);
|
||||
|
||||
Reference in New Issue
Block a user