mirror of
				https://github.com/actions/setup-go.git
				synced 2025-10-31 15:50:33 +00:00 
			
		
		
		
	Compare commits
	
		
			33 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 78bd24e01a | ||
|   | 6613fc89fc | ||
|   | 202a594963 | ||
|   | 0dbc7e4965 | ||
|   | 2091469f9f | ||
|   | f32657ccaf | ||
|   | cec6ecefb4 | ||
|   | e36ce1d6cf | ||
|   | 89c89c5036 | ||
|   | 0a62a734da | ||
|   | 5156bc5dd3 | ||
|   | 7837b03976 | ||
|   | 74c8095946 | ||
|   | 34223181a5 | ||
|   | 1c06f0e82e | ||
|   | a030287975 | ||
|   | 3349559e91 | ||
|   | dec4fc5647 | ||
|   | 262468e92f | ||
|   | 4e8106ca18 | ||
|   | 93ddff5bef | ||
|   | 3d89e603f2 | ||
|   | 1fea44b3f0 | ||
|   | 3e014ec8a4 | ||
|   | 75899f8cdf | ||
|   | 1fdcb9b160 | ||
|   | 3d0e3826ed | ||
|   | 9c31f591e9 | ||
|   | e0b6a4d694 | ||
|   | 1295b8c552 | ||
|   | 9b1c41166a | ||
|   | 655555d319 | ||
|   | 2096a2c66a | 
							
								
								
									
										9
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							| @@ -25,7 +25,7 @@ jobs: | |||||||
|         go-version: ^1.13.6 |         go-version: ^1.13.6 | ||||||
|  |  | ||||||
|     - name: validate version  |     - name: validate version  | ||||||
|       run: go version | grep "go1.13." |       run: go version | grep "go1." | ||||||
|  |  | ||||||
|     - name: setup-go 1.13 |     - name: setup-go 1.13 | ||||||
|       uses: ./ |       uses: ./ | ||||||
| @@ -42,3 +42,10 @@ jobs: | |||||||
|  |  | ||||||
|     - name: validate version  |     - name: validate version  | ||||||
|       run: go version | grep "go1.12.9" |       run: go version | grep "go1.12.9" | ||||||
|  |  | ||||||
|  |     - name: dump env | ||||||
|  |       shell: bash | ||||||
|  |       run: | | ||||||
|  |         echo $PATH | ||||||
|  |         echo go versions in tool cache:  | ||||||
|  |         echo $(ls $RUNNER_TOOL_CACHE/go)        | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							| @@ -34,5 +34,5 @@ jobs: | |||||||
|       run: npm test |       run: npm test | ||||||
|  |  | ||||||
|     - name: audit packages |     - name: audit packages | ||||||
|       run: npm audit --audit-level=moderate |       run: npm audit --audit-level=high | ||||||
|       if: matrix.operating-system == 'ubuntu-latest' |       if: matrix.operating-system == 'ubuntu-latest' | ||||||
| @@ -1,15 +1,17 @@ | |||||||
| import * as tc from '@actions/tool-cache'; |  | ||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
| import fs = require('fs'); | import * as io from '@actions/io'; | ||||||
|  | import * as tc from '@actions/tool-cache'; | ||||||
|  | import fs from 'fs'; | ||||||
|  | import cp from 'child_process'; | ||||||
| import osm = require('os'); | import osm = require('os'); | ||||||
| import path = require('path'); | import path from 'path'; | ||||||
| import {run} from '../src/main'; | import * as main from '../src/main'; | ||||||
| import * as httpm from '@actions/http-client'; |  | ||||||
| import * as im from '../src/installer'; | import * as im from '../src/installer'; | ||||||
| import * as sys from '../src/system'; |  | ||||||
| import {ITypedResponse} from '@actions/http-client/interfaces'; |  | ||||||
|  |  | ||||||
| let goJsonData = require('./data/golang-dl.json'); | let goJsonData = require('./data/golang-dl.json'); | ||||||
|  | let matchers = require('../matchers.json'); | ||||||
|  | let matcherPattern = matchers.problemMatcher[0].pattern[0]; | ||||||
|  | let matcherRegExp = new RegExp(matcherPattern.regexp); | ||||||
|  |  | ||||||
| describe('setup-go', () => { | describe('setup-go', () => { | ||||||
|   let inputs = {} as any; |   let inputs = {} as any; | ||||||
| @@ -25,6 +27,11 @@ describe('setup-go', () => { | |||||||
|   let dlSpy: jest.SpyInstance; |   let dlSpy: jest.SpyInstance; | ||||||
|   let exSpy: jest.SpyInstance; |   let exSpy: jest.SpyInstance; | ||||||
|   let cacheSpy: jest.SpyInstance; |   let cacheSpy: jest.SpyInstance; | ||||||
|  |   let dbgSpy: jest.SpyInstance; | ||||||
|  |   let whichSpy: jest.SpyInstance; | ||||||
|  |   let existsSpy: jest.SpyInstance; | ||||||
|  |   let mkdirpSpy: jest.SpyInstance; | ||||||
|  |   let execSpy: jest.SpyInstance; | ||||||
|  |  | ||||||
|   beforeEach(() => { |   beforeEach(() => { | ||||||
|     // @actions/core |     // @actions/core | ||||||
| @@ -32,12 +39,13 @@ describe('setup-go', () => { | |||||||
|     inSpy = jest.spyOn(core, 'getInput'); |     inSpy = jest.spyOn(core, 'getInput'); | ||||||
|     inSpy.mockImplementation(name => inputs[name]); |     inSpy.mockImplementation(name => inputs[name]); | ||||||
|  |  | ||||||
|     // node 'os' |     // node | ||||||
|     os = {}; |     os = {}; | ||||||
|     platSpy = jest.spyOn(osm, 'platform'); |     platSpy = jest.spyOn(osm, 'platform'); | ||||||
|     platSpy.mockImplementation(() => os['platform']); |     platSpy.mockImplementation(() => os['platform']); | ||||||
|     archSpy = jest.spyOn(osm, 'arch'); |     archSpy = jest.spyOn(osm, 'arch'); | ||||||
|     archSpy.mockImplementation(() => os['arch']); |     archSpy.mockImplementation(() => os['arch']); | ||||||
|  |     execSpy = jest.spyOn(cp, 'execSync'); | ||||||
|  |  | ||||||
|     // @actions/tool-cache |     // @actions/tool-cache | ||||||
|     findSpy = jest.spyOn(tc, 'find'); |     findSpy = jest.spyOn(tc, 'find'); | ||||||
| @@ -46,9 +54,15 @@ describe('setup-go', () => { | |||||||
|     cacheSpy = jest.spyOn(tc, 'cacheDir'); |     cacheSpy = jest.spyOn(tc, 'cacheDir'); | ||||||
|     getSpy = jest.spyOn(im, 'getVersions'); |     getSpy = jest.spyOn(im, 'getVersions'); | ||||||
|  |  | ||||||
|  |     // io | ||||||
|  |     whichSpy = jest.spyOn(io, 'which'); | ||||||
|  |     existsSpy = jest.spyOn(fs, 'existsSync'); | ||||||
|  |     mkdirpSpy = jest.spyOn(io, 'mkdirP'); | ||||||
|  |  | ||||||
|     // writes |     // writes | ||||||
|     cnSpy = jest.spyOn(process.stdout, 'write'); |     cnSpy = jest.spyOn(process.stdout, 'write'); | ||||||
|     logSpy = jest.spyOn(console, 'log'); |     logSpy = jest.spyOn(console, 'log'); | ||||||
|  |     dbgSpy = jest.spyOn(main, '_debug'); | ||||||
|     getSpy.mockImplementation(() => <im.IGoVersion[]>goJsonData); |     getSpy.mockImplementation(() => <im.IGoVersion[]>goJsonData); | ||||||
|     cnSpy.mockImplementation(line => { |     cnSpy.mockImplementation(line => { | ||||||
|       // uncomment to debug |       // uncomment to debug | ||||||
| @@ -58,11 +72,16 @@ describe('setup-go', () => { | |||||||
|       // uncomment to debug |       // uncomment to debug | ||||||
|       // process.stderr.write('log:' + line + '\n'); |       // process.stderr.write('log:' + line + '\n'); | ||||||
|     }); |     }); | ||||||
|  |     dbgSpy.mockImplementation(msg => { | ||||||
|  |       // uncomment to see debug output | ||||||
|  |       // process.stderr.write(msg + '\n'); | ||||||
|  |     }); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   afterEach(() => { |   afterEach(() => { | ||||||
|     jest.resetAllMocks(); |     jest.resetAllMocks(); | ||||||
|     jest.clearAllMocks(); |     jest.clearAllMocks(); | ||||||
|  |     //jest.restoreAllMocks(); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   afterAll(async () => {}, 100000); |   afterAll(async () => {}, 100000); | ||||||
| @@ -164,7 +183,7 @@ describe('setup-go', () => { | |||||||
|  |  | ||||||
|     let toolPath = path.normalize('/cache/go/1.13.0/x64'); |     let toolPath = path.normalize('/cache/go/1.13.0/x64'); | ||||||
|     findSpy.mockImplementation(() => toolPath); |     findSpy.mockImplementation(() => toolPath); | ||||||
|     await run(); |     await main.run(); | ||||||
|  |  | ||||||
|     expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec 1.13.0`); |     expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec 1.13.0`); | ||||||
|   }); |   }); | ||||||
| @@ -176,7 +195,7 @@ describe('setup-go', () => { | |||||||
|  |  | ||||||
|     let toolPath = path.normalize('/cache/go/1.13.0/x64'); |     let toolPath = path.normalize('/cache/go/1.13.0/x64'); | ||||||
|     findSpy.mockImplementation(() => toolPath); |     findSpy.mockImplementation(() => toolPath); | ||||||
|     await run(); |     await main.run(); | ||||||
|  |  | ||||||
|     expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec 1.13.0`); |     expect(logSpy).toHaveBeenCalledWith(`Setup go stable version spec 1.13.0`); | ||||||
|   }); |   }); | ||||||
| @@ -186,7 +205,7 @@ describe('setup-go', () => { | |||||||
|  |  | ||||||
|     let toolPath = path.normalize('/cache/go/1.13.0/x64'); |     let toolPath = path.normalize('/cache/go/1.13.0/x64'); | ||||||
|     findSpy.mockImplementation(() => toolPath); |     findSpy.mockImplementation(() => toolPath); | ||||||
|     await run(); |     await main.run(); | ||||||
|  |  | ||||||
|     let expPath = path.join(toolPath, 'bin'); |     let expPath = path.join(toolPath, 'bin'); | ||||||
|   }); |   }); | ||||||
| @@ -195,7 +214,7 @@ describe('setup-go', () => { | |||||||
|     inputs['go-version'] = '1.13.0'; |     inputs['go-version'] = '1.13.0'; | ||||||
|     let toolPath = path.normalize('/cache/go/1.13.0/x64'); |     let toolPath = path.normalize('/cache/go/1.13.0/x64'); | ||||||
|     findSpy.mockImplementation(() => toolPath); |     findSpy.mockImplementation(() => toolPath); | ||||||
|     await run(); |     await main.run(); | ||||||
|  |  | ||||||
|     let expPath = path.join(toolPath, 'bin'); |     let expPath = path.join(toolPath, 'bin'); | ||||||
|     expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); |     expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); | ||||||
| @@ -208,7 +227,7 @@ describe('setup-go', () => { | |||||||
|     findSpy.mockImplementation(() => { |     findSpy.mockImplementation(() => { | ||||||
|       throw new Error(errMsg); |       throw new Error(errMsg); | ||||||
|     }); |     }); | ||||||
|     await run(); |     await main.run(); | ||||||
|     expect(cnSpy).toHaveBeenCalledWith('::error::' + errMsg + osm.EOL); |     expect(cnSpy).toHaveBeenCalledWith('::error::' + errMsg + osm.EOL); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
| @@ -223,7 +242,7 @@ describe('setup-go', () => { | |||||||
|     let toolPath = path.normalize('/cache/go/1.13.0/x64'); |     let toolPath = path.normalize('/cache/go/1.13.0/x64'); | ||||||
|     exSpy.mockImplementation(() => '/some/other/temp/path'); |     exSpy.mockImplementation(() => '/some/other/temp/path'); | ||||||
|     cacheSpy.mockImplementation(() => toolPath); |     cacheSpy.mockImplementation(() => toolPath); | ||||||
|     await run(); |     await main.run(); | ||||||
|  |  | ||||||
|     let expPath = path.join(toolPath, 'bin'); |     let expPath = path.join(toolPath, 'bin'); | ||||||
|  |  | ||||||
| @@ -239,7 +258,7 @@ describe('setup-go', () => { | |||||||
|     inputs['go-version'] = '9.99.9'; |     inputs['go-version'] = '9.99.9'; | ||||||
|  |  | ||||||
|     findSpy.mockImplementation(() => ''); |     findSpy.mockImplementation(() => ''); | ||||||
|     await run(); |     await main.run(); | ||||||
|  |  | ||||||
|     expect(cnSpy).toHaveBeenCalledWith( |     expect(cnSpy).toHaveBeenCalledWith( | ||||||
|       `::error::Could not find a version that satisfied version spec: 9.99.9${osm.EOL}` |       `::error::Could not find a version that satisfied version spec: 9.99.9${osm.EOL}` | ||||||
| @@ -257,7 +276,7 @@ describe('setup-go', () => { | |||||||
|     dlSpy.mockImplementation(() => { |     dlSpy.mockImplementation(() => { | ||||||
|       throw new Error(errMsg); |       throw new Error(errMsg); | ||||||
|     }); |     }); | ||||||
|     await run(); |     await main.run(); | ||||||
|  |  | ||||||
|     expect(cnSpy).toHaveBeenCalledWith( |     expect(cnSpy).toHaveBeenCalledWith( | ||||||
|       `::error::Failed to download version 1.13.1: Error: ${errMsg}${osm.EOL}` |       `::error::Failed to download version 1.13.1: Error: ${errMsg}${osm.EOL}` | ||||||
| @@ -273,13 +292,133 @@ describe('setup-go', () => { | |||||||
|  |  | ||||||
|     findSpy.mockImplementation(() => ''); |     findSpy.mockImplementation(() => ''); | ||||||
|     getSpy.mockImplementation(() => null); |     getSpy.mockImplementation(() => null); | ||||||
|     await run(); |     await main.run(); | ||||||
|  |  | ||||||
|     expect(cnSpy).toHaveBeenCalledWith( |     expect(cnSpy).toHaveBeenCalledWith( | ||||||
|       `::error::Failed to download version 1.13.1: Error: golang download url did not return results${osm.EOL}` |       `::error::Failed to download version 1.13.1: Error: golang download url did not return results${osm.EOL}` | ||||||
|     ); |     ); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|  |   it('does not add BIN if go is not in path', async () => { | ||||||
|  |     whichSpy.mockImplementation(async () => { | ||||||
|  |       return ''; | ||||||
|  |     }); | ||||||
|  |     let added = await main.addBinToPath(); | ||||||
|  |     expect(added).toBeFalsy(); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('adds bin if dir not exists', async () => { | ||||||
|  |     whichSpy.mockImplementation(async () => { | ||||||
|  |       return '/usr/local/go/bin/go'; | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     execSpy.mockImplementation(() => { | ||||||
|  |       return '/Users/testuser/go'; | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     mkdirpSpy.mockImplementation(async () => {}); | ||||||
|  |     existsSpy.mockImplementation(path => { | ||||||
|  |       return false; | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     let added = await main.addBinToPath(); | ||||||
|  |     expect(added).toBeTruthy; | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   interface Annotation { | ||||||
|  |     file: string; | ||||||
|  |     line: number; | ||||||
|  |     column: number; | ||||||
|  |     message: string; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // | ||||||
|  |   // problem matcher regex pattern tests | ||||||
|  |  | ||||||
|  |   function testMatch(line: string): Annotation { | ||||||
|  |     let annotation = <Annotation>{}; | ||||||
|  |  | ||||||
|  |     let match = matcherRegExp.exec(line); | ||||||
|  |     if (match) { | ||||||
|  |       annotation.line = parseInt(match[matcherPattern.line], 10); | ||||||
|  |       annotation.column = parseInt(match[matcherPattern.column], 10); | ||||||
|  |       annotation.file = match[matcherPattern.file].trim(); | ||||||
|  |       annotation.message = match[matcherPattern.message].trim(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return annotation; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   it('matches on relative unix path', async () => { | ||||||
|  |     let line = './main.go:13:2: undefined: fmt.Printl'; | ||||||
|  |     let annotation = testMatch(line); | ||||||
|  |     expect(annotation).toBeDefined(); | ||||||
|  |     expect(annotation.line).toBe(13); | ||||||
|  |     expect(annotation.column).toBe(2); | ||||||
|  |     expect(annotation.file).toBe('./main.go'); | ||||||
|  |     expect(annotation.message).toBe('undefined: fmt.Printl'); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('matches on unix path up the tree', async () => { | ||||||
|  |     let line = '../main.go:13:2: undefined: fmt.Printl'; | ||||||
|  |     let annotation = testMatch(line); | ||||||
|  |     expect(annotation).toBeDefined(); | ||||||
|  |     expect(annotation.line).toBe(13); | ||||||
|  |     expect(annotation.column).toBe(2); | ||||||
|  |     expect(annotation.file).toBe('../main.go'); | ||||||
|  |     expect(annotation.message).toBe('undefined: fmt.Printl'); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('matches on rooted unix path', async () => { | ||||||
|  |     let line = '/assert.go:4:1: missing return at end of function'; | ||||||
|  |     let annotation = testMatch(line); | ||||||
|  |     expect(annotation).toBeDefined(); | ||||||
|  |     expect(annotation.line).toBe(4); | ||||||
|  |     expect(annotation.column).toBe(1); | ||||||
|  |     expect(annotation.file).toBe('/assert.go'); | ||||||
|  |     expect(annotation.message).toBe('missing return at end of function'); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('matches on unix path with spaces', async () => { | ||||||
|  |     let line = '   ./assert.go:5:2: missing return at end of function   '; | ||||||
|  |     let annotation = testMatch(line); | ||||||
|  |     expect(annotation).toBeDefined(); | ||||||
|  |     expect(annotation.line).toBe(5); | ||||||
|  |     expect(annotation.column).toBe(2); | ||||||
|  |     expect(annotation.file).toBe('./assert.go'); | ||||||
|  |     expect(annotation.message).toBe('missing return at end of function'); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('matches on unix path with tabs', async () => { | ||||||
|  |     let line = '\t./assert.go:5:2: missing return at end of function   '; | ||||||
|  |     let annotation = testMatch(line); | ||||||
|  |     expect(annotation).toBeDefined(); | ||||||
|  |     expect(annotation.line).toBe(5); | ||||||
|  |     expect(annotation.column).toBe(2); | ||||||
|  |     expect(annotation.file).toBe('./assert.go'); | ||||||
|  |     expect(annotation.message).toBe('missing return at end of function'); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('matches on relative windows path', async () => { | ||||||
|  |     let line = '.\\main.go:13:2: undefined: fmt.Printl'; | ||||||
|  |     let annotation = testMatch(line); | ||||||
|  |     expect(annotation).toBeDefined(); | ||||||
|  |     expect(annotation.line).toBe(13); | ||||||
|  |     expect(annotation.column).toBe(2); | ||||||
|  |     expect(annotation.file).toBe('.\\main.go'); | ||||||
|  |     expect(annotation.message).toBe('undefined: fmt.Printl'); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('matches on windows path up the tree', async () => { | ||||||
|  |     let line = '..\\main.go:13:2: undefined: fmt.Printl'; | ||||||
|  |     let annotation = testMatch(line); | ||||||
|  |     expect(annotation).toBeDefined(); | ||||||
|  |     expect(annotation.line).toBe(13); | ||||||
|  |     expect(annotation.column).toBe(2); | ||||||
|  |     expect(annotation.file).toBe('..\\main.go'); | ||||||
|  |     expect(annotation.message).toBe('undefined: fmt.Printl'); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|   // 1.13.1 => 1.13.1 |   // 1.13.1 => 1.13.1 | ||||||
|   // 1.13 => 1.13.0 |   // 1.13 => 1.13.0 | ||||||
|   // 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1 |   // 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1 | ||||||
|   | |||||||
							
								
								
									
										309
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										309
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -1274,11 +1274,17 @@ var __importStar = (this && this.__importStar) || function (mod) { | |||||||
|     result["default"] = mod; |     result["default"] = mod; | ||||||
|     return result; |     return result; | ||||||
| }; | }; | ||||||
|  | var __importDefault = (this && this.__importDefault) || function (mod) { | ||||||
|  |     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||||
|  | }; | ||||||
| Object.defineProperty(exports, "__esModule", { value: true }); | Object.defineProperty(exports, "__esModule", { value: true }); | ||||||
| const core = __importStar(__webpack_require__(470)); | const core = __importStar(__webpack_require__(470)); | ||||||
|  | const io = __importStar(__webpack_require__(1)); | ||||||
| const tc = __importStar(__webpack_require__(533)); | const tc = __importStar(__webpack_require__(533)); | ||||||
| const installer = __importStar(__webpack_require__(749)); | const installer = __importStar(__webpack_require__(749)); | ||||||
| const path = __importStar(__webpack_require__(622)); | const path_1 = __importDefault(__webpack_require__(622)); | ||||||
|  | const child_process_1 = __importDefault(__webpack_require__(129)); | ||||||
|  | const fs_1 = __importDefault(__webpack_require__(747)); | ||||||
| function run() { | function run() { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         try { |         try { | ||||||
| @@ -1300,16 +1306,26 @@ function run() { | |||||||
|                 } |                 } | ||||||
|                 if (installDir) { |                 if (installDir) { | ||||||
|                     core.exportVariable('GOROOT', installDir); |                     core.exportVariable('GOROOT', installDir); | ||||||
|                     core.addPath(path.join(installDir, 'bin')); |                     core.addPath(path_1.default.join(installDir, 'bin')); | ||||||
|                     console.log('Added go to the path'); |                     console.log('Added go to the path'); | ||||||
|  |                     let added = addBinToPath(); | ||||||
|  |                     core.debug(`add bin ${added}`); | ||||||
|                 } |                 } | ||||||
|                 else { |                 else { | ||||||
|                     throw new Error(`Could not find a version that satisfied version spec: ${versionSpec}`); |                     throw new Error(`Could not find a version that satisfied version spec: ${versionSpec}`); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             // add problem matchers |             // add problem matchers | ||||||
|             const matchersPath = path.join(__dirname, '..', 'matchers.json'); |             const matchersPath = path_1.default.join(__dirname, '..', 'matchers.json'); | ||||||
|             console.log(`##[add-matcher]${matchersPath}`); |             console.log(`##[add-matcher]${matchersPath}`); | ||||||
|  |             // output the version actually being used | ||||||
|  |             let goPath = yield io.which('go'); | ||||||
|  |             let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString(); | ||||||
|  |             console.log(goVersion); | ||||||
|  |             core.startGroup('go env'); | ||||||
|  |             let goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString(); | ||||||
|  |             console.log(goEnv); | ||||||
|  |             core.endGroup(); | ||||||
|         } |         } | ||||||
|         catch (error) { |         catch (error) { | ||||||
|             core.setFailed(error.message); |             core.setFailed(error.message); | ||||||
| @@ -1317,6 +1333,40 @@ function run() { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| exports.run = run; | exports.run = run; | ||||||
|  | function addBinToPath() { | ||||||
|  |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|  |         let added = false; | ||||||
|  |         let g = yield io.which('go'); | ||||||
|  |         _debug(`which go :${g}:`); | ||||||
|  |         if (!g) { | ||||||
|  |             _debug('go not in the path'); | ||||||
|  |             return added; | ||||||
|  |         } | ||||||
|  |         let buf = child_process_1.default.execSync('go env GOPATH'); | ||||||
|  |         if (buf) { | ||||||
|  |             let gp = buf.toString().trim(); | ||||||
|  |             _debug(`go env GOPATH :${gp}:`); | ||||||
|  |             if (!fs_1.default.existsSync(gp)) { | ||||||
|  |                 // some of the hosted images have go install but not profile dir | ||||||
|  |                 _debug(`creating ${gp}`); | ||||||
|  |                 io.mkdirP(gp); | ||||||
|  |             } | ||||||
|  |             let bp = path_1.default.join(gp, 'bin'); | ||||||
|  |             if (!fs_1.default.existsSync(bp)) { | ||||||
|  |                 _debug(`creating ${bp}`); | ||||||
|  |                 io.mkdirP(bp); | ||||||
|  |             } | ||||||
|  |             core.addPath(bp); | ||||||
|  |             added = true; | ||||||
|  |         } | ||||||
|  |         return added; | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  | exports.addBinToPath = addBinToPath; | ||||||
|  | function _debug(message) { | ||||||
|  |     core.debug(message); | ||||||
|  | } | ||||||
|  | exports._debug = _debug; | ||||||
|  |  | ||||||
|  |  | ||||||
| /***/ }), | /***/ }), | ||||||
| @@ -3279,9 +3329,12 @@ const os = __importStar(__webpack_require__(87)); | |||||||
| const path = __importStar(__webpack_require__(622)); | const path = __importStar(__webpack_require__(622)); | ||||||
| const httpm = __importStar(__webpack_require__(539)); | const httpm = __importStar(__webpack_require__(539)); | ||||||
| const semver = __importStar(__webpack_require__(280)); | const semver = __importStar(__webpack_require__(280)); | ||||||
|  | const stream = __importStar(__webpack_require__(794)); | ||||||
|  | const util = __importStar(__webpack_require__(669)); | ||||||
| const v4_1 = __importDefault(__webpack_require__(826)); | const v4_1 = __importDefault(__webpack_require__(826)); | ||||||
| const exec_1 = __webpack_require__(986); | const exec_1 = __webpack_require__(986); | ||||||
| const assert_1 = __webpack_require__(357); | const assert_1 = __webpack_require__(357); | ||||||
|  | const retry_helper_1 = __webpack_require__(979); | ||||||
| class HTTPError extends Error { | class HTTPError extends Error { | ||||||
|     constructor(httpStatusCode) { |     constructor(httpStatusCode) { | ||||||
|         super(`Unexpected HTTP response: ${httpStatusCode}`); |         super(`Unexpected HTTP response: ${httpStatusCode}`); | ||||||
| @@ -3292,31 +3345,6 @@ class HTTPError extends Error { | |||||||
| exports.HTTPError = HTTPError; | exports.HTTPError = HTTPError; | ||||||
| const IS_WINDOWS = process.platform === 'win32'; | const IS_WINDOWS = process.platform === 'win32'; | ||||||
| const userAgent = 'actions/tool-cache'; | const userAgent = 'actions/tool-cache'; | ||||||
| // On load grab temp directory and cache directory and remove them from env (currently don't want to expose this) |  | ||||||
| let tempDirectory = process.env['RUNNER_TEMP'] || ''; |  | ||||||
| let cacheRoot = process.env['RUNNER_TOOL_CACHE'] || ''; |  | ||||||
| // If directories not found, place them in common temp locations |  | ||||||
| if (!tempDirectory || !cacheRoot) { |  | ||||||
|     let baseLocation; |  | ||||||
|     if (IS_WINDOWS) { |  | ||||||
|         // On windows use the USERPROFILE env variable |  | ||||||
|         baseLocation = process.env['USERPROFILE'] || 'C:\\'; |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|         if (process.platform === 'darwin') { |  | ||||||
|             baseLocation = '/Users'; |  | ||||||
|         } |  | ||||||
|         else { |  | ||||||
|             baseLocation = '/home'; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     if (!tempDirectory) { |  | ||||||
|         tempDirectory = path.join(baseLocation, 'actions', 'temp'); |  | ||||||
|     } |  | ||||||
|     if (!cacheRoot) { |  | ||||||
|         cacheRoot = path.join(baseLocation, 'actions', 'cache'); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| /** | /** | ||||||
|  * Download a tool from an url and stream it into a file |  * Download a tool from an url and stream it into a file | ||||||
|  * |  * | ||||||
| @@ -3326,52 +3354,71 @@ if (!tempDirectory || !cacheRoot) { | |||||||
|  */ |  */ | ||||||
| function downloadTool(url, dest) { | function downloadTool(url, dest) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         // Wrap in a promise so that we can resolve from within stream callbacks |         dest = dest || path.join(_getTempDirectory(), v4_1.default()); | ||||||
|         return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { |         yield io.mkdirP(path.dirname(dest)); | ||||||
|             try { |         core.debug(`Downloading ${url}`); | ||||||
|                 const http = new httpm.HttpClient(userAgent, [], { |         core.debug(`Destination ${dest}`); | ||||||
|                     allowRetries: true, |         const maxAttempts = 3; | ||||||
|                     maxRetries: 3 |         const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10); | ||||||
|                 }); |         const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20); | ||||||
|                 dest = dest || path.join(tempDirectory, v4_1.default()); |         const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); | ||||||
|                 yield io.mkdirP(path.dirname(dest)); |         return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { | ||||||
|                 core.debug(`Downloading ${url}`); |             return yield downloadToolAttempt(url, dest || ''); | ||||||
|                 core.debug(`Downloading ${dest}`); |         }), (err) => { | ||||||
|                 if (fs.existsSync(dest)) { |             if (err instanceof HTTPError && err.httpStatusCode) { | ||||||
|                     throw new Error(`Destination file path ${dest} already exists`); |                 // Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests | ||||||
|  |                 if (err.httpStatusCode < 500 && | ||||||
|  |                     err.httpStatusCode !== 408 && | ||||||
|  |                     err.httpStatusCode !== 429) { | ||||||
|  |                     return false; | ||||||
|                 } |                 } | ||||||
|                 const response = yield http.get(url); |  | ||||||
|                 if (response.message.statusCode !== 200) { |  | ||||||
|                     const err = new HTTPError(response.message.statusCode); |  | ||||||
|                     core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); |  | ||||||
|                     throw err; |  | ||||||
|                 } |  | ||||||
|                 const file = fs.createWriteStream(dest); |  | ||||||
|                 file.on('open', () => __awaiter(this, void 0, void 0, function* () { |  | ||||||
|                     try { |  | ||||||
|                         const stream = response.message.pipe(file); |  | ||||||
|                         stream.on('close', () => { |  | ||||||
|                             core.debug('download complete'); |  | ||||||
|                             resolve(dest); |  | ||||||
|                         }); |  | ||||||
|                     } |  | ||||||
|                     catch (err) { |  | ||||||
|                         core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); |  | ||||||
|                         reject(err); |  | ||||||
|                     } |  | ||||||
|                 })); |  | ||||||
|                 file.on('error', err => { |  | ||||||
|                     file.end(); |  | ||||||
|                     reject(err); |  | ||||||
|                 }); |  | ||||||
|             } |             } | ||||||
|             catch (err) { |             // Otherwise retry | ||||||
|                 reject(err); |             return true; | ||||||
|             } |         }); | ||||||
|         })); |  | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| exports.downloadTool = downloadTool; | exports.downloadTool = downloadTool; | ||||||
|  | function downloadToolAttempt(url, dest) { | ||||||
|  |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|  |         if (fs.existsSync(dest)) { | ||||||
|  |             throw new Error(`Destination file path ${dest} already exists`); | ||||||
|  |         } | ||||||
|  |         // Get the response headers | ||||||
|  |         const http = new httpm.HttpClient(userAgent, [], { | ||||||
|  |             allowRetries: false | ||||||
|  |         }); | ||||||
|  |         const response = yield http.get(url); | ||||||
|  |         if (response.message.statusCode !== 200) { | ||||||
|  |             const err = new HTTPError(response.message.statusCode); | ||||||
|  |             core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); | ||||||
|  |             throw err; | ||||||
|  |         } | ||||||
|  |         // Download the response body | ||||||
|  |         const pipeline = util.promisify(stream.pipeline); | ||||||
|  |         const responseMessageFactory = _getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message); | ||||||
|  |         const readStream = responseMessageFactory(); | ||||||
|  |         let succeeded = false; | ||||||
|  |         try { | ||||||
|  |             yield pipeline(readStream, fs.createWriteStream(dest)); | ||||||
|  |             core.debug('download complete'); | ||||||
|  |             succeeded = true; | ||||||
|  |             return dest; | ||||||
|  |         } | ||||||
|  |         finally { | ||||||
|  |             // Error, delete dest before retry | ||||||
|  |             if (!succeeded) { | ||||||
|  |                 core.debug('download failed'); | ||||||
|  |                 try { | ||||||
|  |                     yield io.rmRF(dest); | ||||||
|  |                 } | ||||||
|  |                 catch (err) { | ||||||
|  |                     core.debug(`Failed to delete '${dest}'. ${err.message}`); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  | } | ||||||
| /** | /** | ||||||
|  * Extract a .7z file |  * Extract a .7z file | ||||||
|  * |  * | ||||||
| @@ -3461,14 +3508,17 @@ function extractTar(file, dest, flags = 'xz') { | |||||||
|         // Create dest |         // Create dest | ||||||
|         dest = yield _createExtractFolder(dest); |         dest = yield _createExtractFolder(dest); | ||||||
|         // Determine whether GNU tar |         // Determine whether GNU tar | ||||||
|  |         core.debug('Checking tar --version'); | ||||||
|         let versionOutput = ''; |         let versionOutput = ''; | ||||||
|         yield exec_1.exec('tar --version', [], { |         yield exec_1.exec('tar --version', [], { | ||||||
|             ignoreReturnCode: true, |             ignoreReturnCode: true, | ||||||
|  |             silent: true, | ||||||
|             listeners: { |             listeners: { | ||||||
|                 stdout: (data) => (versionOutput += data.toString()), |                 stdout: (data) => (versionOutput += data.toString()), | ||||||
|                 stderr: (data) => (versionOutput += data.toString()) |                 stderr: (data) => (versionOutput += data.toString()) | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |         core.debug(versionOutput.trim()); | ||||||
|         const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR'); |         const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR'); | ||||||
|         // Initialize args |         // Initialize args | ||||||
|         const args = [flags]; |         const args = [flags]; | ||||||
| @@ -3629,7 +3679,7 @@ function find(toolName, versionSpec, arch) { | |||||||
|     let toolPath = ''; |     let toolPath = ''; | ||||||
|     if (versionSpec) { |     if (versionSpec) { | ||||||
|         versionSpec = semver.clean(versionSpec) || ''; |         versionSpec = semver.clean(versionSpec) || ''; | ||||||
|         const cachePath = path.join(cacheRoot, toolName, versionSpec, arch); |         const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch); | ||||||
|         core.debug(`checking cache: ${cachePath}`); |         core.debug(`checking cache: ${cachePath}`); | ||||||
|         if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { |         if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { | ||||||
|             core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); |             core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); | ||||||
| @@ -3651,7 +3701,7 @@ exports.find = find; | |||||||
| function findAllVersions(toolName, arch) { | function findAllVersions(toolName, arch) { | ||||||
|     const versions = []; |     const versions = []; | ||||||
|     arch = arch || os.arch(); |     arch = arch || os.arch(); | ||||||
|     const toolPath = path.join(cacheRoot, toolName); |     const toolPath = path.join(_getCacheDirectory(), toolName); | ||||||
|     if (fs.existsSync(toolPath)) { |     if (fs.existsSync(toolPath)) { | ||||||
|         const children = fs.readdirSync(toolPath); |         const children = fs.readdirSync(toolPath); | ||||||
|         for (const child of children) { |         for (const child of children) { | ||||||
| @@ -3670,7 +3720,7 @@ function _createExtractFolder(dest) { | |||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         if (!dest) { |         if (!dest) { | ||||||
|             // create a temp dir |             // create a temp dir | ||||||
|             dest = path.join(tempDirectory, v4_1.default()); |             dest = path.join(_getTempDirectory(), v4_1.default()); | ||||||
|         } |         } | ||||||
|         yield io.mkdirP(dest); |         yield io.mkdirP(dest); | ||||||
|         return dest; |         return dest; | ||||||
| @@ -3678,7 +3728,7 @@ function _createExtractFolder(dest) { | |||||||
| } | } | ||||||
| function _createToolPath(tool, version, arch) { | function _createToolPath(tool, version, arch) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); |         const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); | ||||||
|         core.debug(`destination ${folderPath}`); |         core.debug(`destination ${folderPath}`); | ||||||
|         const markerPath = `${folderPath}.complete`; |         const markerPath = `${folderPath}.complete`; | ||||||
|         yield io.rmRF(folderPath); |         yield io.rmRF(folderPath); | ||||||
| @@ -3688,7 +3738,7 @@ function _createToolPath(tool, version, arch) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| function _completeToolPath(tool, version, arch) { | function _completeToolPath(tool, version, arch) { | ||||||
|     const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); |     const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); | ||||||
|     const markerPath = `${folderPath}.complete`; |     const markerPath = `${folderPath}.complete`; | ||||||
|     fs.writeFileSync(markerPath, ''); |     fs.writeFileSync(markerPath, ''); | ||||||
|     core.debug('finished caching tool'); |     core.debug('finished caching tool'); | ||||||
| @@ -3725,6 +3775,31 @@ function _evaluateVersions(versions, versionSpec) { | |||||||
|     } |     } | ||||||
|     return version; |     return version; | ||||||
| } | } | ||||||
|  | /** | ||||||
|  |  * Gets RUNNER_TOOL_CACHE | ||||||
|  |  */ | ||||||
|  | function _getCacheDirectory() { | ||||||
|  |     const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; | ||||||
|  |     assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); | ||||||
|  |     return cacheDirectory; | ||||||
|  | } | ||||||
|  | /** | ||||||
|  |  * Gets RUNNER_TEMP | ||||||
|  |  */ | ||||||
|  | function _getTempDirectory() { | ||||||
|  |     const tempDirectory = process.env['RUNNER_TEMP'] || ''; | ||||||
|  |     assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); | ||||||
|  |     return tempDirectory; | ||||||
|  | } | ||||||
|  | /** | ||||||
|  |  * Gets a global variable | ||||||
|  |  */ | ||||||
|  | function _getGlobal(key, defaultValue) { | ||||||
|  |     /* eslint-disable @typescript-eslint/no-explicit-any */ | ||||||
|  |     const value = global[key]; | ||||||
|  |     /* eslint-enable @typescript-eslint/no-explicit-any */ | ||||||
|  |     return value !== undefined ? value : defaultValue; | ||||||
|  | } | ||||||
| //# sourceMappingURL=tool-cache.js.map | //# sourceMappingURL=tool-cache.js.map | ||||||
|  |  | ||||||
| /***/ }), | /***/ }), | ||||||
| @@ -4601,7 +4676,7 @@ function downloadGo(versionSpec, stable) { | |||||||
|                 core_1.debug(`extracted to ${extPath}`); |                 core_1.debug(`extracted to ${extPath}`); | ||||||
|                 // extracts with a root folder that matches the fileName downloaded |                 // extracts with a root folder that matches the fileName downloaded | ||||||
|                 const toolRoot = path.join(extPath, 'go'); |                 const toolRoot = path.join(extPath, 'go'); | ||||||
|                 toolPath = yield tc.cacheDir(toolRoot, 'go', versionSpec); |                 toolPath = yield tc.cacheDir(toolRoot, 'go', makeSemver(match.version)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         catch (error) { |         catch (error) { | ||||||
| @@ -4684,6 +4759,13 @@ function makeSemver(version) { | |||||||
| exports.makeSemver = makeSemver; | exports.makeSemver = makeSemver; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /***/ }), | ||||||
|  |  | ||||||
|  | /***/ 794: | ||||||
|  | /***/ (function(module) { | ||||||
|  |  | ||||||
|  | module.exports = require("stream"); | ||||||
|  |  | ||||||
| /***/ }), | /***/ }), | ||||||
|  |  | ||||||
| /***/ 826: | /***/ 826: | ||||||
| @@ -4792,6 +4874,83 @@ function checkBypass(reqUrl) { | |||||||
| exports.checkBypass = checkBypass; | exports.checkBypass = checkBypass; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /***/ }), | ||||||
|  |  | ||||||
|  | /***/ 979: | ||||||
|  | /***/ (function(__unusedmodule, exports, __webpack_require__) { | ||||||
|  |  | ||||||
|  | "use strict"; | ||||||
|  |  | ||||||
|  | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||||
|  |     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||||
|  |     return new (P || (P = Promise))(function (resolve, reject) { | ||||||
|  |         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||||
|  |         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||||
|  |         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||||
|  |         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||||
|  |     }); | ||||||
|  | }; | ||||||
|  | var __importStar = (this && this.__importStar) || function (mod) { | ||||||
|  |     if (mod && mod.__esModule) return mod; | ||||||
|  |     var result = {}; | ||||||
|  |     if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||||||
|  |     result["default"] = mod; | ||||||
|  |     return result; | ||||||
|  | }; | ||||||
|  | Object.defineProperty(exports, "__esModule", { value: true }); | ||||||
|  | const core = __importStar(__webpack_require__(470)); | ||||||
|  | /** | ||||||
|  |  * Internal class for retries | ||||||
|  |  */ | ||||||
|  | class RetryHelper { | ||||||
|  |     constructor(maxAttempts, minSeconds, maxSeconds) { | ||||||
|  |         if (maxAttempts < 1) { | ||||||
|  |             throw new Error('max attempts should be greater than or equal to 1'); | ||||||
|  |         } | ||||||
|  |         this.maxAttempts = maxAttempts; | ||||||
|  |         this.minSeconds = Math.floor(minSeconds); | ||||||
|  |         this.maxSeconds = Math.floor(maxSeconds); | ||||||
|  |         if (this.minSeconds > this.maxSeconds) { | ||||||
|  |             throw new Error('min seconds should be less than or equal to max seconds'); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     execute(action, isRetryable) { | ||||||
|  |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|  |             let attempt = 1; | ||||||
|  |             while (attempt < this.maxAttempts) { | ||||||
|  |                 // Try | ||||||
|  |                 try { | ||||||
|  |                     return yield action(); | ||||||
|  |                 } | ||||||
|  |                 catch (err) { | ||||||
|  |                     if (isRetryable && !isRetryable(err)) { | ||||||
|  |                         throw err; | ||||||
|  |                     } | ||||||
|  |                     core.info(err.message); | ||||||
|  |                 } | ||||||
|  |                 // Sleep | ||||||
|  |                 const seconds = this.getSleepAmount(); | ||||||
|  |                 core.info(`Waiting ${seconds} seconds before trying again`); | ||||||
|  |                 yield this.sleep(seconds); | ||||||
|  |                 attempt++; | ||||||
|  |             } | ||||||
|  |             // Last attempt | ||||||
|  |             return yield action(); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |     getSleepAmount() { | ||||||
|  |         return (Math.floor(Math.random() * (this.maxSeconds - this.minSeconds + 1)) + | ||||||
|  |             this.minSeconds); | ||||||
|  |     } | ||||||
|  |     sleep(seconds) { | ||||||
|  |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|  |             return new Promise(resolve => setTimeout(resolve, seconds * 1000)); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | exports.RetryHelper = RetryHelper; | ||||||
|  | //# sourceMappingURL=retry-helper.js.map | ||||||
|  |  | ||||||
| /***/ }), | /***/ }), | ||||||
|  |  | ||||||
| /***/ 986: | /***/ 986: | ||||||
|   | |||||||
| @@ -4,11 +4,11 @@ | |||||||
|             "owner": "go", |             "owner": "go", | ||||||
|             "pattern": [ |             "pattern": [ | ||||||
|                 { |                 { | ||||||
|                     "regexp": "^([^:]*: )?((.:)?[^:]*):(\\d+)(:(\\d+))?: (.*)$", |                     "regexp": "^\\s*(\\.{0,2}[\\/\\\\].+\\.go):(?:(\\d+):(\\d+):)? (.*)", | ||||||
|                     "file": 2, |                     "file": 1, | ||||||
|                     "line": 4, |                     "line": 2, | ||||||
|                     "column": 6, |                     "column": 3, | ||||||
|                     "message": 7 |                     "message": 4 | ||||||
|                 } |                 } | ||||||
|             ] |             ] | ||||||
|         } |         } | ||||||
|   | |||||||
							
								
								
									
										10818
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10818
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -25,7 +25,8 @@ | |||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@actions/core": "^1.2.2", |     "@actions/core": "^1.2.2", | ||||||
|     "@actions/http-client": "^1.0.6", |     "@actions/http-client": "^1.0.6", | ||||||
|     "@actions/tool-cache": "^1.3.1", |     "@actions/io": "^1.0.2", | ||||||
|  |     "@actions/tool-cache": "^1.3.3", | ||||||
|     "semver": "^6.1.1" |     "semver": "^6.1.1" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
| @@ -33,7 +34,7 @@ | |||||||
|     "@types/node": "^12.0.4", |     "@types/node": "^12.0.4", | ||||||
|     "@types/semver": "^6.0.0", |     "@types/semver": "^6.0.0", | ||||||
|     "@zeit/ncc": "^0.21.0", |     "@zeit/ncc": "^0.21.0", | ||||||
|     "jest": "^24.8.0", |     "jest": "^25.2.1", | ||||||
|     "jest-circus": "^24.7.1", |     "jest-circus": "^24.7.1", | ||||||
|     "nock": "^10.0.6", |     "nock": "^10.0.6", | ||||||
|     "prettier": "^1.17.1", |     "prettier": "^1.17.1", | ||||||
|   | |||||||
| @@ -33,7 +33,7 @@ export async function downloadGo( | |||||||
|  |  | ||||||
|       // extracts with a root folder that matches the fileName downloaded |       // extracts with a root folder that matches the fileName downloaded | ||||||
|       const toolRoot = path.join(extPath, 'go'); |       const toolRoot = path.join(extPath, 'go'); | ||||||
|       toolPath = await tc.cacheDir(toolRoot, 'go', versionSpec); |       toolPath = await tc.cacheDir(toolRoot, 'go', makeSemver(match.version)); | ||||||
|     } |     } | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     throw new Error(`Failed to download version ${versionSpec}: ${error}`); |     throw new Error(`Failed to download version ${versionSpec}: ${error}`); | ||||||
|   | |||||||
							
								
								
									
										53
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								src/main.ts
									
									
									
									
									
								
							| @@ -1,7 +1,10 @@ | |||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
|  | import * as io from '@actions/io'; | ||||||
| import * as tc from '@actions/tool-cache'; | import * as tc from '@actions/tool-cache'; | ||||||
| import * as installer from './installer'; | import * as installer from './installer'; | ||||||
| import * as path from 'path'; | import path from 'path'; | ||||||
|  | import cp from 'child_process'; | ||||||
|  | import fs from 'fs'; | ||||||
|  |  | ||||||
| export async function run() { | export async function run() { | ||||||
|   try { |   try { | ||||||
| @@ -34,6 +37,9 @@ export async function run() { | |||||||
|         core.exportVariable('GOROOT', installDir); |         core.exportVariable('GOROOT', installDir); | ||||||
|         core.addPath(path.join(installDir, 'bin')); |         core.addPath(path.join(installDir, 'bin')); | ||||||
|         console.log('Added go to the path'); |         console.log('Added go to the path'); | ||||||
|  |  | ||||||
|  |         let added = addBinToPath(); | ||||||
|  |         core.debug(`add bin ${added}`); | ||||||
|       } else { |       } else { | ||||||
|         throw new Error( |         throw new Error( | ||||||
|           `Could not find a version that satisfied version spec: ${versionSpec}` |           `Could not find a version that satisfied version spec: ${versionSpec}` | ||||||
| @@ -44,7 +50,52 @@ export async function run() { | |||||||
|     // add problem matchers |     // add problem matchers | ||||||
|     const matchersPath = path.join(__dirname, '..', 'matchers.json'); |     const matchersPath = path.join(__dirname, '..', 'matchers.json'); | ||||||
|     console.log(`##[add-matcher]${matchersPath}`); |     console.log(`##[add-matcher]${matchersPath}`); | ||||||
|  |  | ||||||
|  |     // output the version actually being used | ||||||
|  |     let goPath = await io.which('go'); | ||||||
|  |     let goVersion = (cp.execSync(`${goPath} version`) || '').toString(); | ||||||
|  |     console.log(goVersion); | ||||||
|  |  | ||||||
|  |     core.startGroup('go env'); | ||||||
|  |     let goEnv = (cp.execSync(`${goPath} env`) || '').toString(); | ||||||
|  |     console.log(goEnv); | ||||||
|  |     core.endGroup(); | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     core.setFailed(error.message); |     core.setFailed(error.message); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | export async function addBinToPath(): Promise<boolean> { | ||||||
|  |   let added = false; | ||||||
|  |   let g = await io.which('go'); | ||||||
|  |   _debug(`which go :${g}:`); | ||||||
|  |   if (!g) { | ||||||
|  |     _debug('go not in the path'); | ||||||
|  |     return added; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   let buf = cp.execSync('go env GOPATH'); | ||||||
|  |   if (buf) { | ||||||
|  |     let gp = buf.toString().trim(); | ||||||
|  |     _debug(`go env GOPATH :${gp}:`); | ||||||
|  |     if (!fs.existsSync(gp)) { | ||||||
|  |       // some of the hosted images have go install but not profile dir | ||||||
|  |       _debug(`creating ${gp}`); | ||||||
|  |       io.mkdirP(gp); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     let bp = path.join(gp, 'bin'); | ||||||
|  |     if (!fs.existsSync(bp)) { | ||||||
|  |       _debug(`creating ${bp}`); | ||||||
|  |       io.mkdirP(bp); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     core.addPath(bp); | ||||||
|  |     added = true; | ||||||
|  |   } | ||||||
|  |   return added; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | export function _debug(message: string) { | ||||||
|  |   core.debug(message); | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user