mirror of
				https://github.com/actions/setup-go.git
				synced 2025-10-31 16:13:43 +00:00 
			
		
		
		
	Merge 4ef8fc9d4c283e40a027c2c4a385d650c85a21be into c0137caad775660c0844396c52da96e560aba63d
This commit is contained in:
		
						commit
						234370a138
					
				| @ -44,7 +44,8 @@ describe('restoreCache', () => { | ||||
|       await cacheRestore.restoreCache( | ||||
|         versionSpec, | ||||
|         packageManager, | ||||
|         cacheDependencyPath | ||||
|         cacheDependencyPath, | ||||
|         undefined | ||||
|       ); | ||||
|     }).rejects.toThrow( | ||||
|       'Some specified paths were not resolved, unable to cache dependencies.' | ||||
| @ -69,7 +70,8 @@ describe('restoreCache', () => { | ||||
|     await cacheRestore.restoreCache( | ||||
|       versionSpec, | ||||
|       packageManager, | ||||
|       cacheDependencyPath | ||||
|       cacheDependencyPath, | ||||
|       undefined | ||||
|     ); | ||||
|     expect(infoSpy).toHaveBeenCalledWith(`Cache is not found`); | ||||
|   }); | ||||
| @ -92,7 +94,8 @@ describe('restoreCache', () => { | ||||
|     await cacheRestore.restoreCache( | ||||
|       versionSpec, | ||||
|       packageManager, | ||||
|       cacheDependencyPath | ||||
|       cacheDependencyPath, | ||||
|       undefined | ||||
|     ); | ||||
|     expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true); | ||||
|   }); | ||||
|  | ||||
| @ -17,6 +17,8 @@ inputs: | ||||
|     default: true | ||||
|   cache-dependency-path: | ||||
|     description: 'Used to specify the path to a dependency file - go.sum' | ||||
|   buildTargetArch: | ||||
|     description: 'Optional build target architecture (for example arm64 or amd64) used to scope the cache key.' | ||||
|   architecture: | ||||
|     description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.' | ||||
| outputs: | ||||
|  | ||||
| @ -11,7 +11,8 @@ import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils'; | ||||
| export const restoreCache = async ( | ||||
|   versionSpec: string, | ||||
|   packageManager: string, | ||||
|   cacheDependencyPath?: string | ||||
|   cacheDependencyPath?: string, | ||||
|   buildTargetArch?: string | ||||
| ) => { | ||||
|   const packageManagerInfo = await getPackageManagerInfo(packageManager); | ||||
|   const platform = process.env.RUNNER_OS; | ||||
| @ -32,7 +33,9 @@ export const restoreCache = async ( | ||||
| 
 | ||||
|   const linuxVersion = | ||||
|     process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; | ||||
|   const primaryKey = `setup-go-${platform}-${arch}-${linuxVersion}go-${versionSpec}-${fileHash}`; | ||||
|   const sanitizedBuildTarget = buildTargetArch?.trim(); | ||||
|   const targetSegment = sanitizedBuildTarget ? `${sanitizedBuildTarget}-` : ''; | ||||
|   const primaryKey = `setup-go-${platform}-${arch}-${targetSegment}${linuxVersion}go-${versionSpec}-${fileHash}`; | ||||
|   core.debug(`primary key is ${primaryKey}`); | ||||
| 
 | ||||
|   core.saveState(State.CachePrimaryKey, primaryKey); | ||||
|  | ||||
| @ -20,6 +20,7 @@ export async function run() { | ||||
|     setGoToolchain(); | ||||
| 
 | ||||
|     const cache = core.getBooleanInput('cache'); | ||||
|     const buildTargetArch = core.getInput('buildTargetArch'); | ||||
|     core.info(`Setup go version spec ${versionSpec}`); | ||||
| 
 | ||||
|     let arch = core.getInput('architecture') as Architecture; | ||||
| @ -73,7 +74,8 @@ export async function run() { | ||||
|         await restoreCache( | ||||
|           parseGoVersion(goVersion), | ||||
|           packageManager, | ||||
|           cacheDependencyPath | ||||
|           cacheDependencyPath, | ||||
|           buildTargetArch | ||||
|         ); | ||||
|       } catch (error) { | ||||
|         core.warning(`Restore cache failed: ${(error as Error).message}`); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user