Compare commits

..

1 Commits

Author SHA1 Message Date
Accelerator1996
784bb48b94
Merge ec1af222f0 into 4075bfc1b5 2023-09-04 07:30:29 +00:00
4 changed files with 60 additions and 148 deletions

View File

@ -29,17 +29,12 @@ jobs:
'liberica',
'microsoft',
'semeru',
'corretto',
'dragonwell'
'corretto'
] # internally 'adopt-hotspot' is the same as 'adopt'
version: ['8', '11', '17']
exclude:
- distribution: microsoft
version: 8
- distribution: dragonwell
os: macos-latest
- distribution: dragonwell
version: 16
include:
- distribution: oracle
os: macos-latest
@ -50,13 +45,6 @@ jobs:
- distribution: oracle
os: ubuntu-latest
version: 20
- distribution: dragonwell
os: windows-latest
version: 17
- distribution: dragonwell
os: ubuntu-latest
version: 17
steps:
- name: Checkout
uses: actions/checkout@v3
@ -87,12 +75,6 @@ jobs:
- distribution: oracle
os: ubuntu-latest
version: '20.0.1'
- distribution: dragonwell
os: ubuntu-latest
version: '11.0'
- distribution: dragonwell
os: ubuntu-latest
version: '11.0.13+9'
steps:
- name: Checkout
uses: actions/checkout@v3
@ -114,10 +96,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
exclude:
- distribution: dragonwell
os: macos-latest
distribution: ['temurin', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
@ -140,10 +119,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
exclude:
- distribution: dragonwell
os: macos-latest
distribution: ['temurin', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3

View File

@ -1,6 +1,9 @@
import {HttpClient} from '@actions/http-client';
import * as semver from 'semver';
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
import {IDragonwellAllVersions} from '../../src/distributions/dragonwell/models';
import * as utils from '../../src/util';
import os from 'os';
import manifestData from '../data/dragonwell.json';
@ -41,17 +44,17 @@ describe('getAvailableVersions', () => {
describe('getAvailableVersions', () => {
it.each([
['8', 'x86', 'linux', 0],
['8', 'aarch64', 'linux', 24],
['8.6.6', 'x64', 'linux', 27],
['8', 'aarch64', 'linux', 33],
['8.6.6', 'x64', 'linux', 36],
['8', 'x86', 'anolis', 0],
['8', 'x86', 'windows', 0],
['8', 'x86', 'mac', 0],
['11', 'x64', 'linux', 27],
['11', 'aarch64', 'linux', 24],
['11', 'x64', 'linux', 36],
['11', 'aarch64', 'linux', 33],
['17', 'riscv', 'linux', 0],
['16.0.1', 'x64', 'linux', 27]
['16.0.1', 'x64', 'linux', 36]
])(
'should get right number of available versions from JSON',
'load available versions',
async (
jdkVersion: string,
arch: string,
@ -160,7 +163,7 @@ describe('getAvailableVersions', () => {
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.4.0.4%2B8_jdk-17.0.4-ga/Alibaba_Dragonwell_Standard_17.0.4.0.4%2B8_x64_linux.tar.gz'
]
])(
'should return proper link according to the specified java-version, platform and arch',
'test for download link',
async (
jdkVersion: string,
platform: string,
@ -189,7 +192,7 @@ describe('getAvailableVersions', () => {
['11', 'macos', 'aarch64'],
['17', 'linux', 'riscv']
])(
'should throw when required version of JDK can not be found in the JSON',
'test for unsupported version',
async (jdkVersion: string, platform: string, arch: string) => {
const distribution = new DragonwellDistribution({
version: jdkVersion,
@ -202,26 +205,9 @@ describe('getAvailableVersions', () => {
await expect(
distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow(
`Couldn't find any satisfied version for the specified java-version: "${jdkVersion}".`
`Couldn't find any satisfied version for the specified: "${jdkVersion}".`
);
}
);
it('should throw when required package type is not jdk', async () => {
const jdkVersion = '17';
const arch = 'x64';
const platform = 'linux';
const distribution = new DragonwellDistribution({
version: jdkVersion,
architecture: arch,
packageType: 'jre',
checkLatest: false
});
mockPlatform(distribution, platform);
await expect(
distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow('Dragonwell provides only the `jdk` package type');
});
});
});

59
dist/setup/index.js vendored
View File

@ -102644,7 +102644,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DragonwellDistribution = void 0;
const core = __importStar(__nccwpck_require__(2186));
const tc = __importStar(__nccwpck_require__(7784));
const semver_1 = __importDefault(__nccwpck_require__(1383));
const fs_1 = __importDefault(__nccwpck_require__(7147));
const path_1 = __importDefault(__nccwpck_require__(1017));
const base_installer_1 = __nccwpck_require__(9741);
@ -102658,14 +102657,16 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
if (!this.stable) {
throw new Error('Early access versions are not supported');
}
if (this.packageType !== 'jdk') {
throw new Error('Dragonwell provides only the `jdk` package type');
let majorVersion = version;
if (version.includes('.')) {
const splits = version.split('.');
majorVersion = splits[0];
version = splits.length >= 3 ? splits.slice(0, 3).join('.') : version;
}
const edition = majorVersion == '17' ? 'Standard' : 'Extended';
const availableVersions = yield this.getAvailableVersions();
const matchedVersions = availableVersions
.filter(item => {
return util_1.isVersionSatisfies(version, item.jdk_version);
})
.filter(item => item.jdk_version == version && item.edition == edition)
.map(item => {
return {
version: item.jdk_version,
@ -102673,22 +102674,24 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
};
});
if (!matchedVersions.length) {
throw new Error(`Couldn't find any satisfied version for the specified java-version: "${version}".`);
throw new Error(`Couldn't find any satisfied version for the specified: "${version}".`);
}
const resolvedVersion = matchedVersions[0];
return resolvedVersion;
});
}
getAvailableVersions() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
const availableVersionsUrl = 'https://raw.githubusercontent.com/dragonwell-releng/dragonwell-setup-java/main/releases.json';
const fetchedDragonwellVersions = (yield this.http.getJson(availableVersionsUrl)).result;
if (!fetchedDragonwellVersions) {
throw new Error(`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`);
const fetchedDragonwellVersions = (_a = (yield this.http.getJson(availableVersionsUrl))
.result) !== null && _a !== void 0 ? _a : {};
if (Object.keys(fetchedDragonwellVersions).length == 0) {
throw Error(`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`);
}
const availableVersions = this.parseVersions(platform, arch, fetchedDragonwellVersions);
const availableVersions = this.getEligibleAvailableVersions(platform, arch, fetchedDragonwellVersions);
if (core.isDebug()) {
core.startGroup('Print information about available versions');
core.debug(availableVersions.map(item => item.jdk_version).join(', '));
@ -102710,8 +102713,7 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
return { version: javaRelease.version, path: javaPath };
});
}
parseVersions(platform, arch, dragonwellVersions) {
var _a;
getEligibleAvailableVersions(platform, arch, dragonwellVersions) {
const eligibleVersions = [];
for (const majorVersion in dragonwellVersions) {
const majorVersionMap = dragonwellVersions[majorVersion];
@ -102726,44 +102728,27 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
}
const archMap = platformMap[arch];
if (jdkVersion === 'latest') {
continue;
jdkVersion = majorVersion;
}
if (jdkVersion.split('.').length > 3) {
jdkVersion = this.transformToSemver(jdkVersion);
if (jdkVersion.includes('.')) {
const splits = jdkVersion.split('.');
jdkVersion =
splits.length >= 3 ? splits.slice(0, 3).join('.') : jdkVersion;
}
for (const edition in archMap) {
eligibleVersions.push({
os: platform,
architecture: arch,
jdk_version: jdkVersion,
checksum: (_a = archMap[edition].sha256) !== null && _a !== void 0 ? _a : '',
checksum: archMap[edition].sha256,
download_link: archMap[edition].download_url,
edition: edition,
image_type: 'jdk'
});
break; // Get the first available link to the JDK. In most cases it should point to the Extended version of JDK, in rare cases like with v17 it points to the Standard version (the only available).
}
}
}
const sortedVersions = this.sortParsedVersions(eligibleVersions);
return sortedVersions;
}
// Sorts versions in descending order as by default data in JSON isn't sorted
sortParsedVersions(eligibleVersions) {
const sortedVersions = eligibleVersions.sort((versionObj1, versionObj2) => {
const version1 = versionObj1.jdk_version;
const version2 = versionObj2.jdk_version;
return semver_1.default.compareBuild(version1, version2);
});
return sortedVersions.reverse();
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
transformToSemver(version) {
const splits = version.split('.');
const versionMainPart = splits.slice(0, 3).join('.');
const versionBuildPart = splits.slice(3).join('.');
return `${versionMainPart}+${versionBuildPart}`;
return eligibleVersions;
}
getPlatformOption() {
switch (process.platform) {

View File

@ -1,16 +1,11 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import semver from 'semver';
import fs from 'fs';
import path from 'path';
import {JavaBase} from '../base-installer';
import {
extractJdkFile,
getDownloadArchiveExtension,
isVersionSatisfies
} from '../../util';
import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
import {
JavaDownloadRelease,
@ -29,27 +24,25 @@ export class DragonwellDistribution extends JavaBase {
if (!this.stable) {
throw new Error('Early access versions are not supported');
}
if (this.packageType !== 'jdk') {
throw new Error('Dragonwell provides only the `jdk` package type');
let majorVersion = version;
if (version.includes('.')) {
const splits = version.split('.');
majorVersion = splits[0];
version = splits.length >= 3 ? splits.slice(0, 3).join('.') : version;
}
const edition = majorVersion == '17' ? 'Standard' : 'Extended';
const availableVersions = await this.getAvailableVersions();
const matchedVersions = availableVersions
.filter(item => {
return isVersionSatisfies(version, item.jdk_version);
})
.filter(item => item.jdk_version == version && item.edition == edition)
.map(item => {
return {
version: item.jdk_version,
url: item.download_link
} as JavaDownloadRelease;
});
if (!matchedVersions.length) {
throw new Error(
`Couldn't find any satisfied version for the specified java-version: "${version}".`
`Couldn't find any satisfied version for the specified: "${version}".`
);
}
@ -64,17 +57,15 @@ export class DragonwellDistribution extends JavaBase {
const availableVersionsUrl =
'https://raw.githubusercontent.com/dragonwell-releng/dragonwell-setup-java/main/releases.json';
const fetchedDragonwellVersions = (
await this.http.getJson<IDragonwellAllVersions>(availableVersionsUrl)
).result;
if (!fetchedDragonwellVersions) {
throw new Error(
const fetchedDragonwellVersions =
(await this.http.getJson<IDragonwellAllVersions>(availableVersionsUrl))
.result ?? {};
if (Object.keys(fetchedDragonwellVersions).length == 0) {
throw Error(
`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`
);
}
const availableVersions = this.parseVersions(
const availableVersions = this.getEligibleAvailableVersions(
platform,
arch,
fetchedDragonwellVersions
@ -118,7 +109,7 @@ export class DragonwellDistribution extends JavaBase {
return {version: javaRelease.version, path: javaPath};
}
private parseVersions(
private getEligibleAvailableVersions(
platform: string,
arch: string,
dragonwellVersions: IDragonwellAllVersions
@ -137,54 +128,28 @@ export class DragonwellDistribution extends JavaBase {
continue;
}
const archMap = platformMap[arch];
if (jdkVersion === 'latest') {
continue;
jdkVersion = majorVersion;
}
if (jdkVersion.split('.').length > 3) {
jdkVersion = this.transformToSemver(jdkVersion);
if (jdkVersion.includes('.')) {
const splits = jdkVersion.split('.');
jdkVersion =
splits.length >= 3 ? splits.slice(0, 3).join('.') : jdkVersion;
}
for (const edition in archMap) {
eligibleVersions.push({
os: platform,
architecture: arch,
jdk_version: jdkVersion,
checksum: archMap[edition].sha256 ?? '',
checksum: archMap[edition].sha256,
download_link: archMap[edition].download_url,
edition: edition,
image_type: 'jdk'
});
break; // Get the first available link to the JDK. In most cases it should point to the Extended version of JDK, in rare cases like with v17 it points to the Standard version (the only available).
}
}
}
const sortedVersions = this.sortParsedVersions(eligibleVersions);
return sortedVersions;
}
// Sorts versions in descending order as by default data in JSON isn't sorted
private sortParsedVersions(
eligibleVersions: IDragonwellVersions[]
): IDragonwellVersions[] {
const sortedVersions = eligibleVersions.sort((versionObj1, versionObj2) => {
const version1 = versionObj1.jdk_version;
const version2 = versionObj2.jdk_version;
return semver.compareBuild(version1, version2);
});
return sortedVersions.reverse();
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
private transformToSemver(version: string) {
const splits = version.split('.');
const versionMainPart = splits.slice(0, 3).join('.');
const versionBuildPart = splits.slice(3).join('.');
return `${versionMainPart}+${versionBuildPart}`;
return eligibleVersions;
}
private getPlatformOption(): string {