Skip to content

Commit

Permalink
[BACKPORT] Add volta@1.1.0 support to v3.x releases.
Browse files Browse the repository at this point in the history
This is basically a cherry-pick of
069b85c, but done manually.
  • Loading branch information
rwjblue committed Oct 18, 2022
1 parent 2216ae1 commit 9095448
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
matrix:
volta-version: ["1.0.0", "1.0.8"]
volta-version: ["1.0.0", "1.0.8", "1.1.0"]
os: [ubuntu, macOS, windows]

steps:
Expand Down
186 changes: 125 additions & 61 deletions src/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,110 @@ import { createTempDir } from 'broccoli-test-helper';
import nock from 'nock';

describe('buildDownloadUrl', () => {
test('darwin', async function () {
expect(await buildDownloadUrl('darwin', '0.6.4')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-macos.tar.gz"`
);
});
describe('volta < 1.1.0', function () {
test('darwin - x64', async function () {
expect(await buildDownloadUrl('darwin', 'x64', '0.6.4')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-macos.tar.gz"`
);
});

test('linux', async function () {
expect(
await buildDownloadUrl('linux', '0.6.4', 'OpenSSL 1.0.1e-fips 11 Feb 2013')
).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"`
);
test('darwin - arm64', async function () {
expect(await buildDownloadUrl('darwin', 'arm64', '0.6.4')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-macos.tar.gz"`
);
});

expect(
await buildDownloadUrl('linux', '0.6.4', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
);
});
test('linux', async function () {
expect(
await buildDownloadUrl('linux', 'x64', '0.6.4', 'OpenSSL 1.0.1e-fips 11 Feb 2013')
).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"`
);

expect(
await buildDownloadUrl('linux', 'x64', '0.6.4', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
);
});

test('linux with openssl-version input', async function () {
expect(await buildDownloadUrl('linux', '0.6.4', '1.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"`
);
test('linux with openssl-version input', async function () {
expect(await buildDownloadUrl('linux', 'x64', '0.6.4', '1.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.0.tar.gz"`
);

expect(await buildDownloadUrl('linux', '0.6.4', '1.1')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
);
});
expect(await buildDownloadUrl('linux', 'x64', '0.6.4', '1.1')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
);
});

test('win32', async function () {
expect(await buildDownloadUrl('win32', '0.7.2')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`
);
test('win32', async function () {
expect(await buildDownloadUrl('win32', 'x86-64', '0.7.2')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`
);
});

test('aix', async function () {
expect(
async () =>
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '0.6.4')
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
});
});

test('aix', async function () {
expect(
async () => await buildDownloadUrl('aix', '0.6.4')
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
describe('volta@1.1.0', function () {
test('darwin - x64', async function () {
expect(await buildDownloadUrl('darwin', 'x64', '1.1.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos.tar.gz"`
);
});

test('darwin - arm64', async function () {
expect(await buildDownloadUrl('darwin', 'arm64', '1.1.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos-aarch64.tar.gz"`
);
});

test('linux', async function () {
expect(
await buildDownloadUrl('linux', 'x64', '1.1.0', 'OpenSSL 1.0.1e-fips 11 Feb 2013')
).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
);

expect(
await buildDownloadUrl('linux', 'x64', '1.1.0', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
);

expect(await buildDownloadUrl('linux', 'x64', '1.1.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
);
});

test('linux with openssl-version input', async function () {
expect(await buildDownloadUrl('linux', 'x64', '1.1.0', '1.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
);

expect(await buildDownloadUrl('linux', 'x64', '1.1.0', '1.1')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
);
});

test('win32', async function () {
expect(await buildDownloadUrl('win32', 'x86-64', '1.1.0')).toMatchInlineSnapshot(
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-windows-x86_64.msi"`
);
});

test('aix', async function () {
expect(
async () =>
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '1.1.0')
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
});
});
});

Expand All @@ -59,34 +123,34 @@ describe('buildLayout', () => {
await buildLayout(tmpdir.path());

expect(tmpdir.read()).toMatchInlineSnapshot(`
Object {
"bin": Object {
"node": "shim-file-here",
"npm": "shim-file-here",
"npx": "shim-file-here",
"shim": "shim-file-here",
"yarn": "shim-file-here",
},
"cache": Object {
"node": Object {},
},
"log": Object {},
"tmp": Object {},
"tools": Object {
"image": Object {
"node": Object {},
"packages": Object {},
"yarn": Object {},
},
"inventory": Object {
"node": Object {},
"packages": Object {},
"yarn": Object {},
},
"user": Object {},
},
}
`);
Object {
"bin": Object {
"node": "shim-file-here",
"npm": "shim-file-here",
"npx": "shim-file-here",
"shim": "shim-file-here",
"yarn": "shim-file-here",
},
"cache": Object {
"node": Object {},
},
"log": Object {},
"tmp": Object {},
"tools": Object {
"image": Object {
"node": Object {},
"packages": Object {},
"yarn": Object {},
},
"inventory": Object {
"node": Object {},
"packages": Object {},
"yarn": Object {},
},
"user": Object {},
},
}
`);
});
});

Expand Down
49 changes: 35 additions & 14 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,46 @@ function voltaVersionHasSetup(version: string): boolean {

export async function buildDownloadUrl(
platform: string,
arch: string,
version: string,
openSSLVersion = ''
): Promise<string> {
let fileName: string;
switch (platform) {
case 'darwin':
fileName = `volta-${version}-macos.tar.gz`;
break;
case 'linux': {
openSSLVersion = await getOpenSSLVersion(openSSLVersion);

fileName = `volta-${version}-linux-${openSSLVersion}.tar.gz`;
break;

const isOpenSSLDependent = semver.lt(version, '1.1.0');

if (isOpenSSLDependent) {
switch (platform) {
case 'darwin':
fileName = `volta-${version}-macos.tar.gz`;
break;
case 'linux': {
openSSLVersion = await getOpenSSLVersion(openSSLVersion);

fileName = `volta-${version}-linux-${openSSLVersion}.tar.gz`;
break;
}
case 'win32':
fileName = `volta-${version}-windows-x86_64.msi`;
break;
default:
throw new Error(`your platform ${platform} is not yet supported`);
}
case 'win32':
fileName = `volta-${version}-windows-x86_64.msi`;
break;
default:
} else {
switch (platform) {
case 'darwin':
fileName = `volta-${version}-macos${arch === 'arm64' ? '-aarch64' : ''}.tar.gz`;
break;
case 'linux': {
fileName = `volta-${version}-linux.tar.gz`;
break;
}
case 'win32':
fileName = `volta-${version}-windows-x86_64.msi`;
break;
default:
throw new Error(`your platform ${platform} is not yet supported`);
}
}

return `https://github.com/volta-cli/volta/releases/download/v${version}/${fileName}`;
Expand Down Expand Up @@ -166,7 +187,7 @@ async function acquireVolta(

core.info(`downloading volta@${version}`);

const downloadUrl = await buildDownloadUrl(os.platform(), version, openSSLVersion);
const downloadUrl = await buildDownloadUrl(os.platform(), os.arch(), version, openSSLVersion);

core.debug(`downloading from \`${downloadUrl}\``);
const downloadPath = await tc.downloadTool(downloadUrl, undefined, authToken);
Expand Down

0 comments on commit 9095448

Please sign in to comment.