Ensure that we have files to calculate the hash for the cache key from
This commit is contained in:
parent
9d1353fe5f
commit
5afaeede1c
3 changed files with 45 additions and 5 deletions
20
lib/dependency-caching.js
generated
20
lib/dependency-caching.js
generated
|
|
@ -65,6 +65,9 @@ const CODEQL_DEFAULT_CACHE_CONFIG = {
|
|||
hash: ["**/go.sum"],
|
||||
},
|
||||
};
|
||||
async function makeGlobber(files) {
|
||||
return glob.create(files.join("\n"));
|
||||
}
|
||||
/**
|
||||
* Attempts to restore dependency caches for the languages being analyzed.
|
||||
*
|
||||
|
|
@ -80,6 +83,13 @@ async function downloadDependencyCaches(languages, logger) {
|
|||
logger.info(`Skipping download of dependency cache for ${language} as we have no caching configuration for it.`);
|
||||
continue;
|
||||
}
|
||||
// Check that we can find files to calculate the hash for the cache key from, so we don't end up
|
||||
// with an empty string.
|
||||
const globber = await makeGlobber(cacheConfig.hash);
|
||||
if ((await globber.glob()).length === 0) {
|
||||
logger.info(`Skipping download of dependency cache for ${language} as we cannot calculate a hash for the cache key.`);
|
||||
continue;
|
||||
}
|
||||
const primaryKey = await cacheKey(language, cacheConfig);
|
||||
const restoreKeys = [await cachePrefix(language)];
|
||||
logger.info(`Downloading cache for ${language} with key ${primaryKey} and restore keys ${restoreKeys.join(", ")}`);
|
||||
|
|
@ -104,8 +114,14 @@ async function uploadDependencyCaches(config, logger) {
|
|||
logger.info(`Skipping upload of dependency cache for ${language} as we have no caching configuration for it.`);
|
||||
continue;
|
||||
}
|
||||
const globber = await glob.create(cacheConfig.hash.join("\n"));
|
||||
const size = await (0, caching_utils_1.getTotalCacheSize)(await globber.glob(), logger);
|
||||
// Check that we can find files to calculate the hash for the cache key from, so we don't end up
|
||||
// with an empty string.
|
||||
const globber = await makeGlobber(cacheConfig.hash);
|
||||
if ((await globber.glob()).length === 0) {
|
||||
logger.info(`Skipping upload of dependency cache for ${language} as we cannot calculate a hash for the cache key.`);
|
||||
continue;
|
||||
}
|
||||
const size = await (0, caching_utils_1.getTotalCacheSize)(cacheConfig.paths, logger);
|
||||
const key = await cacheKey(language, cacheConfig);
|
||||
logger.info(`Uploading cache of size ${size} for ${language} with key ${key}`);
|
||||
await actionsCache.saveCache(cacheConfig.paths, key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue