diff --git a/.github/workflows/e2e-publishing.yml b/.github/workflows/e2e-publishing.yml index 28e631e1..431ce9f7 100644 --- a/.github/workflows/e2e-publishing.yml +++ b/.github/workflows/e2e-publishing.yml @@ -26,6 +26,8 @@ jobs: uses: ./ id: setup-java with: + java-version: 'adopt' + distribution: '11' server-id: maven server-username: MAVEN_USERNAME server-password: MAVEN_CENTRAL_TOKEN @@ -65,6 +67,8 @@ jobs: uses: ./ id: setup-java with: + java-version: 'adopt' + distribution: '11' server-id: maven server-username: MAVEN_USERNAME server-password: MAVEN_CENTRAL_TOKEN diff --git a/__tests__/distributors/adopt-installer.test.ts b/__tests__/distributors/adopt-installer.test.ts index 61f16dad..4b4a3c0d 100644 --- a/__tests__/distributors/adopt-installer.test.ts +++ b/__tests__/distributors/adopt-installer.test.ts @@ -27,19 +27,19 @@ describe('getAvailableVersions', () => { it.each([ [ - { version: '11', arch: 'x64', packageType: 'jdk' }, + { version: '11', architecture: 'x64', packageType: 'jdk' }, 'os=mac&architecture=x64&image_type=jdk&release_type=ga&page_size=20&page=0' ], [ - { version: '11', arch: 'x86', packageType: 'jdk' }, + { version: '11', architecture: 'x86', packageType: 'jdk' }, 'os=mac&architecture=x86&image_type=jdk&release_type=ga&page_size=20&page=0' ], [ - { version: '11', arch: 'x64', packageType: 'jre' }, + { version: '11', architecture: 'x64', packageType: 'jre' }, 'os=mac&architecture=x64&image_type=jre&release_type=ga&page_size=20&page=0' ], [ - { version: '11-ea', arch: 'x64', packageType: 'jdk' }, + { version: '11-ea', architecture: 'x64', packageType: 'jdk' }, 'os=mac&architecture=x64&image_type=jdk&release_type=ea&page_size=20&page=0' ] ])( @@ -78,7 +78,7 @@ describe('getAvailableVersions', () => { const distribution = new AdoptDistribution({ version: '11', - arch: 'x64', + architecture: 'x64', packageType: 'jdk' }); const availableVersions = await distribution['getAvailableVersions'](); @@ -103,7 +103,7 @@ describe('findPackageForDownload', () => { ])('version is resolved correctly %s -> %s', async (input, expected) => { const distribution = new AdoptDistribution({ version: '11', - arch: 'x64', + architecture: 'x64', packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => manifestData; @@ -114,7 +114,7 @@ describe('findPackageForDownload', () => { it('version is found but binaries list is empty', async () => { const distribution = new AdoptDistribution({ version: '11', - arch: 'x64', + architecture: 'x64', packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => manifestData; @@ -126,7 +126,7 @@ describe('findPackageForDownload', () => { it('version is not found', async () => { const distribution = new AdoptDistribution({ version: '11', - arch: 'x64', + architecture: 'x64', packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => manifestData; @@ -138,7 +138,7 @@ describe('findPackageForDownload', () => { it('version list is empty', async () => { const distribution = new AdoptDistribution({ version: '11', - arch: 'x64', + architecture: 'x64', packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => []; diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index ddd1d2db..e23c972b 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -58,21 +58,21 @@ describe('findInToolcache', () => { it.each([ [ - { version: '11', arch: 'x64', packageType: 'jdk' }, + { version: '11', architecture: 'x64', packageType: 'jdk' }, { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.1', arch: 'x64', packageType: 'jdk' }, + { version: '11.1', architecture: 'x64', packageType: 'jdk' }, { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.1.10', arch: 'x64', packageType: 'jdk' }, + { version: '11.1.10', architecture: 'x64', packageType: 'jdk' }, { version: actualJavaVersion, path: javaPath } ], - [{ version: '11', arch: 'x64', packageType: 'jre' }, null], - [{ version: '8', arch: 'x64', packageType: 'jdk' }, null], - [{ version: '11', arch: 'x86', packageType: 'jdk' }, null], - [{ version: '11', arch: 'x86', packageType: 'jre' }, null] + [{ version: '11', architecture: 'x64', packageType: 'jre' }, null], + [{ version: '8', architecture: 'x64', packageType: 'jdk' }, null], + [{ version: '11', architecture: 'x86', packageType: 'jdk' }, null], + [{ version: '11', architecture: 'x86', packageType: 'jre' }, null] ])(`should find java for path %s -> %s`, (input, expected) => { spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); spyGetToolcachePath.mockImplementation( @@ -115,7 +115,7 @@ describe('findInToolcache', () => { (toolname: string, javaVersion: string, architecture: string) => `/hostedtoolcache/${toolname}/${javaVersion}/${architecture}` ); - mockJavaBase = new EmptyJavaBase({ version: input, arch: 'x64', packageType: 'jdk' }); + mockJavaBase = new EmptyJavaBase({ version: input, architecture: 'x64', packageType: 'jdk' }); const foundVersion = mockJavaBase['findInToolcache'](); expect(foundVersion?.version).toEqual(expected); }); @@ -177,15 +177,15 @@ describe('setupJava', () => { it.each([ [ - { version: '11', arch: 'x86', packageType: 'jdk' }, + { version: '11', architecture: 'x86', packageType: 'jdk' }, { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.1', arch: 'x86', packageType: 'jdk' }, + { version: '11.1', architecture: 'x86', packageType: 'jdk' }, { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.1.10', arch: 'x86', packageType: 'jdk' }, + { version: '11.1.10', architecture: 'x86', packageType: 'jdk' }, { version: actualJavaVersion, path: javaPath } ] ])('should find java locally for %s', (input, expected) => { @@ -196,15 +196,15 @@ describe('setupJava', () => { it.each([ [ - { version: '11', arch: 'x86', packageType: 'jre' }, + { version: '11', architecture: 'x86', packageType: 'jre' }, { path: `/toolcache/Java_Empty_jre/11.0.8/x86`, version: '11.0.8' } ], [ - { version: '11', arch: 'x64', packageType: 'jdk' }, + { version: '11', architecture: 'x64', packageType: 'jdk' }, { path: `/toolcache/Java_Empty_jdk/11.0.8/x64`, version: '11.0.8' } ], [ - { version: '11', arch: 'x64', packageType: 'jre' }, + { version: '11', architecture: 'x64', packageType: 'jre' }, { path: `/toolcache/Java_Empty_jre/11.0.8/x64`, version: '11.0.8' } ] ])('download java with configuration %s', async (input, expected) => { @@ -217,8 +217,8 @@ describe('setupJava', () => { }); it.each([ - [{ version: '15', arch: 'x86', packageType: 'jre' }], - [{ version: '11.0.7', arch: 'x64', packageType: 'jre' }] + [{ version: '15', architecture: 'x86', packageType: 'jre' }], + [{ version: '11.0.7', architecture: 'x64', packageType: 'jre' }] ])('should throw an error for Available version not found for %s', async input => { mockJavaBase = new EmptyJavaBase(input); await expect(mockJavaBase.setupJava()).rejects.toThrowError('Available version not found'); diff --git a/__tests__/distributors/local-installer.test.ts b/__tests__/distributors/local-installer.test.ts index 96f02f4d..c3b085bf 100644 --- a/__tests__/distributors/local-installer.test.ts +++ b/__tests__/distributors/local-installer.test.ts @@ -93,11 +93,11 @@ describe('setupJava', () => { }); it('java is resolved from toolcache, jdkfile is untouched', async () => { - const inputs = { version: actualJavaVersion, arch: 'x86', packageType: 'jdk' }; + const inputs = { version: actualJavaVersion, architecture: 'x86', packageType: 'jdk' }; const jdkFile = 'not_existing_one'; const expected = { version: actualJavaVersion, - path: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch) + path: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture) }; mockJavaBase = new LocalDistribution(inputs, jdkFile); @@ -110,11 +110,11 @@ describe('setupJava', () => { }); it("java is resolved from toolcache, jdkfile doesn't exist", async () => { - const inputs = { version: actualJavaVersion, arch: 'x86', packageType: 'jdk' }; + const inputs = { version: actualJavaVersion, architecture: 'x86', packageType: 'jdk' }; const jdkFile = undefined; const expected = { version: actualJavaVersion, - path: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch) + path: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture) }; mockJavaBase = new LocalDistribution(inputs, jdkFile); @@ -127,11 +127,11 @@ describe('setupJava', () => { }); it('java is unpacked from jdkfile', async () => { - const inputs = { version: '11.0.289', arch: 'x86', packageType: 'jdk' }; + const inputs = { version: '11.0.289', architecture: 'x86', packageType: 'jdk' }; const jdkFile = expectedJdkFile; const expected = { version: '11.0.289', - path: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch) + path: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture) }; mockJavaBase = new LocalDistribution(inputs, jdkFile); @@ -147,15 +147,15 @@ describe('setupJava', () => { }); it('jdk file is not found', async () => { - const inputs = { version: '11.0.289', arch: 'x86', packageType: 'jdk' }; + const inputs = { version: '11.0.289', architecture: 'x86', packageType: 'jdk' }; const jdkFile = 'not_existing_one'; const expected = { javaVersion: '11.0.289', - javaPath: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch) + javaPath: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture) }; mockJavaBase = new LocalDistribution(inputs, jdkFile); - expected.javaPath = path.join('Java_jdkfile_jdk', inputs.version, inputs.arch); + expected.javaPath = path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture); await expect(mockJavaBase.setupJava()).rejects.toThrowError( "JDK file was not found in path 'not_existing_one'" ); @@ -170,10 +170,10 @@ describe('setupJava', () => { }); it.each([ - [{ version: '8.0.289', arch: 'x64', packageType: 'jdk' }, 'otherJdkFile'], - [{ version: '11.0.289', arch: 'x64', packageType: 'jdk' }, 'otherJdkFile'], - [{ version: '12.0.289', arch: 'x64', packageType: 'jdk' }, 'otherJdkFile'], - [{ version: '11.1.11', arch: 'x64', packageType: 'jdk' }, 'not_existing_one'] + [{ version: '8.0.289', architecture: 'x64', packageType: 'jdk' }, 'otherJdkFile'], + [{ version: '11.0.289', architecture: 'x64', packageType: 'jdk' }, 'otherJdkFile'], + [{ version: '12.0.289', architecture: 'x64', packageType: 'jdk' }, 'otherJdkFile'], + [{ version: '11.1.11', architecture: 'x64', packageType: 'jdk' }, 'not_existing_one'] ])( `Throw an error if jdkfile has wrong path, inputs %s, jdkfile %s, real name ${expectedJdkFile}`, async (inputs, jdkFile) => { @@ -186,9 +186,9 @@ describe('setupJava', () => { ); it.each([ - [{ version: '8.0.289', arch: 'x64', packageType: 'jdk' }, ''], - [{ version: '7.0.289', arch: 'x64', packageType: 'jdk' }, undefined], - [{ version: '11.0.289', arch: 'x64', packageType: 'jdk' }, undefined] + [{ version: '8.0.289', architecture: 'x64', packageType: 'jdk' }, ''], + [{ version: '7.0.289', architecture: 'x64', packageType: 'jdk' }, undefined], + [{ version: '11.0.289', architecture: 'x64', packageType: 'jdk' }, undefined] ])('Throw an error if jdkfile is not specified, inputs %s', async (inputs, jdkFile) => { mockJavaBase = new LocalDistribution(inputs, jdkFile); await expect(mockJavaBase.setupJava()).rejects.toThrowError("'jdkFile' is not specified"); diff --git a/__tests__/distributors/zulu-installer.test.ts b/__tests__/distributors/zulu-installer.test.ts index c4f4783c..fe5958a9 100644 --- a/__tests__/distributors/zulu-installer.test.ts +++ b/__tests__/distributors/zulu-installer.test.ts @@ -30,27 +30,27 @@ describe('getAvailableVersions', () => { it.each([ [ - { version: '11', arch: 'x86', packageType: 'jdk' }, + { version: '11', architecture: 'x86', packageType: 'jdk' }, '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga' ], [ - { version: '11-ea', arch: 'x86', packageType: 'jdk' }, + { version: '11-ea', architecture: 'x86', packageType: 'jdk' }, '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea' ], [ - { version: '8', arch: 'x64', packageType: 'jdk' }, + { version: '8', architecture: 'x64', packageType: 'jdk' }, '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga' ], [ - { version: '8', arch: 'x64', packageType: 'jre' }, + { version: '8', architecture: 'x64', packageType: 'jre' }, '?os=macos&ext=tar.gz&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga' ], [ - { version: '8', arch: 'x64', packageType: 'jdk+fx' }, + { version: '8', architecture: 'x64', packageType: 'jdk+fx' }, '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' ], [ - { version: '8', arch: 'x64', packageType: 'jre+fx' }, + { version: '8', architecture: 'x64', packageType: 'jre+fx' }, '?os=macos&ext=tar.gz&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' ] ])('build correct url for %s -> %s', async (input, parsedUrl) => { @@ -65,7 +65,11 @@ describe('getAvailableVersions', () => { }); it('load available versions', async () => { - const distribution = new ZuluDistribution({ version: '11', arch: 'x86', packageType: 'jdk' }); + const distribution = new ZuluDistribution({ + version: '11', + architecture: 'x86', + packageType: 'jdk' + }); const availableVersions = await distribution['getAvailableVersions'](); expect(availableVersions).toHaveLength(manifestData.length); }); @@ -80,7 +84,7 @@ describe('getArchitectureOptions', () => { ])('%s -> %s', (input, expected) => { const distribution = new ZuluDistribution({ version: '11', - arch: input.architecture, + architecture: input.architecture, packageType: 'jdk' }); expect(distribution['getArchitectureOptions']()).toEqual(expected); @@ -103,7 +107,7 @@ describe('findPackageForDownload', () => { ])('version is %s -> %s', async (input, expected) => { const distribution = new ZuluDistribution({ version: input, - arch: 'x86', + architecture: 'x86', packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => manifestData; @@ -112,7 +116,11 @@ describe('findPackageForDownload', () => { }); it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => { - const distribution = new ZuluDistribution({ version: '', arch: 'x86', packageType: 'jdk' }); + const distribution = new ZuluDistribution({ + version: '', + architecture: 'x86', + packageType: 'jdk' + }); distribution['getAvailableVersions'] = async () => manifestData; const result = await distribution['findPackageForDownload']('11.0.5'); expect(result.url).toBe( @@ -121,7 +129,11 @@ describe('findPackageForDownload', () => { }); it('should throw an error', async () => { - const distribution = new ZuluDistribution({ version: '18', arch: 'x86', packageType: 'jdk' }); + const distribution = new ZuluDistribution({ + version: '18', + architecture: 'x86', + packageType: 'jdk' + }); await expect( distribution['findPackageForDownload'](distribution['version']) ).rejects.toThrowError(/Could not find satisfied version for semver */); @@ -136,7 +148,11 @@ describe('convertVersionToSemver', () => { [[12, 0, 2, 1], '12.0.2+1'], [[12, 0, 2, 1, 3], '12.0.2+1'] ])('%s -> %s', (input: number[], expected: string) => { - const distribution = new ZuluDistribution({ version: '18', arch: 'x86', packageType: 'jdk' }); + const distribution = new ZuluDistribution({ + version: '18', + architecture: 'x86', + packageType: 'jdk' + }); const actual = distribution['convertVersionToSemver'](input); expect(actual).toBe(expected); });