mirror of
https://github.com/actions/setup-go.git
synced 2025-04-24 01:50:52 +00:00
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.
This commit is contained in:
parent
b22fbbc292
commit
264cb756bc
3 changed files with 836 additions and 830 deletions
3
dist/setup/index.js
vendored
3
dist/setup/index.js
vendored
|
@ -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…
Add table
Reference in a new issue