mirror of
				https://gitea.com/actions/setup-python.git
				synced 2025-10-29 07:47:14 +00:00 
			
		
		
		
	Cache on ghes (#363)
* initial changes * updated version * format check * refactored code * updated test cases * Update src/utils.ts Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com> * Update utils.ts * Update utils.test.ts * review comments * dist update * Review comment * update version * updated version Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										20
									
								
								src/utils.ts
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/utils.ts
									
									
									
									
									
								
							| @@ -1,3 +1,5 @@ | ||||
| import * as cache from '@actions/cache'; | ||||
| import * as core from '@actions/core'; | ||||
| import fs from 'fs'; | ||||
| import * as path from 'path'; | ||||
| import * as semver from 'semver'; | ||||
| @@ -99,3 +101,21 @@ export function isGhes(): boolean { | ||||
|   ); | ||||
|   return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; | ||||
| } | ||||
|  | ||||
| export function isCacheFeatureAvailable(): boolean { | ||||
|   if (!cache.isFeatureAvailable()) { | ||||
|     if (isGhes()) { | ||||
|       throw new Error( | ||||
|         'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.' | ||||
|       ); | ||||
|     } else { | ||||
|       core.warning( | ||||
|         'The runner was not able to contact the cache service. Caching will be skipped' | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     return false; | ||||
|   } | ||||
|  | ||||
|   return true; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Shubham Tiwari
					Shubham Tiwari