mirror of
https://code.forgejo.org/actions/setup-node
synced 2025-06-08 04:58:19 +02:00
feat: support private mirrors (#1240)
* feat: support private mirrors * chore: change fallback message with mirrors
This commit is contained in:
parent
40337cb8f7
commit
e3ce749e20
14 changed files with 322 additions and 44 deletions
|
@ -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([
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue