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

View File

@ -1,6 +1,9 @@
import {HttpClient} from '@actions/http-client'; import {HttpClient} from '@actions/http-client';
import * as semver from 'semver';
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer'; import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
import {IDragonwellAllVersions} from '../../src/distributions/dragonwell/models';
import * as utils from '../../src/util'; import * as utils from '../../src/util';
import os from 'os';
import manifestData from '../data/dragonwell.json'; import manifestData from '../data/dragonwell.json';
@ -41,17 +44,17 @@ describe('getAvailableVersions', () => {
describe('getAvailableVersions', () => { describe('getAvailableVersions', () => {
it.each([ it.each([
['8', 'x86', 'linux', 0], ['8', 'x86', 'linux', 0],
['8', 'aarch64', 'linux', 24], ['8', 'aarch64', 'linux', 33],
['8.6.6', 'x64', 'linux', 27], ['8.6.6', 'x64', 'linux', 36],
['8', 'x86', 'anolis', 0], ['8', 'x86', 'anolis', 0],
['8', 'x86', 'windows', 0], ['8', 'x86', 'windows', 0],
['8', 'x86', 'mac', 0], ['8', 'x86', 'mac', 0],
['11', 'x64', 'linux', 27], ['11', 'x64', 'linux', 36],
['11', 'aarch64', 'linux', 24], ['11', 'aarch64', 'linux', 33],
['17', 'riscv', 'linux', 0], ['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 ( async (
jdkVersion: string, jdkVersion: string,
arch: 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' '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 ( async (
jdkVersion: string, jdkVersion: string,
platform: string, platform: string,
@ -189,7 +192,7 @@ describe('getAvailableVersions', () => {
['11', 'macos', 'aarch64'], ['11', 'macos', 'aarch64'],
['17', 'linux', 'riscv'] ['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) => { async (jdkVersion: string, platform: string, arch: string) => {
const distribution = new DragonwellDistribution({ const distribution = new DragonwellDistribution({
version: jdkVersion, version: jdkVersion,
@ -202,26 +205,9 @@ describe('getAvailableVersions', () => {
await expect( await expect(
distribution['findPackageForDownload'](jdkVersion) distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow( ).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; exports.DragonwellDistribution = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const tc = __importStar(__nccwpck_require__(7784)); const tc = __importStar(__nccwpck_require__(7784));
const semver_1 = __importDefault(__nccwpck_require__(1383));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const path_1 = __importDefault(__nccwpck_require__(1017)); const path_1 = __importDefault(__nccwpck_require__(1017));
const base_installer_1 = __nccwpck_require__(9741); const base_installer_1 = __nccwpck_require__(9741);
@ -102658,14 +102657,16 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
if (!this.stable) { if (!this.stable) {
throw new Error('Early access versions are not supported'); throw new Error('Early access versions are not supported');
} }
if (this.packageType !== 'jdk') { let majorVersion = version;
throw new Error('Dragonwell provides only the `jdk` package type'); 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 availableVersions = yield this.getAvailableVersions();
const matchedVersions = availableVersions const matchedVersions = availableVersions
.filter(item => { .filter(item => item.jdk_version == version && item.edition == edition)
return util_1.isVersionSatisfies(version, item.jdk_version);
})
.map(item => { .map(item => {
return { return {
version: item.jdk_version, version: item.jdk_version,
@ -102673,22 +102674,24 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
}; };
}); });
if (!matchedVersions.length) { 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]; const resolvedVersion = matchedVersions[0];
return resolvedVersion; return resolvedVersion;
}); });
} }
getAvailableVersions() { getAvailableVersions() {
var _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const platform = this.getPlatformOption(); const platform = this.getPlatformOption();
const arch = this.distributionArchitecture(); const arch = this.distributionArchitecture();
const availableVersionsUrl = 'https://raw.githubusercontent.com/dragonwell-releng/dragonwell-setup-java/main/releases.json'; const availableVersionsUrl = 'https://raw.githubusercontent.com/dragonwell-releng/dragonwell-setup-java/main/releases.json';
const fetchedDragonwellVersions = (yield this.http.getJson(availableVersionsUrl)).result; const fetchedDragonwellVersions = (_a = (yield this.http.getJson(availableVersionsUrl))
if (!fetchedDragonwellVersions) { .result) !== null && _a !== void 0 ? _a : {};
throw new Error(`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`); 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()) { if (core.isDebug()) {
core.startGroup('Print information about available versions'); core.startGroup('Print information about available versions');
core.debug(availableVersions.map(item => item.jdk_version).join(', ')); 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 }; return { version: javaRelease.version, path: javaPath };
}); });
} }
parseVersions(platform, arch, dragonwellVersions) { getEligibleAvailableVersions(platform, arch, dragonwellVersions) {
var _a;
const eligibleVersions = []; const eligibleVersions = [];
for (const majorVersion in dragonwellVersions) { for (const majorVersion in dragonwellVersions) {
const majorVersionMap = dragonwellVersions[majorVersion]; const majorVersionMap = dragonwellVersions[majorVersion];
@ -102726,44 +102728,27 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
} }
const archMap = platformMap[arch]; const archMap = platformMap[arch];
if (jdkVersion === 'latest') { if (jdkVersion === 'latest') {
continue; jdkVersion = majorVersion;
} }
if (jdkVersion.split('.').length > 3) { if (jdkVersion.includes('.')) {
jdkVersion = this.transformToSemver(jdkVersion); const splits = jdkVersion.split('.');
jdkVersion =
splits.length >= 3 ? splits.slice(0, 3).join('.') : jdkVersion;
} }
for (const edition in archMap) { for (const edition in archMap) {
eligibleVersions.push({ eligibleVersions.push({
os: platform, os: platform,
architecture: arch, architecture: arch,
jdk_version: jdkVersion, jdk_version: jdkVersion,
checksum: (_a = archMap[edition].sha256) !== null && _a !== void 0 ? _a : '', checksum: archMap[edition].sha256,
download_link: archMap[edition].download_url, download_link: archMap[edition].download_url,
edition: edition, edition: edition,
image_type: 'jdk' 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 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}`;
} }
getPlatformOption() { getPlatformOption() {
switch (process.platform) { switch (process.platform) {

View File

@ -1,16 +1,11 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import semver from 'semver';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import {JavaBase} from '../base-installer'; import {JavaBase} from '../base-installer';
import { import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
extractJdkFile,
getDownloadArchiveExtension,
isVersionSatisfies
} from '../../util';
import {IDragonwellVersions, IDragonwellAllVersions} from './models'; import {IDragonwellVersions, IDragonwellAllVersions} from './models';
import { import {
JavaDownloadRelease, JavaDownloadRelease,
@ -29,27 +24,25 @@ export class DragonwellDistribution extends JavaBase {
if (!this.stable) { if (!this.stable) {
throw new Error('Early access versions are not supported'); throw new Error('Early access versions are not supported');
} }
let majorVersion = version;
if (this.packageType !== 'jdk') { if (version.includes('.')) {
throw new Error('Dragonwell provides only the `jdk` package type'); 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 availableVersions = await this.getAvailableVersions();
const matchedVersions = availableVersions const matchedVersions = availableVersions
.filter(item => { .filter(item => item.jdk_version == version && item.edition == edition)
return isVersionSatisfies(version, item.jdk_version);
})
.map(item => { .map(item => {
return { return {
version: item.jdk_version, version: item.jdk_version,
url: item.download_link url: item.download_link
} as JavaDownloadRelease; } as JavaDownloadRelease;
}); });
if (!matchedVersions.length) { if (!matchedVersions.length) {
throw new Error( 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 = const availableVersionsUrl =
'https://raw.githubusercontent.com/dragonwell-releng/dragonwell-setup-java/main/releases.json'; 'https://raw.githubusercontent.com/dragonwell-releng/dragonwell-setup-java/main/releases.json';
const fetchedDragonwellVersions = ( const fetchedDragonwellVersions =
await this.http.getJson<IDragonwellAllVersions>(availableVersionsUrl) (await this.http.getJson<IDragonwellAllVersions>(availableVersionsUrl))
).result; .result ?? {};
if (Object.keys(fetchedDragonwellVersions).length == 0) {
if (!fetchedDragonwellVersions) { throw Error(
throw new Error(
`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}` `Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`
); );
} }
const availableVersions = this.getEligibleAvailableVersions(
const availableVersions = this.parseVersions(
platform, platform,
arch, arch,
fetchedDragonwellVersions fetchedDragonwellVersions
@ -118,7 +109,7 @@ export class DragonwellDistribution extends JavaBase {
return {version: javaRelease.version, path: javaPath}; return {version: javaRelease.version, path: javaPath};
} }
private parseVersions( private getEligibleAvailableVersions(
platform: string, platform: string,
arch: string, arch: string,
dragonwellVersions: IDragonwellAllVersions dragonwellVersions: IDragonwellAllVersions
@ -137,54 +128,28 @@ export class DragonwellDistribution extends JavaBase {
continue; continue;
} }
const archMap = platformMap[arch]; const archMap = platformMap[arch];
if (jdkVersion === 'latest') { if (jdkVersion === 'latest') {
continue; jdkVersion = majorVersion;
} }
if (jdkVersion.includes('.')) {
if (jdkVersion.split('.').length > 3) { const splits = jdkVersion.split('.');
jdkVersion = this.transformToSemver(jdkVersion); jdkVersion =
splits.length >= 3 ? splits.slice(0, 3).join('.') : jdkVersion;
} }
for (const edition in archMap) { for (const edition in archMap) {
eligibleVersions.push({ eligibleVersions.push({
os: platform, os: platform,
architecture: arch, architecture: arch,
jdk_version: jdkVersion, jdk_version: jdkVersion,
checksum: archMap[edition].sha256 ?? '', checksum: archMap[edition].sha256,
download_link: archMap[edition].download_url, download_link: archMap[edition].download_url,
edition: edition, edition: edition,
image_type: 'jdk' 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).
} }
} }
} }
return eligibleVersions;
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}`;
} }
private getPlatformOption(): string { private getPlatformOption(): string {