mirror of
				https://git.mirrors.martin98.com/https://github.com/actions/setup-python
				synced 2025-10-31 08:51:06 +08:00 
			
		
		
		
	Add error handling for saving and restoring cache (#618)
This commit is contained in:
		
							parent
							
								
									b41aaf9f0c
								
							
						
					
					
						commit
						03eb867e3d
					
				
							
								
								
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@actions/cache" | ||||
| version: 3.0.4 | ||||
| version: 3.1.4 | ||||
| type: npm | ||||
| summary: Actions cache lib | ||||
| homepage: https://github.com/actions/toolkit/tree/main/packages/cache | ||||
|  | ||||
							
								
								
									
										4
									
								
								.licenses/npm/@azure/abort-controller.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								.licenses/npm/@azure/abort-controller.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,9 +1,9 @@ | ||||
| --- | ||||
| name: "@azure/abort-controller" | ||||
| version: 1.0.4 | ||||
| version: 1.1.0 | ||||
| type: npm | ||||
| summary: Microsoft Azure SDK for JavaScript - Aborter | ||||
| homepage: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/abort-controller/README.md | ||||
| homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/abort-controller/README.md | ||||
| license: mit | ||||
| licenses: | ||||
| - sources: LICENSE | ||||
|  | ||||
| @ -225,7 +225,7 @@ describe('run', () => { | ||||
|       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'; | ||||
|       getStateSpy.mockImplementation((name: string) => { | ||||
|         if (name === State.STATE_CACHE_PRIMARY_KEY) { | ||||
| @ -247,7 +247,7 @@ describe('run', () => { | ||||
|       expect(getStateSpy).toHaveBeenCalledTimes(3); | ||||
|       expect(infoSpy).not.toHaveBeenCalledWith(); | ||||
|       expect(saveCacheSpy).toHaveBeenCalled(); | ||||
|       expect(setFailedSpy).toHaveBeenCalled(); | ||||
|       expect(setFailedSpy).not.toHaveBeenCalled(); | ||||
|     }); | ||||
|   }); | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										843
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										843
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										833
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										833
									
								
								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": { | ||||
|       "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", | ||||
| @ -153,14 +154,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": { | ||||
| @ -6777,15 +6778,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", | ||||
| @ -6891,11 +6893,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": { | ||||
|  | ||||
| @ -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(); | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
|   } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dmitry Shibanov
						Dmitry Shibanov