Format adopt
This commit is contained in:
parent
b50facbbd0
commit
2df4cee1ae
|
@ -1,11 +1,17 @@
|
||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import {AdoptDistribution, AdoptImplementation} from '../../src/distributions/adopt/installer';
|
import {
|
||||||
|
AdoptDistribution,
|
||||||
|
AdoptImplementation
|
||||||
|
} from '../../src/distributions/adopt/installer';
|
||||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
import manifestData from '../data/adopt.json';
|
import manifestData from '../data/adopt.json';
|
||||||
import {TemurinDistribution, TemurinImplementation} from "../../src/distributions/temurin/installer";
|
import {
|
||||||
|
TemurinDistribution,
|
||||||
|
TemurinImplementation
|
||||||
|
} from '../../src/distributions/temurin/installer';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
let spyHttpClient: jest.SpyInstance;
|
let spyHttpClient: jest.SpyInstance;
|
||||||
|
@ -245,83 +251,87 @@ describe('findPackageForDownload', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('delegates to Temurin', () => {
|
describe('delegates to Temurin', () => {
|
||||||
it.each([
|
it.each([
|
||||||
['9', '9.0.7+10'],
|
['9', '9.0.7+10'],
|
||||||
['15', '15.0.2+7'],
|
['15', '15.0.2+7'],
|
||||||
['15.0', '15.0.2+7'],
|
['15.0', '15.0.2+7'],
|
||||||
['15.0.2', '15.0.2+7'],
|
['15.0.2', '15.0.2+7'],
|
||||||
['15.0.1', '15.0.1+9.1'],
|
['15.0.1', '15.0.1+9.1'],
|
||||||
['11.x', '11.0.10+9'],
|
['11.x', '11.0.10+9'],
|
||||||
['x', '15.0.2+7'],
|
['x', '15.0.2+7'],
|
||||||
['12', '12.0.2+10.3'], // make sure that '12.0.2+10.1', '12.0.2+10.3', '12.0.2+10.2' are sorted correctly
|
['12', '12.0.2+10.3'], // make sure that '12.0.2+10.1', '12.0.2+10.3', '12.0.2+10.2' are sorted correctly
|
||||||
['12.0.2+10.1', '12.0.2+10.1'],
|
['12.0.2+10.1', '12.0.2+10.1'],
|
||||||
['15.0.1+9', '15.0.1+9'],
|
['15.0.1+9', '15.0.1+9'],
|
||||||
['15.0.1+9.1', '15.0.1+9.1']
|
['15.0.1+9.1', '15.0.1+9.1']
|
||||||
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
||||||
|
const temurinDistribution = new TemurinDistribution(
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
TemurinImplementation.Hotspot
|
||||||
|
);
|
||||||
|
|
||||||
const temurinDistribution = new TemurinDistribution(
|
const distribution = new AdoptDistribution(
|
||||||
{
|
{
|
||||||
version: '11',
|
version: '11',
|
||||||
architecture: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
},
|
},
|
||||||
TemurinImplementation.Hotspot
|
AdoptImplementation.Hotspot,
|
||||||
);
|
temurinDistribution
|
||||||
|
);
|
||||||
|
|
||||||
const distribution = new AdoptDistribution(
|
temurinDistribution['getAvailableVersions'] = async () =>
|
||||||
{
|
manifestData as any;
|
||||||
version: '11',
|
const resolvedVersion = await distribution['findPackageForDownload'](
|
||||||
architecture: 'x64',
|
input
|
||||||
packageType: 'jdk',
|
);
|
||||||
checkLatest: false
|
expect(resolvedVersion.version).toBe(expected);
|
||||||
},
|
});
|
||||||
AdoptImplementation.Hotspot,
|
|
||||||
temurinDistribution
|
|
||||||
);
|
|
||||||
|
|
||||||
temurinDistribution['getAvailableVersions'] = async () => manifestData as any;
|
|
||||||
const resolvedVersion = await distribution['findPackageForDownload'](input);
|
|
||||||
expect(resolvedVersion.version).toBe(expected);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Falls back if Temurin fails', () => {
|
||||||
|
it.each([['9', '9.0.7+10']])(
|
||||||
|
'version is resolved correctly %s -> %s',
|
||||||
|
async (input, expected) => {
|
||||||
|
const temurinDistribution = new TemurinDistribution(
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
TemurinImplementation.Hotspot
|
||||||
|
);
|
||||||
|
|
||||||
describe('Falls back if Temurin fails', () => {
|
const distribution = new AdoptDistribution(
|
||||||
it.each([
|
{
|
||||||
['9', '9.0.7+10']
|
version: '11',
|
||||||
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
AdoptImplementation.Hotspot,
|
||||||
|
temurinDistribution
|
||||||
|
);
|
||||||
|
|
||||||
const temurinDistribution = new TemurinDistribution(
|
temurinDistribution['findPackageForDownload'] = async () =>
|
||||||
{
|
new Promise(function () {
|
||||||
version: '11',
|
throw new Error('Could not find satisfied version for SemVer');
|
||||||
architecture: 'x64',
|
});
|
||||||
packageType: 'jdk',
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
checkLatest: false
|
|
||||||
},
|
|
||||||
TemurinImplementation.Hotspot
|
|
||||||
);
|
|
||||||
|
|
||||||
const distribution = new AdoptDistribution(
|
const resolvedVersion = await distribution['findPackageForDownload'](
|
||||||
{
|
input
|
||||||
version: '11',
|
);
|
||||||
architecture: 'x64',
|
expect(resolvedVersion.version).toBe(expected);
|
||||||
packageType: 'jdk',
|
}
|
||||||
checkLatest: false
|
);
|
||||||
},
|
});
|
||||||
AdoptImplementation.Hotspot,
|
|
||||||
temurinDistribution
|
|
||||||
);
|
|
||||||
|
|
||||||
temurinDistribution['findPackageForDownload'] = async () => new Promise(function () {
|
|
||||||
throw new Error("Could not find satisfied version for SemVer")
|
|
||||||
});
|
|
||||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
|
||||||
|
|
||||||
const resolvedVersion = await distribution['findPackageForDownload'](input);
|
|
||||||
expect(resolvedVersion.version).toBe(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('version is found but binaries list is empty', async () => {
|
it('version is found but binaries list is empty', async () => {
|
||||||
const distribution = new AdoptDistribution(
|
const distribution = new AdoptDistribution(
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
isVersionSatisfies
|
isVersionSatisfies
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import {TemurinDistribution, TemurinImplementation} from "../temurin/installer";
|
import {TemurinDistribution, TemurinImplementation} from '../temurin/installer';
|
||||||
|
|
||||||
export enum AdoptImplementation {
|
export enum AdoptImplementation {
|
||||||
Hotspot = 'Hotspot',
|
Hotspot = 'Hotspot',
|
||||||
|
@ -33,36 +33,45 @@ export class AdoptDistribution extends JavaBase {
|
||||||
super(`Adopt-${jvmImpl}`, installerOptions);
|
super(`Adopt-${jvmImpl}`, installerOptions);
|
||||||
|
|
||||||
if (temurinDistribution != null && jvmImpl != AdoptImplementation.Hotspot) {
|
if (temurinDistribution != null && jvmImpl != AdoptImplementation.Hotspot) {
|
||||||
throw new Error("Only Hotspot JVM is supported by Temurin.")
|
throw new Error('Only Hotspot JVM is supported by Temurin.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only use the temurin repo for Hotspot JVMs
|
// Only use the temurin repo for Hotspot JVMs
|
||||||
if (temurinDistribution == null && jvmImpl == AdoptImplementation.Hotspot) {
|
if (temurinDistribution == null && jvmImpl == AdoptImplementation.Hotspot) {
|
||||||
this.temurinDistribution = new TemurinDistribution(
|
this.temurinDistribution = new TemurinDistribution(
|
||||||
installerOptions,
|
installerOptions,
|
||||||
TemurinImplementation.Hotspot);
|
TemurinImplementation.Hotspot
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async findPackageForDownload(
|
protected async findPackageForDownload(
|
||||||
version: string
|
version: string
|
||||||
): Promise<JavaDownloadRelease> {
|
): Promise<JavaDownloadRelease> {
|
||||||
|
|
||||||
if (this.jvmImpl == AdoptImplementation.Hotspot) {
|
if (this.jvmImpl == AdoptImplementation.Hotspot) {
|
||||||
core.notice("AdoptOpenJDK has moved to Eclipse Temurin https://github.com/actions/setup-java#supported-distributions please consider changing to the 'temurin' distribution type in your setup-java configuration.")
|
core.notice(
|
||||||
|
"AdoptOpenJDK has moved to Eclipse Temurin https://github.com/actions/setup-java#supported-distributions please consider changing to the 'temurin' distribution type in your setup-java configuration."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.jvmImpl == AdoptImplementation.Hotspot && this.temurinDistribution != null) {
|
if (
|
||||||
|
this.jvmImpl == AdoptImplementation.Hotspot &&
|
||||||
|
this.temurinDistribution != null
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
let result = await this.temurinDistribution.findPackageForDownload(version)
|
let result = await this.temurinDistribution.findPackageForDownload(
|
||||||
|
version
|
||||||
|
);
|
||||||
|
|
||||||
if (result != undefined) {
|
if (result != undefined) {
|
||||||
return result
|
return result;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.message.includes('Could not find satisfied version')) {
|
if (error.message.includes('Could not find satisfied version')) {
|
||||||
core.notice("The JVM you are looking for could not be found in the Temurin repository, this likely indicates " +
|
core.notice(
|
||||||
"that you are using an out of date version of Java, consider updating and moving to using the Temurin distribution type in setup-java.")
|
'The JVM you are looking for could not be found in the Temurin repository, this likely indicates ' +
|
||||||
|
'that you are using an out of date version of Java, consider updating and moving to using the Temurin distribution type in setup-java.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +81,7 @@ export class AdoptDistribution extends JavaBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async findPackageForDownloadOldAdoptOpenJdk(
|
private async findPackageForDownloadOldAdoptOpenJdk(
|
||||||
version: string
|
version: string
|
||||||
): Promise<JavaDownloadRelease> {
|
): Promise<JavaDownloadRelease> {
|
||||||
const availableVersionsRaw = await this.getAvailableVersions();
|
const availableVersionsRaw = await this.getAvailableVersions();
|
||||||
const availableVersionsWithBinaries = availableVersionsRaw
|
const availableVersionsWithBinaries = availableVersionsRaw
|
||||||
|
|
Loading…
Reference in New Issue