mirror of
https://github.com/actions/setup-python.git
synced 2024-11-24 08:00:59 -05:00
Add error handling for saving and restoring cache (#618)
This commit is contained in:
parent
b41aaf9f0c
commit
03eb867e3d
8 changed files with 691 additions and 1053 deletions
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@azure/abort-controller.dep.yml
generated
BIN
.licenses/npm/@azure/abort-controller.dep.yml
generated
Binary file not shown.
|
@ -225,7 +225,7 @@ describe('run', () => {
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('saves with error from toolkit, should fail workflow', async () => {
|
it('saves with error from toolkit, should not fail the workflow', async () => {
|
||||||
inputs['cache'] = 'npm';
|
inputs['cache'] = 'npm';
|
||||||
getStateSpy.mockImplementation((name: string) => {
|
getStateSpy.mockImplementation((name: string) => {
|
||||||
if (name === State.STATE_CACHE_PRIMARY_KEY) {
|
if (name === State.STATE_CACHE_PRIMARY_KEY) {
|
||||||
|
@ -247,7 +247,7 @@ describe('run', () => {
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith();
|
expect(infoSpy).not.toHaveBeenCalledWith();
|
||||||
expect(saveCacheSpy).toHaveBeenCalled();
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
expect(setFailedSpy).toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
775
dist/cache-save/index.js
vendored
775
dist/cache-save/index.js
vendored
File diff suppressed because it is too large
Load diff
765
dist/setup/index.js
vendored
765
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load diff
36
package-lock.json
generated
36
package-lock.json
generated
|
@ -36,15 +36,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache": {
|
"node_modules/@actions/cache": {
|
||||||
"version": "3.0.4",
|
"version": "3.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.4.tgz",
|
||||||
"integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==",
|
"integrity": "sha512-Uh9wsz7SxunfyqF3UY/wfHI81z97CYQrZs4NU+whzYd0N8emTaloB+XtrAq46X2RbQEOBjF6R090jKQpX4coGg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/glob": "^0.1.0",
|
"@actions/glob": "^0.1.0",
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.1",
|
||||||
|
"@azure/abort-controller": "^1.1.0",
|
||||||
"@azure/ms-rest-js": "^2.6.0",
|
"@azure/ms-rest-js": "^2.6.0",
|
||||||
"@azure/storage-blob": "^12.8.0",
|
"@azure/storage-blob": "^12.8.0",
|
||||||
"semver": "^6.1.0",
|
"semver": "^6.1.0",
|
||||||
|
@ -153,14 +154,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@azure/abort-controller": {
|
"node_modules/@azure/abort-controller": {
|
||||||
"version": "1.0.4",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
|
||||||
"integrity": "sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw==",
|
"integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^2.0.0"
|
"tslib": "^2.2.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.0.0"
|
"node": ">=12.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@azure/abort-controller/node_modules/tslib": {
|
"node_modules/@azure/abort-controller/node_modules/tslib": {
|
||||||
|
@ -6777,15 +6778,16 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": {
|
"@actions/cache": {
|
||||||
"version": "3.0.4",
|
"version": "3.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.4.tgz",
|
||||||
"integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==",
|
"integrity": "sha512-Uh9wsz7SxunfyqF3UY/wfHI81z97CYQrZs4NU+whzYd0N8emTaloB+XtrAq46X2RbQEOBjF6R090jKQpX4coGg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/glob": "^0.1.0",
|
"@actions/glob": "^0.1.0",
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.1",
|
||||||
|
"@azure/abort-controller": "^1.1.0",
|
||||||
"@azure/ms-rest-js": "^2.6.0",
|
"@azure/ms-rest-js": "^2.6.0",
|
||||||
"@azure/storage-blob": "^12.8.0",
|
"@azure/storage-blob": "^12.8.0",
|
||||||
"semver": "^6.1.0",
|
"semver": "^6.1.0",
|
||||||
|
@ -6891,11 +6893,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@azure/abort-controller": {
|
"@azure/abort-controller": {
|
||||||
"version": "1.0.4",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
|
||||||
"integrity": "sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw==",
|
"integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"tslib": "^2.0.0"
|
"tslib": "^2.2.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": {
|
"tslib": {
|
||||||
|
|
|
@ -39,13 +39,18 @@ abstract class CacheDistributor {
|
||||||
const cachePath = await this.getCacheGlobalDirectories();
|
const cachePath = await this.getCacheGlobalDirectories();
|
||||||
|
|
||||||
core.saveState(State.CACHE_PATHS, cachePath);
|
core.saveState(State.CACHE_PATHS, cachePath);
|
||||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
|
||||||
|
|
||||||
const matchedKey = await cache.restoreCache(
|
let matchedKey: string | undefined;
|
||||||
cachePath,
|
try {
|
||||||
primaryKey,
|
matchedKey = await cache.restoreCache(cachePath, primaryKey, restoreKey);
|
||||||
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();
|
await this.handleLoadedCache();
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,16 @@ async function saveCache(packageManager: string) {
|
||||||
return;
|
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) {
|
if (cacheId == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue