Use common `getTotalCacheSize` for TRAP caching
This commit is contained in:
Родитель
0cb71294e5
Коммит
21e6a62b15
|
@ -64,7 +64,7 @@ async function sendStatusReport(startedAt, config, stats, error, trapCacheUpload
|
|||
const trapCacheUploadStatusReport = {
|
||||
...report,
|
||||
trap_cache_upload_duration_ms: Math.round(trapCacheUploadTime || 0),
|
||||
trap_cache_upload_size_bytes: Math.round(await (0, trap_caching_1.getTotalCacheSize)(config.trapCaches, logger)),
|
||||
trap_cache_upload_size_bytes: Math.round(await (0, caching_utils_1.getTotalCacheSize)(Object.values(config.trapCaches), logger)),
|
||||
};
|
||||
await statusReport.sendStatusReport(trapCacheUploadStatusReport);
|
||||
}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -43,7 +43,6 @@ const repository_1 = require("./repository");
|
|||
const setup_codeql_1 = require("./setup-codeql");
|
||||
const status_report_1 = require("./status-report");
|
||||
const tools_features_1 = require("./tools-features");
|
||||
const trap_caching_1 = require("./trap-caching");
|
||||
const util_1 = require("./util");
|
||||
const workflow_1 = require("./workflow");
|
||||
async function sendCompletedStatusReport(startedAt, config, configFile, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error) {
|
||||
|
@ -113,7 +112,7 @@ async function sendCompletedStatusReport(startedAt, config, configFile, toolsDow
|
|||
queries: queries.join(","),
|
||||
packs: JSON.stringify(packs),
|
||||
trap_cache_languages: Object.keys(config.trapCaches).join(","),
|
||||
trap_cache_download_size_bytes: Math.round(await (0, trap_caching_1.getTotalCacheSize)(config.trapCaches, logger)),
|
||||
trap_cache_download_size_bytes: Math.round(await (0, caching_utils_1.getTotalCacheSize)(Object.values(config.trapCaches), logger)),
|
||||
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
|
||||
query_filters: JSON.stringify(config.originalUserInput["query-filters"] ?? []),
|
||||
registries: JSON.stringify(configUtils.parseRegistriesWithoutCredentials((0, actions_util_1.getOptionalInput)("registries")) ?? []),
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -27,7 +27,6 @@ exports.downloadTrapCaches = downloadTrapCaches;
|
|||
exports.uploadTrapCaches = uploadTrapCaches;
|
||||
exports.cleanupTrapCaches = cleanupTrapCaches;
|
||||
exports.getLanguagesSupportingCaching = getLanguagesSupportingCaching;
|
||||
exports.getTotalCacheSize = getTotalCacheSize;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const actionsCache = __importStar(require("@actions/cache"));
|
||||
|
@ -227,10 +226,6 @@ async function getLanguagesSupportingCaching(codeql, languages, logger) {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
async function getTotalCacheSize(trapCaches, logger) {
|
||||
const sizes = await Promise.all(Object.values(trapCaches).map((cacheDir) => (0, util_1.tryGetFolderBytes)(cacheDir, logger)));
|
||||
return sizes.map((a) => a || 0).reduce((a, b) => a + b, 0);
|
||||
}
|
||||
async function cacheKey(codeql, language, baseSha) {
|
||||
return `${await cachePrefix(codeql, language)}${baseSha}`;
|
||||
}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -16,7 +16,7 @@ import {
|
|||
} from "./analyze";
|
||||
import { getApiDetails, getGitHubVersion } from "./api-client";
|
||||
import { runAutobuild } from "./autobuild";
|
||||
import { shouldStoreCache } from "./caching-utils";
|
||||
import { getTotalCacheSize, shouldStoreCache } from "./caching-utils";
|
||||
import { getCodeQL } from "./codeql";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { uploadDatabases } from "./database-upload";
|
||||
|
@ -36,7 +36,6 @@ import {
|
|||
} from "./status-report";
|
||||
import {
|
||||
cleanupTrapCaches,
|
||||
getTotalCacheSize,
|
||||
TrapCacheCleanupStatusReport,
|
||||
uploadTrapCaches,
|
||||
} from "./trap-caching";
|
||||
|
@ -94,7 +93,7 @@ async function sendStatusReport(
|
|||
...report,
|
||||
trap_cache_upload_duration_ms: Math.round(trapCacheUploadTime || 0),
|
||||
trap_cache_upload_size_bytes: Math.round(
|
||||
await getTotalCacheSize(config.trapCaches, logger),
|
||||
await getTotalCacheSize(Object.values(config.trapCaches), logger),
|
||||
),
|
||||
};
|
||||
await statusReport.sendStatusReport(trapCacheUploadStatusReport);
|
||||
|
|
|
@ -17,6 +17,7 @@ import {
|
|||
import { getGitHubVersion } from "./api-client";
|
||||
import {
|
||||
getDependencyCachingEnabled,
|
||||
getTotalCacheSize,
|
||||
shouldRestoreCache,
|
||||
} from "./caching-utils";
|
||||
import { CodeQL } from "./codeql";
|
||||
|
@ -51,7 +52,6 @@ import {
|
|||
import { ZstdAvailability } from "./tar";
|
||||
import { ToolsDownloadStatusReport } from "./tools-download";
|
||||
import { ToolsFeature } from "./tools-features";
|
||||
import { getTotalCacheSize } from "./trap-caching";
|
||||
import {
|
||||
checkDiskUsage,
|
||||
checkForTimeout,
|
||||
|
@ -230,7 +230,7 @@ async function sendCompletedStatusReport(
|
|||
packs: JSON.stringify(packs),
|
||||
trap_cache_languages: Object.keys(config.trapCaches).join(","),
|
||||
trap_cache_download_size_bytes: Math.round(
|
||||
await getTotalCacheSize(config.trapCaches, logger),
|
||||
await getTotalCacheSize(Object.values(config.trapCaches), logger),
|
||||
),
|
||||
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
|
||||
query_filters: JSON.stringify(
|
||||
|
|
|
@ -312,18 +312,6 @@ export async function getLanguagesSupportingCaching(
|
|||
return result;
|
||||
}
|
||||
|
||||
export async function getTotalCacheSize(
|
||||
trapCaches: Partial<Record<Language, string>>,
|
||||
logger: Logger,
|
||||
): Promise<number> {
|
||||
const sizes = await Promise.all(
|
||||
Object.values(trapCaches).map((cacheDir) =>
|
||||
tryGetFolderBytes(cacheDir, logger),
|
||||
),
|
||||
);
|
||||
return sizes.map((a) => a || 0).reduce((a, b) => a + b, 0);
|
||||
}
|
||||
|
||||
async function cacheKey(
|
||||
codeql: CodeQL,
|
||||
language: Language,
|
||||
|
|
Загрузка…
Ссылка в новой задаче