mirror of
https://github.com/actions/setup-go.git
synced 2024-11-15 11:54:34 +08:00
Add cache error handling
This commit is contained in:
parent
b22fbbc292
commit
6036aa2424
12
dist/setup/index.js
vendored
12
dist/setup/index.js
vendored
@ -61275,6 +61275,7 @@ 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}`);
|
||||||
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
|
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
|
||||||
|
try {
|
||||||
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey);
|
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey);
|
||||||
core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey));
|
core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey));
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
@ -61283,6 +61284,17 @@ exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0
|
|||||||
}
|
}
|
||||||
core.saveState(constants_1.State.CacheMatchedKey, cacheKey);
|
core.saveState(constants_1.State.CacheMatchedKey, cacheKey);
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const typedError = error;
|
||||||
|
if (typedError.name === cache.ValidationError.name) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.warning(typedError.message);
|
||||||
|
core.setOutput(constants_1.Outputs.CacheHit, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const findDependencyFile = (packageManager) => {
|
const findDependencyFile = (packageManager) => {
|
||||||
let dependencyFile = packageManager.dependencyFilePattern;
|
let dependencyFile = packageManager.dependencyFilePattern;
|
||||||
|
@ -34,6 +34,7 @@ export const restoreCache = async (
|
|||||||
|
|
||||||
core.saveState(State.CachePrimaryKey, primaryKey);
|
core.saveState(State.CachePrimaryKey, primaryKey);
|
||||||
|
|
||||||
|
try {
|
||||||
const cacheKey = await cache.restoreCache(cachePaths, primaryKey);
|
const cacheKey = await cache.restoreCache(cachePaths, primaryKey);
|
||||||
core.setOutput(Outputs.CacheHit, Boolean(cacheKey));
|
core.setOutput(Outputs.CacheHit, Boolean(cacheKey));
|
||||||
|
|
||||||
@ -44,6 +45,15 @@ export const restoreCache = async (
|
|||||||
|
|
||||||
core.saveState(State.CacheMatchedKey, cacheKey);
|
core.saveState(State.CacheMatchedKey, cacheKey);
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
|
} catch (error) {
|
||||||
|
const typedError = error as Error;
|
||||||
|
if (typedError.name === cache.ValidationError.name) {
|
||||||
|
throw error;
|
||||||
|
} else {
|
||||||
|
core.warning(typedError.message);
|
||||||
|
core.setOutput(Outputs.CacheHit, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const findDependencyFile = (packageManager: PackageManagerInfo) => {
|
const findDependencyFile = (packageManager: PackageManagerInfo) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user