Build action with cache-hit output

This commit is contained in:
dhvcc 2022-04-03 02:47:14 +03:00
parent c933f3c50e
commit fa50ad5388
3 changed files with 25 additions and 14 deletions

View file

@ -37234,6 +37234,10 @@ class CacheDistributor {
core.saveState(State.CACHE_PATHS, cachePath); core.saveState(State.CACHE_PATHS, cachePath);
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey); core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey); const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
this.handleMatchResult(matchedKey);
});
}
handleMatchResult(matchedKey) {
if (matchedKey) { if (matchedKey) {
core.saveState(State.CACHE_MATCHED_KEY, matchedKey); core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
core.info(`Cache restored from key: ${matchedKey}`); core.info(`Cache restored from key: ${matchedKey}`);
@ -37241,7 +37245,8 @@ class CacheDistributor {
else { else {
core.info(`${this.packageManager} cache is not found`); core.info(`${this.packageManager} cache is not found`);
} }
}); core.info('cache was hit');
core.setOutput('cache-hit', Boolean(matchedKey));
} }
} }
exports.default = CacheDistributor; exports.default = CacheDistributor;

7
dist/setup/index.js vendored
View file

@ -42579,6 +42579,10 @@ class CacheDistributor {
core.saveState(State.CACHE_PATHS, cachePath); core.saveState(State.CACHE_PATHS, cachePath);
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey); core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey); const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
this.handleMatchResult(matchedKey);
});
}
handleMatchResult(matchedKey) {
if (matchedKey) { if (matchedKey) {
core.saveState(State.CACHE_MATCHED_KEY, matchedKey); core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
core.info(`Cache restored from key: ${matchedKey}`); core.info(`Cache restored from key: ${matchedKey}`);
@ -42586,7 +42590,8 @@ class CacheDistributor {
else { else {
core.info(`${this.packageManager} cache is not found`); core.info(`${this.packageManager} cache is not found`);
} }
}); core.info('cache was hit');
core.setOutput('cache-hit', Boolean(matchedKey));
} }
} }
exports.default = CacheDistributor; exports.default = CacheDistributor;

View file

@ -54,6 +54,7 @@ abstract class CacheDistributor {
} else { } else {
core.info(`${this.packageManager} cache is not found`); core.info(`${this.packageManager} cache is not found`);
} }
core.info('cache was hit');
core.setOutput('cache-hit', Boolean(matchedKey)); core.setOutput('cache-hit', Boolean(matchedKey));
} }
} }