mirror of
https://github.com/actions/setup-java.git
synced 2026-06-26 07:04:30 +00:00
Compare commits
10 Commits
784bb48b94
...
f6f5db9e04
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6f5db9e04 | ||
|
|
5f1dbfa8af | ||
|
|
2c43893557 | ||
|
|
8036ba5657 | ||
|
|
446ddaedf9 | ||
|
|
9799c80ea4 | ||
|
|
253a04374f | ||
|
|
e51fc6409d | ||
|
|
f3b981e123 | ||
|
|
ef8523a614 |
30
.github/workflows/e2e-versions.yml
vendored
30
.github/workflows/e2e-versions.yml
vendored
@ -29,12 +29,17 @@ jobs:
|
||||
'liberica',
|
||||
'microsoft',
|
||||
'semeru',
|
||||
'corretto'
|
||||
'corretto',
|
||||
'dragonwell'
|
||||
] # 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
|
||||
@ -45,6 +50,13 @@ 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
|
||||
@ -75,6 +87,12 @@ 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
|
||||
@ -96,7 +114,10 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['temurin', 'zulu', 'liberica']
|
||||
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||
exclude:
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -119,7 +140,10 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['temurin', 'zulu', 'liberica']
|
||||
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||
exclude:
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
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';
|
||||
|
||||
@ -44,17 +41,17 @@ describe('getAvailableVersions', () => {
|
||||
describe('getAvailableVersions', () => {
|
||||
it.each([
|
||||
['8', 'x86', 'linux', 0],
|
||||
['8', 'aarch64', 'linux', 33],
|
||||
['8.6.6', 'x64', 'linux', 36],
|
||||
['8', 'aarch64', 'linux', 24],
|
||||
['8.6.6', 'x64', 'linux', 27],
|
||||
['8', 'x86', 'anolis', 0],
|
||||
['8', 'x86', 'windows', 0],
|
||||
['8', 'x86', 'mac', 0],
|
||||
['11', 'x64', 'linux', 36],
|
||||
['11', 'aarch64', 'linux', 33],
|
||||
['11', 'x64', 'linux', 27],
|
||||
['11', 'aarch64', 'linux', 24],
|
||||
['17', 'riscv', 'linux', 0],
|
||||
['16.0.1', 'x64', 'linux', 36]
|
||||
['16.0.1', 'x64', 'linux', 27]
|
||||
])(
|
||||
'load available versions',
|
||||
'should get right number of available versions from JSON',
|
||||
async (
|
||||
jdkVersion: string,
|
||||
arch: string,
|
||||
@ -163,7 +160,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'
|
||||
]
|
||||
])(
|
||||
'test for download link',
|
||||
'should return proper link according to the specified java-version, platform and arch',
|
||||
async (
|
||||
jdkVersion: string,
|
||||
platform: string,
|
||||
@ -192,7 +189,7 @@ describe('getAvailableVersions', () => {
|
||||
['11', 'macos', 'aarch64'],
|
||||
['17', 'linux', 'riscv']
|
||||
])(
|
||||
'test for unsupported version',
|
||||
'should throw when required version of JDK can not be found in the JSON',
|
||||
async (jdkVersion: string, platform: string, arch: string) => {
|
||||
const distribution = new DragonwellDistribution({
|
||||
version: jdkVersion,
|
||||
@ -205,9 +202,26 @@ describe('getAvailableVersions', () => {
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](jdkVersion)
|
||||
).rejects.toThrow(
|
||||
`Couldn't find any satisfied version for the specified: "${jdkVersion}".`
|
||||
`Couldn't find any satisfied version for the specified java-version: "${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
59
dist/setup/index.js
vendored
@ -102644,6 +102644,7 @@ 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);
|
||||
@ -102657,16 +102658,14 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
|
||||
if (!this.stable) {
|
||||
throw new Error('Early access versions are not supported');
|
||||
}
|
||||
let majorVersion = version;
|
||||
if (version.includes('.')) {
|
||||
const splits = version.split('.');
|
||||
majorVersion = splits[0];
|
||||
version = splits.length >= 3 ? splits.slice(0, 3).join('.') : version;
|
||||
if (this.packageType !== 'jdk') {
|
||||
throw new Error('Dragonwell provides only the `jdk` package type');
|
||||
}
|
||||
const edition = majorVersion == '17' ? 'Standard' : 'Extended';
|
||||
const availableVersions = yield this.getAvailableVersions();
|
||||
const matchedVersions = availableVersions
|
||||
.filter(item => item.jdk_version == version && item.edition == edition)
|
||||
.filter(item => {
|
||||
return util_1.isVersionSatisfies(version, item.jdk_version);
|
||||
})
|
||||
.map(item => {
|
||||
return {
|
||||
version: item.jdk_version,
|
||||
@ -102674,24 +102673,22 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
|
||||
};
|
||||
});
|
||||
if (!matchedVersions.length) {
|
||||
throw new Error(`Couldn't find any satisfied version for the specified: "${version}".`);
|
||||
throw new Error(`Couldn't find any satisfied version for the specified java-version: "${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 = (_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 fetchedDragonwellVersions = (yield this.http.getJson(availableVersionsUrl)).result;
|
||||
if (!fetchedDragonwellVersions) {
|
||||
throw new Error(`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`);
|
||||
}
|
||||
const availableVersions = this.getEligibleAvailableVersions(platform, arch, fetchedDragonwellVersions);
|
||||
const availableVersions = this.parseVersions(platform, arch, fetchedDragonwellVersions);
|
||||
if (core.isDebug()) {
|
||||
core.startGroup('Print information about available versions');
|
||||
core.debug(availableVersions.map(item => item.jdk_version).join(', '));
|
||||
@ -102713,7 +102710,8 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
|
||||
return { version: javaRelease.version, path: javaPath };
|
||||
});
|
||||
}
|
||||
getEligibleAvailableVersions(platform, arch, dragonwellVersions) {
|
||||
parseVersions(platform, arch, dragonwellVersions) {
|
||||
var _a;
|
||||
const eligibleVersions = [];
|
||||
for (const majorVersion in dragonwellVersions) {
|
||||
const majorVersionMap = dragonwellVersions[majorVersion];
|
||||
@ -102728,27 +102726,44 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
|
||||
}
|
||||
const archMap = platformMap[arch];
|
||||
if (jdkVersion === 'latest') {
|
||||
jdkVersion = majorVersion;
|
||||
continue;
|
||||
}
|
||||
if (jdkVersion.includes('.')) {
|
||||
const splits = jdkVersion.split('.');
|
||||
jdkVersion =
|
||||
splits.length >= 3 ? splits.slice(0, 3).join('.') : jdkVersion;
|
||||
if (jdkVersion.split('.').length > 3) {
|
||||
jdkVersion = this.transformToSemver(jdkVersion);
|
||||
}
|
||||
for (const edition in archMap) {
|
||||
eligibleVersions.push({
|
||||
os: platform,
|
||||
architecture: arch,
|
||||
jdk_version: jdkVersion,
|
||||
checksum: archMap[edition].sha256,
|
||||
checksum: (_a = archMap[edition].sha256) !== null && _a !== void 0 ? _a : '',
|
||||
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).
|
||||
}
|
||||
}
|
||||
}
|
||||
return eligibleVersions;
|
||||
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}`;
|
||||
}
|
||||
getPlatformOption() {
|
||||
switch (process.platform) {
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
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} from '../../util';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
isVersionSatisfies
|
||||
} from '../../util';
|
||||
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
@ -24,25 +29,27 @@ export class DragonwellDistribution extends JavaBase {
|
||||
if (!this.stable) {
|
||||
throw new Error('Early access versions are not supported');
|
||||
}
|
||||
let majorVersion = version;
|
||||
if (version.includes('.')) {
|
||||
const splits = version.split('.');
|
||||
majorVersion = splits[0];
|
||||
version = splits.length >= 3 ? splits.slice(0, 3).join('.') : version;
|
||||
|
||||
if (this.packageType !== 'jdk') {
|
||||
throw new Error('Dragonwell provides only the `jdk` package type');
|
||||
}
|
||||
const edition = majorVersion == '17' ? 'Standard' : 'Extended';
|
||||
|
||||
const availableVersions = await this.getAvailableVersions();
|
||||
|
||||
const matchedVersions = availableVersions
|
||||
.filter(item => item.jdk_version == version && item.edition == edition)
|
||||
.filter(item => {
|
||||
return isVersionSatisfies(version, item.jdk_version);
|
||||
})
|
||||
.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: "${version}".`
|
||||
`Couldn't find any satisfied version for the specified java-version: "${version}".`
|
||||
);
|
||||
}
|
||||
|
||||
@ -57,15 +64,17 @@ 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 (Object.keys(fetchedDragonwellVersions).length == 0) {
|
||||
throw Error(
|
||||
const fetchedDragonwellVersions = (
|
||||
await this.http.getJson<IDragonwellAllVersions>(availableVersionsUrl)
|
||||
).result;
|
||||
|
||||
if (!fetchedDragonwellVersions) {
|
||||
throw new Error(
|
||||
`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`
|
||||
);
|
||||
}
|
||||
const availableVersions = this.getEligibleAvailableVersions(
|
||||
|
||||
const availableVersions = this.parseVersions(
|
||||
platform,
|
||||
arch,
|
||||
fetchedDragonwellVersions
|
||||
@ -109,7 +118,7 @@ export class DragonwellDistribution extends JavaBase {
|
||||
return {version: javaRelease.version, path: javaPath};
|
||||
}
|
||||
|
||||
private getEligibleAvailableVersions(
|
||||
private parseVersions(
|
||||
platform: string,
|
||||
arch: string,
|
||||
dragonwellVersions: IDragonwellAllVersions
|
||||
@ -128,28 +137,54 @@ export class DragonwellDistribution extends JavaBase {
|
||||
continue;
|
||||
}
|
||||
const archMap = platformMap[arch];
|
||||
|
||||
if (jdkVersion === 'latest') {
|
||||
jdkVersion = majorVersion;
|
||||
continue;
|
||||
}
|
||||
if (jdkVersion.includes('.')) {
|
||||
const splits = jdkVersion.split('.');
|
||||
jdkVersion =
|
||||
splits.length >= 3 ? splits.slice(0, 3).join('.') : jdkVersion;
|
||||
|
||||
if (jdkVersion.split('.').length > 3) {
|
||||
jdkVersion = this.transformToSemver(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).
|
||||
}
|
||||
}
|
||||
}
|
||||
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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user