Skip to content

Commit ccf791e

Browse files
committed
Don't try to upload cache if cache key was an exact match during restore
1 parent b73cd05 commit ccf791e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/analyze-action.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dependency-caching.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,18 @@ export async function uploadDependencyCaches(
386386
continue;
387387
}
388388

389+
// Now that we have verified that there are suitable files, compute the hash for the cache key.
390+
const key = await cacheKey(codeql, features, language, patterns);
391+
392+
// Check that we haven't previously had an exact match for this key. If a cache with this key
393+
// already exists in the Actions Cache, performing the next steps is pointless as the cache
394+
// will not get overwritten. We can therefore skip the expensive work of measuring the size
395+
// of the cache contents and attempting to upload it.
396+
if (config.dependencyCachingExactKeys.includes(key)) {
397+
status.push({ language, result: CacheStoreResult.Duplicate });
398+
continue;
399+
}
400+
389401
// Calculate the size of the files that we would store in the cache. We use this to determine whether the
390402
// cache should be saved or not. For example, if there are no files to store, then we skip creating the
391403
// cache. In the future, we could also:
@@ -411,8 +423,6 @@ export async function uploadDependencyCaches(
411423
continue;
412424
}
413425

414-
const key = await cacheKey(codeql, features, language, patterns);
415-
416426
logger.info(
417427
`Uploading cache of size ${size} for ${language} with key ${key}...`,
418428
);

0 commit comments

Comments
 (0)