mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Don't try to upload cache if we have restored a cache with the same key
This commit is contained in:
6
lib/analyze-action.js
generated
6
lib/analyze-action.js
generated
@@ -91155,6 +91155,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,
|
||||
@@ -91167,7 +91172,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}...`
|
||||
);
|
||||
|
||||
@@ -385,6 +385,18 @@ export async function uploadDependencyCaches(
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now that we have verified that there are suitable files, compute the hash for the cache key.
|
||||
const key = await cacheKey(codeql, features, language, patterns);
|
||||
|
||||
// Check that we haven't previously restored this exact key. If a cache with this key
|
||||
// already exists in the Actions Cache, performing the next steps is pointless as the cache
|
||||
// will not get overwritten. We can therefore skip the expensive work of measuring the size
|
||||
// of the cache contents and attempting to upload it if we know that the cache already exists.
|
||||
if (config.dependencyCachingRestoredKeys.includes(key)) {
|
||||
status.push({ language, result: CacheStoreResult.Duplicate });
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calculate the size of the files that we would store in the cache. We use this to determine whether the
|
||||
// cache should be saved or not. For example, if there are no files to store, then we skip creating the
|
||||
// cache. In the future, we could also:
|
||||
@@ -410,8 +422,6 @@ export async function uploadDependencyCaches(
|
||||
continue;
|
||||
}
|
||||
|
||||
const key = await cacheKey(codeql, features, language, patterns);
|
||||
|
||||
logger.info(
|
||||
`Uploading cache of size ${size} for ${language} with key ${key}...`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user