Add cache error handling
This commit is contained in:
		
							parent
							
								
									b22fbbc292
								
							
						
					
					
						commit
						6036aa2424
					
				
							
								
								
									
										26
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							| @ -61275,14 +61275,26 @@ 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); | ||||||
|     const cacheKey = yield cache.restoreCache(cachePaths, primaryKey); |     try { | ||||||
|     core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey)); |         const cacheKey = yield cache.restoreCache(cachePaths, primaryKey); | ||||||
|     if (!cacheKey) { |         core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey)); | ||||||
|         core.info(`Cache is not found`); |         if (!cacheKey) { | ||||||
|         return; |             core.info(`Cache is not found`); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         core.saveState(constants_1.State.CacheMatchedKey, 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); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|     core.saveState(constants_1.State.CacheMatchedKey, cacheKey); |  | ||||||
|     core.info(`Cache restored from key: ${cacheKey}`); |  | ||||||
| }); | }); | ||||||
| const findDependencyFile = (packageManager) => { | const findDependencyFile = (packageManager) => { | ||||||
|     let dependencyFile = packageManager.dependencyFilePattern; |     let dependencyFile = packageManager.dependencyFilePattern; | ||||||
|  | |||||||
| @ -34,16 +34,26 @@ export const restoreCache = async ( | |||||||
| 
 | 
 | ||||||
|   core.saveState(State.CachePrimaryKey, primaryKey); |   core.saveState(State.CachePrimaryKey, primaryKey); | ||||||
| 
 | 
 | ||||||
|   const cacheKey = await cache.restoreCache(cachePaths, primaryKey); |   try { | ||||||
|   core.setOutput(Outputs.CacheHit, Boolean(cacheKey)); |     const cacheKey = await cache.restoreCache(cachePaths, primaryKey); | ||||||
|  |     core.setOutput(Outputs.CacheHit, Boolean(cacheKey)); | ||||||
| 
 | 
 | ||||||
|   if (!cacheKey) { |     if (!cacheKey) { | ||||||
|     core.info(`Cache is not found`); |       core.info(`Cache is not found`); | ||||||
|     return; |       return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     core.saveState(State.CacheMatchedKey, 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); | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| 
 |  | ||||||
|   core.saveState(State.CacheMatchedKey, cacheKey); |  | ||||||
|   core.info(`Cache restored from key: ${cacheKey}`); |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const findDependencyFile = (packageManager: PackageManagerInfo) => { | const findDependencyFile = (packageManager: PackageManagerInfo) => { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user