Skip to content

Commit 069b85c

Browse files
author
Robert Jackson
committed
Add support for Volta 1.1.0
Volta 1.1.0 changed the naming of release assets (removing the need for specific OpenSSL versions due to using RustTLS). This updates the URL downloading logic to accomodate for those changes.
1 parent c3b1019 commit 069b85c

File tree

3 files changed

+104
-33
lines changed

3 files changed

+104
-33
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
volta-version: ["1.0.0", "1.0.8"]
42+
volta-version: ["1.0.0", "1.0.8", "1.1.0"]
4343
os: [ubuntu, macOS, windows]
4444

4545
steps:

src/installer.test.ts

Lines changed: 82 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,94 @@ import { createTempDir } from 'broccoli-test-helper';
33
import nock from 'nock';
44

55
describe('buildDownloadUrl', () => {
6-
test('darwin', async function () {
7-
expect(await buildDownloadUrl('darwin', '0.6.4')).toMatchInlineSnapshot(
8-
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-macos.tar.gz"`
9-
);
10-
});
6+
describe('[email protected]', function () {
7+
test('darwin - x64', async function () {
8+
expect(await buildDownloadUrl('darwin', 'x64', '1.0.0')).toMatchInlineSnapshot(
9+
`"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-macos.tar.gz"`
10+
);
11+
});
1112

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

19-
expect(
20-
await buildDownloadUrl('linux', '0.6.4', '', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
21-
).toMatchInlineSnapshot(
22-
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-1.1.tar.gz"`
23-
);
24-
});
19+
test('linux', async function () {
20+
expect(
21+
await buildDownloadUrl('linux', 'x64', '1.0.0', '', 'OpenSSL 1.0.1e-fips 11 Feb 2013')
22+
).toMatchInlineSnapshot(
23+
`"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-linux-openssl-1.0.tar.gz"`
24+
);
25+
26+
expect(
27+
await buildDownloadUrl('linux', 'x64', '1.0.0', '', 'OpenSSL 1.1.1e-fips 11 Sep 2018')
28+
).toMatchInlineSnapshot(
29+
`"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-linux-openssl-1.1.tar.gz"`
30+
);
31+
});
2532

26-
test('linux with variant input', async function () {
27-
expect(await buildDownloadUrl('linux', '0.6.4', 'linux-openssl-rhel')).toMatchInlineSnapshot(
28-
`"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-rhel.tar.gz"`
29-
);
30-
});
33+
test('linux with variant input', async function () {
34+
expect(
35+
await buildDownloadUrl('linux', 'x64', '1.0.0', 'linux-openssl-rhel')
36+
).toMatchInlineSnapshot(
37+
`"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-linux-openssl-rhel.tar.gz"`
38+
);
39+
});
3140

32-
test('win32', async function () {
33-
expect(await buildDownloadUrl('win32', '0.7.2')).toMatchInlineSnapshot(
34-
`"https://github.com/volta-cli/volta/releases/download/v0.7.2/volta-0.7.2-windows-x86_64.msi"`
35-
);
41+
test('win32', async function () {
42+
expect(await buildDownloadUrl('win32', 'x86-64', '1.0.0')).toMatchInlineSnapshot(
43+
`"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-windows-x86_64.msi"`
44+
);
45+
});
46+
47+
test('aix', async function () {
48+
expect(
49+
async () =>
50+
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '1.0.0')
51+
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
52+
});
3653
});
3754

38-
test('aix', async function () {
39-
expect(
40-
async () => await buildDownloadUrl('aix', '0.6.4')
41-
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
55+
describe('[email protected]', function () {
56+
test('darwin - x64', async function () {
57+
expect(await buildDownloadUrl('darwin', 'x64', '1.1.0')).toMatchInlineSnapshot(
58+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos.tar.gz"`
59+
);
60+
});
61+
62+
test('darwin - arm64', async function () {
63+
expect(await buildDownloadUrl('darwin', 'arm64', '1.1.0')).toMatchInlineSnapshot(
64+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-macos-aarch64.tar.gz"`
65+
);
66+
});
67+
68+
test('linux', async function () {
69+
expect(await buildDownloadUrl('linux', 'x64', '1.1.0')).toMatchInlineSnapshot(
70+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"`
71+
);
72+
});
73+
74+
test('linux with variant input', async function () {
75+
expect(
76+
await buildDownloadUrl('linux', 'x64', '1.1.0', 'linux-openssl-rhel')
77+
).toMatchInlineSnapshot(
78+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux-openssl-rhel.tar.gz"`
79+
);
80+
});
81+
82+
test('win32', async function () {
83+
expect(await buildDownloadUrl('win32', 'x86-64', '1.1.0')).toMatchInlineSnapshot(
84+
`"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-windows-x86_64.msi"`
85+
);
86+
});
87+
88+
test('aix', async function () {
89+
expect(
90+
async () =>
91+
await buildDownloadUrl('aix', 'hmm, wat?? (I dont know a valid arch for aix)', '1.1.0')
92+
).rejects.toThrowErrorMatchingInlineSnapshot(`"your platform aix is not yet supported"`);
93+
});
4294
});
4395
});
4496

src/installer.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,19 @@ function voltaVersionHasSetup(version: string): boolean {
7878

7979
export async function buildDownloadUrl(
8080
platform: string,
81+
arch: string,
8182
version: string,
8283
variant = '',
8384
openSSLVersionForTesting = ''
8485
): Promise<string> {
8586
let fileName = '';
8687

88+
const isOpenSSLDependent = semver.lt(version, '1.1.0');
89+
8790
if (variant) {
8891
fileName = `volta-${version}-${variant}.tar.gz`;
89-
} else {
92+
} else if (isOpenSSLDependent) {
93+
// TODO: remove this branch when support for volta < 1.1.0 is dropped
9094
switch (platform) {
9195
case 'darwin':
9296
fileName = `volta-${version}-macos.tar.gz`;
@@ -103,6 +107,21 @@ export async function buildDownloadUrl(
103107
default:
104108
throw new Error(`your platform ${platform} is not yet supported`);
105109
}
110+
} else {
111+
switch (platform) {
112+
case 'darwin':
113+
fileName = `volta-${version}-macos${arch === 'arm64' ? '-aarch64' : ''}.tar.gz`;
114+
break;
115+
case 'linux': {
116+
fileName = `volta-${version}-linux.tar.gz`;
117+
break;
118+
}
119+
case 'win32':
120+
fileName = `volta-${version}-windows-x86_64.msi`;
121+
break;
122+
default:
123+
throw new Error(`your platform ${platform} is not yet supported`);
124+
}
106125
}
107126

108127
return `https://github.com/volta-cli/volta/releases/download/v${version}/${fileName}`;
@@ -201,7 +220,7 @@ async function acquireVolta(version: string, options: VoltaInstallOptions): Prom
201220

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

204-
const downloadUrl = await buildDownloadUrl(os.platform(), version, options.variant);
223+
const downloadUrl = await buildDownloadUrl(os.platform(), os.arch(), version, options.variant);
205224

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

0 commit comments

Comments
 (0)