mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +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}`;
|
const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`;
|
||||||
core.debug(`primary key is ${primaryKey}`);
|
core.debug(`primary key is ${primaryKey}`);
|
||||||
|
const restoreKeys = [`setup-go-${platform}-go-${versionSpec}-`];
|
||||||
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
|
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));
|
core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey));
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
core.info(`Cache is not found`);
|
core.info(`Cache is not found`);
|
||||||
|
|
|
@ -31,10 +31,15 @@ export const restoreCache = async (
|
||||||
|
|
||||||
const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`;
|
const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`;
|
||||||
core.debug(`primary key is ${primaryKey}`);
|
core.debug(`primary key is ${primaryKey}`);
|
||||||
|
const restoreKeys = [`setup-go-${platform}-go-${versionSpec}-`];
|
||||||
|
|
||||||
core.saveState(State.CachePrimaryKey, primaryKey);
|
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));
|
core.setOutput(Outputs.CacheHit, Boolean(cacheKey));
|
||||||
|
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue