mirror of
				https://github.com/actions/setup-go.git
				synced 2025-10-31 15:50:33 +00:00 
			
		
		
		
	Compare commits
	
		
			15 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | c4a742cab1 | ||
|   | f556e5b7e0 | ||
|   | 514ae57904 | ||
|   | 30b9ddff11 | ||
|   | c4e169859f | ||
|   | db58e98a43 | ||
|   | 2905db4069 | ||
|   | 57452eb902 | ||
|   | 5547b9ed8d | ||
|   | be45b2722d | ||
|   | 4c32251b06 | ||
|   | e68a999c97 | ||
|   | b855b20887 | ||
|   | bf059911e8 | ||
|   | 884d2909a6 | 
							
								
								
									
										2
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@actions/core" | ||||
| version: 1.6.0 | ||||
| version: 1.10.0 | ||||
| type: npm | ||||
| summary: Actions core lib | ||||
| homepage: https://github.com/actions/toolkit/tree/main/packages/core | ||||
|   | ||||
| @@ -179,4 +179,4 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md) | ||||
|  | ||||
| ## Code of Conduct | ||||
|  | ||||
| :wave: Be nice. See [our code of conduct](CONDUCT) | ||||
| :wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md) | ||||
|   | ||||
| @@ -17,6 +17,7 @@ describe('restoreCache', () => { | ||||
|   let infoSpy = jest.spyOn(core, 'info'); | ||||
|   let setOutputSpy = jest.spyOn(core, 'setOutput'); | ||||
|  | ||||
|   const versionSpec = '1.13.1'; | ||||
|   const packageManager = 'default'; | ||||
|   const cacheDependencyPath = 'path'; | ||||
|  | ||||
| @@ -40,7 +41,11 @@ describe('restoreCache', () => { | ||||
|  | ||||
|     //Act + Assert | ||||
|     expect(async () => { | ||||
|       await cacheRestore.restoreCache(packageManager, cacheDependencyPath); | ||||
|       await cacheRestore.restoreCache( | ||||
|         versionSpec, | ||||
|         packageManager, | ||||
|         cacheDependencyPath | ||||
|       ); | ||||
|     }).rejects.toThrowError( | ||||
|       'Some specified paths were not resolved, unable to cache dependencies.' | ||||
|     ); | ||||
| @@ -61,7 +66,11 @@ describe('restoreCache', () => { | ||||
|     }); | ||||
|  | ||||
|     //Act + Assert | ||||
|     await cacheRestore.restoreCache(packageManager, cacheDependencyPath); | ||||
|     await cacheRestore.restoreCache( | ||||
|       versionSpec, | ||||
|       packageManager, | ||||
|       cacheDependencyPath | ||||
|     ); | ||||
|     expect(infoSpy).toBeCalledWith(`Cache is not found`); | ||||
|   }); | ||||
|  | ||||
| @@ -80,7 +89,11 @@ describe('restoreCache', () => { | ||||
|     }); | ||||
|  | ||||
|     //Act + Assert | ||||
|     await cacheRestore.restoreCache(packageManager, cacheDependencyPath); | ||||
|     await cacheRestore.restoreCache( | ||||
|       versionSpec, | ||||
|       packageManager, | ||||
|       cacheDependencyPath | ||||
|     ); | ||||
|     expect(setOutputSpy).toBeCalledWith('cache-hit', true); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -295,7 +295,6 @@ describe('setup-go', () => { | ||||
|     findSpy.mockImplementation(() => toolPath); | ||||
|     await main.run(); | ||||
|  | ||||
|     let expPath = path.join(toolPath, 'bin'); | ||||
|     expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); | ||||
|   }); | ||||
|  | ||||
| @@ -462,9 +461,6 @@ describe('setup-go', () => { | ||||
|     inputs['go-version'] = versionSpec; | ||||
|     inputs['token'] = 'faketoken'; | ||||
|  | ||||
|     let expectedUrl = | ||||
|       'https://github.com/actions/go-versions/releases/download/1.12.14-20200616.18/go-1.12.14-linux-x64.tar.gz'; | ||||
|  | ||||
|     // ... but not in the local cache | ||||
|     findSpy.mockImplementation(() => ''); | ||||
|  | ||||
| @@ -526,7 +522,7 @@ describe('setup-go', () => { | ||||
|     }); | ||||
|  | ||||
|     mkdirpSpy.mockImplementation(async () => {}); | ||||
|     existsSpy.mockImplementation(path => { | ||||
|     existsSpy.mockImplementation(() => { | ||||
|       return false; | ||||
|     }); | ||||
|  | ||||
| @@ -707,8 +703,6 @@ describe('setup-go', () => { | ||||
|       const toolPath = path.normalize('/cache/go/1.17.5/x64'); | ||||
|       extractTarSpy.mockImplementation(async () => '/some/other/temp/path'); | ||||
|       cacheSpy.mockImplementation(async () => toolPath); | ||||
|       const expectedUrl = | ||||
|         'https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz'; | ||||
|  | ||||
|       await main.run(); | ||||
|  | ||||
| @@ -834,7 +828,7 @@ exclude example.com/thismodule v1.3.0 | ||||
|  | ||||
|     it('reads version from go.mod', async () => { | ||||
|       inputs['go-version-file'] = 'go.mod'; | ||||
|       existsSpy.mockImplementation(path => true); | ||||
|       existsSpy.mockImplementation(() => true); | ||||
|       readFileSpy.mockImplementation(() => Buffer.from(goModContents)); | ||||
|  | ||||
|       await main.run(); | ||||
| @@ -846,7 +840,7 @@ exclude example.com/thismodule v1.3.0 | ||||
|  | ||||
|     it('reads version from .go-version', async () => { | ||||
|       inputs['go-version-file'] = '.go-version'; | ||||
|       existsSpy.mockImplementation(path => true); | ||||
|       existsSpy.mockImplementation(() => true); | ||||
|       readFileSpy.mockImplementation(() => Buffer.from(`1.13.0${osm.EOL}`)); | ||||
|  | ||||
|       await main.run(); | ||||
| @@ -859,7 +853,7 @@ exclude example.com/thismodule v1.3.0 | ||||
|     it('is overwritten by go-version', async () => { | ||||
|       inputs['go-version'] = '1.13.1'; | ||||
|       inputs['go-version-file'] = 'go.mod'; | ||||
|       existsSpy.mockImplementation(path => true); | ||||
|       existsSpy.mockImplementation(() => true); | ||||
|       readFileSpy.mockImplementation(() => Buffer.from(goModContents)); | ||||
|  | ||||
|       await main.run(); | ||||
| @@ -871,7 +865,7 @@ exclude example.com/thismodule v1.3.0 | ||||
|  | ||||
|     it('reports a read failure', async () => { | ||||
|       inputs['go-version-file'] = 'go.mod'; | ||||
|       existsSpy.mockImplementation(path => false); | ||||
|       existsSpy.mockImplementation(() => false); | ||||
|  | ||||
|       await main.run(); | ||||
|  | ||||
|   | ||||
							
								
								
									
										1730
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1730
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1720
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1720
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										47
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										47
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1,16 +1,16 @@ | ||||
| { | ||||
|   "name": "setup-go", | ||||
|   "version": "1.0.0", | ||||
|   "version": "3.3.0", | ||||
|   "lockfileVersion": 2, | ||||
|   "requires": true, | ||||
|   "packages": { | ||||
|     "": { | ||||
|       "name": "setup-go", | ||||
|       "version": "1.0.0", | ||||
|       "version": "3.3.0", | ||||
|       "license": "MIT", | ||||
|       "dependencies": { | ||||
|         "@actions/cache": "^3.0.0", | ||||
|         "@actions/core": "^1.6.0", | ||||
|         "@actions/core": "^1.10.0", | ||||
|         "@actions/exec": "^1.1.0", | ||||
|         "@actions/glob": "^0.2.0", | ||||
|         "@actions/http-client": "^2.0.1", | ||||
| @@ -57,19 +57,20 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@actions/core": { | ||||
|       "version": "1.6.0", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", | ||||
|       "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", | ||||
|       "version": "1.10.0", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", | ||||
|       "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", | ||||
|       "dependencies": { | ||||
|         "@actions/http-client": "^1.0.11" | ||||
|         "@actions/http-client": "^2.0.1", | ||||
|         "uuid": "^8.3.2" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@actions/core/node_modules/@actions/http-client": { | ||||
|       "version": "1.0.11", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", | ||||
|       "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", | ||||
|       "dependencies": { | ||||
|         "tunnel": "0.0.6" | ||||
|     "node_modules/@actions/core/node_modules/uuid": { | ||||
|       "version": "8.3.2", | ||||
|       "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", | ||||
|       "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", | ||||
|       "bin": { | ||||
|         "uuid": "dist/bin/uuid" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@actions/exec": { | ||||
| @@ -4991,20 +4992,18 @@ | ||||
|       } | ||||
|     }, | ||||
|     "@actions/core": { | ||||
|       "version": "1.6.0", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", | ||||
|       "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", | ||||
|       "version": "1.10.0", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", | ||||
|       "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", | ||||
|       "requires": { | ||||
|         "@actions/http-client": "^1.0.11" | ||||
|         "@actions/http-client": "^2.0.1", | ||||
|         "uuid": "^8.3.2" | ||||
|       }, | ||||
|       "dependencies": { | ||||
|         "@actions/http-client": { | ||||
|           "version": "1.0.11", | ||||
|           "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", | ||||
|           "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", | ||||
|           "requires": { | ||||
|             "tunnel": "0.0.6" | ||||
|           } | ||||
|         "uuid": { | ||||
|           "version": "8.3.2", | ||||
|           "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", | ||||
|           "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "setup-go", | ||||
|   "version": "1.0.0", | ||||
|   "version": "3.3.0", | ||||
|   "private": true, | ||||
|   "description": "setup go action", | ||||
|   "main": "lib/setup-go.js", | ||||
| @@ -24,7 +24,7 @@ | ||||
|   "license": "MIT", | ||||
|   "dependencies": { | ||||
|     "@actions/cache": "^3.0.0", | ||||
|     "@actions/core": "^1.6.0", | ||||
|     "@actions/core": "^1.10.0", | ||||
|     "@actions/exec": "^1.1.0", | ||||
|     "@actions/glob": "^0.2.0", | ||||
|     "@actions/http-client": "^2.0.1", | ||||
|   | ||||
| @@ -9,12 +9,12 @@ import {PackageManagerInfo} from './package-managers'; | ||||
| import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils'; | ||||
|  | ||||
| export const restoreCache = async ( | ||||
|   versionSpec: string, | ||||
|   packageManager: string, | ||||
|   cacheDependencyPath?: string | ||||
| ) => { | ||||
|   const packageManagerInfo = await getPackageManagerInfo(packageManager); | ||||
|   const platform = process.env.RUNNER_OS; | ||||
|   const versionSpec = core.getInput('go-version'); | ||||
|  | ||||
|   const cachePaths = await getCacheDirectoryPath(packageManagerInfo); | ||||
|  | ||||
|   | ||||
| @@ -16,7 +16,14 @@ export async function run() { | ||||
|   try { | ||||
|     await cachePackages(); | ||||
|   } catch (error) { | ||||
|     core.setFailed(error.message); | ||||
|     let message = 'Unknown error!'; | ||||
|     if (error instanceof Error) { | ||||
|       message = error.message; | ||||
|     } | ||||
|     if (typeof error === 'string') { | ||||
|       message = error; | ||||
|     } | ||||
|     core.setFailed(message); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @@ -40,7 +47,8 @@ const cachePackages = async () => { | ||||
|   ); | ||||
|  | ||||
|   if (nonExistingPaths.length === cachePaths.length) { | ||||
|     throw new Error(`There are no cache folders on the disk`); | ||||
|     core.warning('There are no cache folders on the disk'); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   if (nonExistingPaths.length) { | ||||
| @@ -65,7 +73,7 @@ const cachePackages = async () => { | ||||
|   core.info(`Cache saved with the key: ${primaryKey}`); | ||||
| }; | ||||
|  | ||||
| export function logWarning(message: string): void { | ||||
| function logWarning(message: string): void { | ||||
|   const warningPrefix = '[warning]'; | ||||
|   core.info(`${warningPrefix}${message}`); | ||||
| } | ||||
|   | ||||
| @@ -56,7 +56,7 @@ export async function run() { | ||||
|     if (cache && isCacheFeatureAvailable()) { | ||||
|       const packageManager = 'default'; | ||||
|       const cacheDependencyPath = core.getInput('cache-dependency-path'); | ||||
|       await restoreCache(packageManager, cacheDependencyPath); | ||||
|       await restoreCache(versionSpec, packageManager, cacheDependencyPath); | ||||
|     } | ||||
|  | ||||
|     // add problem matchers | ||||
|   | ||||
		Reference in New Issue
	
	Block a user