mirror of
				https://kkgithub.com/actions/setup-node.git
				synced 2025-11-01 03:01:53 +08:00 
			
		
		
		
	feat: support private mirrors (#1240)
* feat: support private mirrors * chore: change fallback message with mirrors
This commit is contained in:
		| @ -315,7 +315,7 @@ describe('setup-node', () => { | ||||
|     await main.run(); | ||||
|  | ||||
|     workingUrls.forEach(url => { | ||||
|       expect(dlSpy).toHaveBeenCalledWith(url); | ||||
|       expect(dlSpy).toHaveBeenCalledWith(url, undefined, undefined); | ||||
|     }); | ||||
|     expect(cnSpy).toHaveBeenCalledWith(`::add-path::${toolPath}${osm.EOL}`); | ||||
|   }); | ||||
| @ -449,6 +449,54 @@ describe('setup-node', () => { | ||||
|     } | ||||
|   }, 100000); | ||||
|  | ||||
|   it('acquires specified architecture of node from mirror', async () => { | ||||
|     for (const {arch, version, osSpec} of [ | ||||
|       { | ||||
|         arch: 'x86', | ||||
|         version: '18.0.0-nightly202110204cb3e06ed8', | ||||
|         osSpec: 'win32' | ||||
|       }, | ||||
|       { | ||||
|         arch: 'x86', | ||||
|         version: '20.0.0-nightly2022101987cdf7d412', | ||||
|         osSpec: 'win32' | ||||
|       } | ||||
|     ]) { | ||||
|       os.platform = osSpec; | ||||
|       os.arch = arch; | ||||
|       const fileExtension = os.platform === 'win32' ? '7z' : 'tar.gz'; | ||||
|       const platform = { | ||||
|         linux: 'linux', | ||||
|         darwin: 'darwin', | ||||
|         win32: 'win' | ||||
|       }[os.platform]; | ||||
|  | ||||
|       inputs['node-version'] = version; | ||||
|       inputs['architecture'] = arch; | ||||
|       inputs['always-auth'] = false; | ||||
|       inputs['token'] = 'faketoken'; | ||||
|       inputs['mirror'] = 'https://my-mirror.org'; | ||||
|       inputs['mirror-token'] = 'my-mirror-token'; | ||||
|  | ||||
|       const expectedUrl = `https://my-mirror.org/download/nightly/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; | ||||
|  | ||||
|       // ... but not in the local cache | ||||
|       findSpy.mockImplementation(() => ''); | ||||
|       findAllVersionsSpy.mockImplementation(() => []); | ||||
|  | ||||
|       dlSpy.mockImplementation(async () => '/some/temp/path'); | ||||
|       const toolPath = path.normalize(`/cache/node/${version}/${arch}`); | ||||
|       exSpy.mockImplementation(async () => '/some/other/temp/path'); | ||||
|       cacheSpy.mockImplementation(async () => toolPath); | ||||
|  | ||||
|       await main.run(); | ||||
|       expect(dlSpy).toHaveBeenCalled(); | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         `Acquiring ${version} - ${arch} from ${expectedUrl}` | ||||
|       ); | ||||
|     } | ||||
|   }, 100000); | ||||
|  | ||||
|   describe('nightly versions', () => { | ||||
|     it.each([ | ||||
|       [ | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Marco Ippolito
					Marco Ippolito