add error handling for cache

This commit is contained in:
Dmitry Shibanov 2023-03-07 11:58:34 +01:00
parent 7b9ef6fc5a
commit 35437f7fe8
5 changed files with 689 additions and 1051 deletions

File diff suppressed because it is too large Load Diff

833
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

36
package-lock.json generated
View File

@ -31,15 +31,16 @@
}
},
"node_modules/@actions/cache": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz",
"integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==",
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.4.tgz",
"integrity": "sha512-Uh9wsz7SxunfyqF3UY/wfHI81z97CYQrZs4NU+whzYd0N8emTaloB+XtrAq46X2RbQEOBjF6R090jKQpX4coGg==",
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0",
"@actions/http-client": "^2.0.1",
"@actions/io": "^1.0.1",
"@azure/abort-controller": "^1.1.0",
"@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.8.0",
"semver": "^6.1.0",
@ -148,14 +149,14 @@
}
},
"node_modules/@azure/abort-controller": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz",
"integrity": "sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
"integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==",
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.2.0"
},
"engines": {
"node": ">=8.0.0"
"node": ">=12.0.0"
}
},
"node_modules/@azure/abort-controller/node_modules/tslib": {
@ -5649,15 +5650,16 @@
},
"dependencies": {
"@actions/cache": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz",
"integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==",
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.4.tgz",
"integrity": "sha512-Uh9wsz7SxunfyqF3UY/wfHI81z97CYQrZs4NU+whzYd0N8emTaloB+XtrAq46X2RbQEOBjF6R090jKQpX4coGg==",
"requires": {
"@actions/core": "^1.2.6",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0",
"@actions/http-client": "^2.0.1",
"@actions/io": "^1.0.1",
"@azure/abort-controller": "^1.1.0",
"@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.8.0",
"semver": "^6.1.0",
@ -5763,11 +5765,11 @@
}
},
"@azure/abort-controller": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz",
"integrity": "sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
"integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==",
"requires": {
"tslib": "^2.0.0"
"tslib": "^2.2.0"
},
"dependencies": {
"tslib": {

View File

@ -39,13 +39,18 @@ abstract class CacheDistributor {
const cachePath = await this.getCacheGlobalDirectories();
core.saveState(State.CACHE_PATHS, cachePath);
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
const matchedKey = await cache.restoreCache(
cachePath,
primaryKey,
restoreKey
);
let matchedKey: string | undefined;
try {
matchedKey = await cache.restoreCache(cachePath, primaryKey, restoreKey);
} catch (err) {
const message = (err as Error).message;
core.info(`[warning]${message}`);
core.setOutput('cache-hit', false);
return;
}
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
await this.handleLoadedCache();

View File

@ -43,7 +43,16 @@ async function saveCache(packageManager: string) {
return;
}
const cacheId = await cache.saveCache(cachePaths, primaryKey);
let cacheId = 0;
try {
cacheId = await cache.saveCache(cachePaths, primaryKey);
} catch (err) {
const message = (err as Error).message;
core.info(`[warning]${message}`);
return;
}
if (cacheId == -1) {
return;
}