mirror of
				https://github.com/actions/setup-go.git
				synced 2025-10-30 23:10:30 +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" | name: "@actions/core" | ||||||
| version: 1.6.0 | version: 1.10.0 | ||||||
| type: npm | type: npm | ||||||
| summary: Actions core lib | summary: Actions core lib | ||||||
| homepage: https://github.com/actions/toolkit/tree/main/packages/core | 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 | ## 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 infoSpy = jest.spyOn(core, 'info'); | ||||||
|   let setOutputSpy = jest.spyOn(core, 'setOutput'); |   let setOutputSpy = jest.spyOn(core, 'setOutput'); | ||||||
|  |  | ||||||
|  |   const versionSpec = '1.13.1'; | ||||||
|   const packageManager = 'default'; |   const packageManager = 'default'; | ||||||
|   const cacheDependencyPath = 'path'; |   const cacheDependencyPath = 'path'; | ||||||
|  |  | ||||||
| @@ -40,7 +41,11 @@ describe('restoreCache', () => { | |||||||
|  |  | ||||||
|     //Act + Assert |     //Act + Assert | ||||||
|     expect(async () => { |     expect(async () => { | ||||||
|       await cacheRestore.restoreCache(packageManager, cacheDependencyPath); |       await cacheRestore.restoreCache( | ||||||
|  |         versionSpec, | ||||||
|  |         packageManager, | ||||||
|  |         cacheDependencyPath | ||||||
|  |       ); | ||||||
|     }).rejects.toThrowError( |     }).rejects.toThrowError( | ||||||
|       'Some specified paths were not resolved, unable to cache dependencies.' |       'Some specified paths were not resolved, unable to cache dependencies.' | ||||||
|     ); |     ); | ||||||
| @@ -61,7 +66,11 @@ describe('restoreCache', () => { | |||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     //Act + Assert |     //Act + Assert | ||||||
|     await cacheRestore.restoreCache(packageManager, cacheDependencyPath); |     await cacheRestore.restoreCache( | ||||||
|  |       versionSpec, | ||||||
|  |       packageManager, | ||||||
|  |       cacheDependencyPath | ||||||
|  |     ); | ||||||
|     expect(infoSpy).toBeCalledWith(`Cache is not found`); |     expect(infoSpy).toBeCalledWith(`Cache is not found`); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
| @@ -80,7 +89,11 @@ describe('restoreCache', () => { | |||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     //Act + Assert |     //Act + Assert | ||||||
|     await cacheRestore.restoreCache(packageManager, cacheDependencyPath); |     await cacheRestore.restoreCache( | ||||||
|  |       versionSpec, | ||||||
|  |       packageManager, | ||||||
|  |       cacheDependencyPath | ||||||
|  |     ); | ||||||
|     expect(setOutputSpy).toBeCalledWith('cache-hit', true); |     expect(setOutputSpy).toBeCalledWith('cache-hit', true); | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -295,7 +295,6 @@ describe('setup-go', () => { | |||||||
|     findSpy.mockImplementation(() => toolPath); |     findSpy.mockImplementation(() => toolPath); | ||||||
|     await main.run(); |     await main.run(); | ||||||
|  |  | ||||||
|     let expPath = path.join(toolPath, 'bin'); |  | ||||||
|     expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); |     expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
| @@ -462,9 +461,6 @@ describe('setup-go', () => { | |||||||
|     inputs['go-version'] = versionSpec; |     inputs['go-version'] = versionSpec; | ||||||
|     inputs['token'] = 'faketoken'; |     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 |     // ... but not in the local cache | ||||||
|     findSpy.mockImplementation(() => ''); |     findSpy.mockImplementation(() => ''); | ||||||
|  |  | ||||||
| @@ -526,7 +522,7 @@ describe('setup-go', () => { | |||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     mkdirpSpy.mockImplementation(async () => {}); |     mkdirpSpy.mockImplementation(async () => {}); | ||||||
|     existsSpy.mockImplementation(path => { |     existsSpy.mockImplementation(() => { | ||||||
|       return false; |       return false; | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
| @@ -707,8 +703,6 @@ describe('setup-go', () => { | |||||||
|       const toolPath = path.normalize('/cache/go/1.17.5/x64'); |       const toolPath = path.normalize('/cache/go/1.17.5/x64'); | ||||||
|       extractTarSpy.mockImplementation(async () => '/some/other/temp/path'); |       extractTarSpy.mockImplementation(async () => '/some/other/temp/path'); | ||||||
|       cacheSpy.mockImplementation(async () => toolPath); |       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(); |       await main.run(); | ||||||
|  |  | ||||||
| @@ -834,7 +828,7 @@ exclude example.com/thismodule v1.3.0 | |||||||
|  |  | ||||||
|     it('reads version from go.mod', async () => { |     it('reads version from go.mod', async () => { | ||||||
|       inputs['go-version-file'] = 'go.mod'; |       inputs['go-version-file'] = 'go.mod'; | ||||||
|       existsSpy.mockImplementation(path => true); |       existsSpy.mockImplementation(() => true); | ||||||
|       readFileSpy.mockImplementation(() => Buffer.from(goModContents)); |       readFileSpy.mockImplementation(() => Buffer.from(goModContents)); | ||||||
|  |  | ||||||
|       await main.run(); |       await main.run(); | ||||||
| @@ -846,7 +840,7 @@ exclude example.com/thismodule v1.3.0 | |||||||
|  |  | ||||||
|     it('reads version from .go-version', async () => { |     it('reads version from .go-version', async () => { | ||||||
|       inputs['go-version-file'] = '.go-version'; |       inputs['go-version-file'] = '.go-version'; | ||||||
|       existsSpy.mockImplementation(path => true); |       existsSpy.mockImplementation(() => true); | ||||||
|       readFileSpy.mockImplementation(() => Buffer.from(`1.13.0${osm.EOL}`)); |       readFileSpy.mockImplementation(() => Buffer.from(`1.13.0${osm.EOL}`)); | ||||||
|  |  | ||||||
|       await main.run(); |       await main.run(); | ||||||
| @@ -859,7 +853,7 @@ exclude example.com/thismodule v1.3.0 | |||||||
|     it('is overwritten by go-version', async () => { |     it('is overwritten by go-version', async () => { | ||||||
|       inputs['go-version'] = '1.13.1'; |       inputs['go-version'] = '1.13.1'; | ||||||
|       inputs['go-version-file'] = 'go.mod'; |       inputs['go-version-file'] = 'go.mod'; | ||||||
|       existsSpy.mockImplementation(path => true); |       existsSpy.mockImplementation(() => true); | ||||||
|       readFileSpy.mockImplementation(() => Buffer.from(goModContents)); |       readFileSpy.mockImplementation(() => Buffer.from(goModContents)); | ||||||
|  |  | ||||||
|       await main.run(); |       await main.run(); | ||||||
| @@ -871,7 +865,7 @@ exclude example.com/thismodule v1.3.0 | |||||||
|  |  | ||||||
|     it('reports a read failure', async () => { |     it('reports a read failure', async () => { | ||||||
|       inputs['go-version-file'] = 'go.mod'; |       inputs['go-version-file'] = 'go.mod'; | ||||||
|       existsSpy.mockImplementation(path => false); |       existsSpy.mockImplementation(() => false); | ||||||
|  |  | ||||||
|       await main.run(); |       await main.run(); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										1726
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1726
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1716
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1716
									
								
								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", |   "name": "setup-go", | ||||||
|   "version": "1.0.0", |   "version": "3.3.0", | ||||||
|   "lockfileVersion": 2, |   "lockfileVersion": 2, | ||||||
|   "requires": true, |   "requires": true, | ||||||
|   "packages": { |   "packages": { | ||||||
|     "": { |     "": { | ||||||
|       "name": "setup-go", |       "name": "setup-go", | ||||||
|       "version": "1.0.0", |       "version": "3.3.0", | ||||||
|       "license": "MIT", |       "license": "MIT", | ||||||
|       "dependencies": { |       "dependencies": { | ||||||
|         "@actions/cache": "^3.0.0", |         "@actions/cache": "^3.0.0", | ||||||
|         "@actions/core": "^1.6.0", |         "@actions/core": "^1.10.0", | ||||||
|         "@actions/exec": "^1.1.0", |         "@actions/exec": "^1.1.0", | ||||||
|         "@actions/glob": "^0.2.0", |         "@actions/glob": "^0.2.0", | ||||||
|         "@actions/http-client": "^2.0.1", |         "@actions/http-client": "^2.0.1", | ||||||
| @@ -57,19 +57,20 @@ | |||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "node_modules/@actions/core": { |     "node_modules/@actions/core": { | ||||||
|       "version": "1.6.0", |       "version": "1.10.0", | ||||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", |       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", | ||||||
|       "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", |       "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", | ||||||
|       "dependencies": { |       "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": { |     "node_modules/@actions/core/node_modules/uuid": { | ||||||
|       "version": "1.0.11", |       "version": "8.3.2", | ||||||
|       "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", |       "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", | ||||||
|       "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", |       "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", | ||||||
|       "dependencies": { |       "bin": { | ||||||
|         "tunnel": "0.0.6" |         "uuid": "dist/bin/uuid" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "node_modules/@actions/exec": { |     "node_modules/@actions/exec": { | ||||||
| @@ -4991,20 +4992,18 @@ | |||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "@actions/core": { |     "@actions/core": { | ||||||
|       "version": "1.6.0", |       "version": "1.10.0", | ||||||
|       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", |       "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", | ||||||
|       "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", |       "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", | ||||||
|       "requires": { |       "requires": { | ||||||
|         "@actions/http-client": "^1.0.11" |         "@actions/http-client": "^2.0.1", | ||||||
|  |         "uuid": "^8.3.2" | ||||||
|       }, |       }, | ||||||
|       "dependencies": { |       "dependencies": { | ||||||
|         "@actions/http-client": { |         "uuid": { | ||||||
|           "version": "1.0.11", |           "version": "8.3.2", | ||||||
|           "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", |           "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", | ||||||
|           "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", |           "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" | ||||||
|           "requires": { |  | ||||||
|             "tunnel": "0.0.6" |  | ||||||
|           } |  | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "setup-go", |   "name": "setup-go", | ||||||
|   "version": "1.0.0", |   "version": "3.3.0", | ||||||
|   "private": true, |   "private": true, | ||||||
|   "description": "setup go action", |   "description": "setup go action", | ||||||
|   "main": "lib/setup-go.js", |   "main": "lib/setup-go.js", | ||||||
| @@ -24,7 +24,7 @@ | |||||||
|   "license": "MIT", |   "license": "MIT", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@actions/cache": "^3.0.0", |     "@actions/cache": "^3.0.0", | ||||||
|     "@actions/core": "^1.6.0", |     "@actions/core": "^1.10.0", | ||||||
|     "@actions/exec": "^1.1.0", |     "@actions/exec": "^1.1.0", | ||||||
|     "@actions/glob": "^0.2.0", |     "@actions/glob": "^0.2.0", | ||||||
|     "@actions/http-client": "^2.0.1", |     "@actions/http-client": "^2.0.1", | ||||||
|   | |||||||
| @@ -9,12 +9,12 @@ import {PackageManagerInfo} from './package-managers'; | |||||||
| import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils'; | import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils'; | ||||||
|  |  | ||||||
| export const restoreCache = async ( | export const restoreCache = async ( | ||||||
|  |   versionSpec: string, | ||||||
|   packageManager: string, |   packageManager: string, | ||||||
|   cacheDependencyPath?: string |   cacheDependencyPath?: string | ||||||
| ) => { | ) => { | ||||||
|   const packageManagerInfo = await getPackageManagerInfo(packageManager); |   const packageManagerInfo = await getPackageManagerInfo(packageManager); | ||||||
|   const platform = process.env.RUNNER_OS; |   const platform = process.env.RUNNER_OS; | ||||||
|   const versionSpec = core.getInput('go-version'); |  | ||||||
|  |  | ||||||
|   const cachePaths = await getCacheDirectoryPath(packageManagerInfo); |   const cachePaths = await getCacheDirectoryPath(packageManagerInfo); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,7 +16,14 @@ export async function run() { | |||||||
|   try { |   try { | ||||||
|     await cachePackages(); |     await cachePackages(); | ||||||
|   } catch (error) { |   } 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) { |   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) { |   if (nonExistingPaths.length) { | ||||||
| @@ -65,7 +73,7 @@ const cachePackages = async () => { | |||||||
|   core.info(`Cache saved with the key: ${primaryKey}`); |   core.info(`Cache saved with the key: ${primaryKey}`); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| export function logWarning(message: string): void { | function logWarning(message: string): void { | ||||||
|   const warningPrefix = '[warning]'; |   const warningPrefix = '[warning]'; | ||||||
|   core.info(`${warningPrefix}${message}`); |   core.info(`${warningPrefix}${message}`); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -56,7 +56,7 @@ export async function run() { | |||||||
|     if (cache && isCacheFeatureAvailable()) { |     if (cache && isCacheFeatureAvailable()) { | ||||||
|       const packageManager = 'default'; |       const packageManager = 'default'; | ||||||
|       const cacheDependencyPath = core.getInput('cache-dependency-path'); |       const cacheDependencyPath = core.getInput('cache-dependency-path'); | ||||||
|       await restoreCache(packageManager, cacheDependencyPath); |       await restoreCache(versionSpec, packageManager, cacheDependencyPath); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // add problem matchers |     // add problem matchers | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user