Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't try to upload cache if we have restored a cache with the same key
  • Loading branch information
mbg committed Nov 14, 2025
commit 51c9af3a3b0efcf59cfdeca89f6bac998d5c0679
6 changes: 5 additions & 1 deletion lib/analyze-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions src/dependency-caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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}...`,
);
Expand Down