diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2a42447d..c1742f40 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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: diff --git a/src/installer.test.ts b/src/installer.test.ts index cf3220fd..5c4bfc54 100644 --- a/src/installer.test.ts +++ b/src/installer.test.ts @@ -3,42 +3,94 @@ 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.0.0', function () { + test('darwin - x64', async function () { + expect(await buildDownloadUrl('darwin', 'x64', '1.0.0')).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-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', '1.0.0')).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-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', '1.0.0', '', 'OpenSSL 1.0.1e-fips 11 Feb 2013') + ).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-linux-openssl-1.0.tar.gz"` + ); + + expect( + await buildDownloadUrl('linux', 'x64', '1.0.0', '', 'OpenSSL 1.1.1e-fips 11 Sep 2018') + ).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-linux-openssl-1.1.tar.gz"` + ); + }); - test('linux with variant input', async function () { - expect(await buildDownloadUrl('linux', '0.6.4', 'linux-openssl-rhel')).toMatchInlineSnapshot( - `"https://github.com/volta-cli/volta/releases/download/v0.6.4/volta-0.6.4-linux-openssl-rhel.tar.gz"` - ); - }); + test('linux with variant input', async function () { + expect( + await buildDownloadUrl('linux', 'x64', '1.0.0', 'linux-openssl-rhel') + ).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.0-linux-openssl-rhel.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', '1.0.0')).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v1.0.0/volta-1.0.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.0.0') + ).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')).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux.tar.gz"` + ); + }); + + test('linux with variant input', async function () { + expect( + await buildDownloadUrl('linux', 'x64', '1.1.0', 'linux-openssl-rhel') + ).toMatchInlineSnapshot( + `"https://github.com/volta-cli/volta/releases/download/v1.1.0/volta-1.1.0-linux-openssl-rhel.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"`); + }); }); }); diff --git a/src/installer.ts b/src/installer.ts index 9738aae7..80a09691 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -78,15 +78,19 @@ function voltaVersionHasSetup(version: string): boolean { export async function buildDownloadUrl( platform: string, + arch: string, version: string, variant = '', openSSLVersionForTesting = '' ): Promise { let fileName = ''; + const isOpenSSLDependent = semver.lt(version, '1.1.0'); + if (variant) { fileName = `volta-${version}-${variant}.tar.gz`; - } else { + } else if (isOpenSSLDependent) { + // TODO: remove this branch when support for volta < 1.1.0 is dropped switch (platform) { case 'darwin': fileName = `volta-${version}-macos.tar.gz`; @@ -103,6 +107,21 @@ export async function buildDownloadUrl( default: throw new Error(`your platform ${platform} is not yet supported`); } + } 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}`; @@ -201,7 +220,7 @@ async function acquireVolta(version: string, options: VoltaInstallOptions): Prom core.info(`downloading volta@${version}`); - const downloadUrl = await buildDownloadUrl(os.platform(), version, options.variant); + const downloadUrl = await buildDownloadUrl(os.platform(), os.arch(), version, options.variant); core.debug(`downloading from \`${downloadUrl}\``); const downloadPath = await tc.downloadTool(downloadUrl, undefined, options.authToken);