mirror of
https://github.com/github/codeql-action.git
synced 2026-04-27 01:08:46 +00:00
Merge pull request #3296 from github/mbg/dependency-caching/skip-uploads-for-exact-matches
Skip uploading dependency caches if we know they exist
This commit is contained in:
Generated
+5
-1
@@ -91159,6 +91159,11 @@ async function uploadDependencyCaches(codeql, features, config, logger) {
|
||||
status.push({ language, result: "no-hash" /* NoHash */ });
|
||||
continue;
|
||||
}
|
||||
const key = await cacheKey2(codeql, features, language, patterns);
|
||||
if (config.dependencyCachingRestoredKeys.includes(key)) {
|
||||
status.push({ language, result: "duplicate" /* Duplicate */ });
|
||||
continue;
|
||||
}
|
||||
const size = await getTotalCacheSize(
|
||||
cacheConfig.getDependencyPaths(),
|
||||
logger,
|
||||
@@ -91171,7 +91176,6 @@ async function uploadDependencyCaches(codeql, features, config, logger) {
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const key = await cacheKey2(codeql, features, language, patterns);
|
||||
logger.info(
|
||||
`Uploading cache of size ${size} for ${language} with key ${key}...`
|
||||
);
|
||||
|
||||
Generated
+19
-7
@@ -86828,6 +86828,7 @@ async function initActionState({
|
||||
trapCaches,
|
||||
trapCacheDownloadTime,
|
||||
dependencyCachingEnabled: getCachingKind(dependencyCachingEnabled),
|
||||
dependencyCachingRestoredKeys: [],
|
||||
extraQueryExclusions: [],
|
||||
overlayDatabaseMode: "none" /* None */,
|
||||
useOverlayDatabaseCaching: false,
|
||||
@@ -87321,6 +87322,7 @@ async function checkHashPatterns(codeql, features, language, cacheConfig, checkT
|
||||
}
|
||||
async function downloadDependencyCaches(codeql, features, languages, logger) {
|
||||
const status = [];
|
||||
const restoredKeys = [];
|
||||
for (const language of languages) {
|
||||
const cacheConfig = defaultCacheConfigs[language];
|
||||
if (cacheConfig === void 0) {
|
||||
@@ -87359,14 +87361,22 @@ async function downloadDependencyCaches(codeql, features, languages, logger) {
|
||||
const download_duration_ms = Math.round(performance.now() - start);
|
||||
if (hitKey !== void 0) {
|
||||
logger.info(`Cache hit on key ${hitKey} for ${language}.`);
|
||||
const hit_kind = hitKey === primaryKey ? "exact" /* Exact */ : "partial" /* Partial */;
|
||||
status.push({ language, hit_kind, download_duration_ms });
|
||||
let hit_kind = "partial" /* Partial */;
|
||||
if (hitKey === primaryKey) {
|
||||
hit_kind = "exact" /* Exact */;
|
||||
}
|
||||
status.push({
|
||||
language,
|
||||
hit_kind,
|
||||
download_duration_ms
|
||||
});
|
||||
restoredKeys.push(hitKey);
|
||||
} else {
|
||||
status.push({ language, hit_kind: "miss" /* Miss */ });
|
||||
logger.info(`No suitable cache found for ${language}.`);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
return { statusReport: status, restoredKeys };
|
||||
}
|
||||
async function cacheKey2(codeql, features, language, patterns) {
|
||||
const hash = await glob.hashFiles(patterns.join("\n"));
|
||||
@@ -89998,7 +90008,7 @@ async function run() {
|
||||
return;
|
||||
}
|
||||
let overlayBaseDatabaseStats;
|
||||
let dependencyCachingResults;
|
||||
let dependencyCachingStatus;
|
||||
try {
|
||||
if (config.overlayDatabaseMode === "overlay" /* Overlay */ && config.useOverlayDatabaseCaching) {
|
||||
overlayBaseDatabaseStats = await downloadOverlayBaseDatabaseFromCache(
|
||||
@@ -90139,12 +90149,14 @@ exec ${goBinaryPath} "$@"`
|
||||
}
|
||||
}
|
||||
if (shouldRestoreCache(config.dependencyCachingEnabled)) {
|
||||
dependencyCachingResults = await downloadDependencyCaches(
|
||||
const dependencyCachingResult = await downloadDependencyCaches(
|
||||
codeql,
|
||||
features,
|
||||
config.languages,
|
||||
logger
|
||||
);
|
||||
dependencyCachingStatus = dependencyCachingResult.statusReport;
|
||||
config.dependencyCachingRestoredKeys = dependencyCachingResult.restoredKeys;
|
||||
}
|
||||
if (await codeQlVersionAtLeast(codeql, "2.17.1")) {
|
||||
} else {
|
||||
@@ -90245,7 +90257,7 @@ exec ${goBinaryPath} "$@"`
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingResults,
|
||||
dependencyCachingStatus,
|
||||
logger,
|
||||
error3
|
||||
);
|
||||
@@ -90263,7 +90275,7 @@ exec ${goBinaryPath} "$@"`
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingResults,
|
||||
dependencyCachingStatus,
|
||||
logger
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user