Use restoreKeys with cache

To match the recommendation documented here:
https://github.com/actions/cache/blob/main/examples.md#go---modules

Without `restoreKeys` any change to `go.sum` results in a complete cache
miss. By using `restoreKeys` a change in one dependency should still
allow a cache to be restored, so that all the other dependencies are
retreived from the cache.
pull/239/head
Daniel Nephin 3 years ago
parent b22fbbc292
commit 264cb756bc

@ -61274,8 +61274,9 @@ exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0
}
const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`;
core.debug(`primary key is ${primaryKey}`);
const restoreKeys = [`setup-go-${platform}-go-${versionSpec}-`];
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey);
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey));
if (!cacheKey) {
core.info(`Cache is not found`);

@ -31,10 +31,15 @@ export const restoreCache = async (
const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`;
core.debug(`primary key is ${primaryKey}`);
const restoreKeys = [`setup-go-${platform}-go-${versionSpec}-`];
core.saveState(State.CachePrimaryKey, primaryKey);
const cacheKey = await cache.restoreCache(cachePaths, primaryKey);
const cacheKey = await cache.restoreCache(
cachePaths,
primaryKey,
restoreKeys
);
core.setOutput(Outputs.CacheHit, Boolean(cacheKey));
if (!cacheKey) {

Loading…
Cancel
Save