Updates
This commit is contained in:
parent
dff91e4ff3
commit
204a88328a
@ -1,9 +1,9 @@
|
|||||||
import { HttpClient } from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
|
|
||||||
import { JavaInstallerOptions } from '../../src/distributions/base-models';
|
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||||
import { SemeruDistribution } from '../../src/distributions/semeru/installer';
|
import {SemeruDistribution} from '../../src/distributions/semeru/installer';
|
||||||
|
|
||||||
let manifestData = require('../data/semeru.json') as [];
|
import manifestData from '../data/semeru.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
let spyHttpClient: jest.SpyInstance;
|
let spyHttpClient: jest.SpyInstance;
|
||||||
@ -25,26 +25,47 @@ describe('getAvailableVersions', () => {
|
|||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
{ version: '16', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
{
|
||||||
|
version: '16',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '16', architecture: 'x86', packageType: 'jdk', checkLatest: false },
|
{
|
||||||
|
version: '16',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '16', architecture: 'x64', packageType: 'jre', checkLatest: false },
|
{
|
||||||
|
version: '16',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jre',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ version: '16', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
{
|
||||||
|
version: '16',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
||||||
]
|
]
|
||||||
])(
|
])(
|
||||||
'build correct url for %s',
|
'build correct url for %s',
|
||||||
async (installerOptions: JavaInstallerOptions, expectedParameters) => {
|
async (installerOptions: JavaInstallerOptions, expectedParameters) => {
|
||||||
const distribution = new SemeruDistribution(installerOptions);
|
const distribution = new SemeruDistribution(installerOptions);
|
||||||
const baseUrl = 'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D';
|
const baseUrl =
|
||||||
|
'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D';
|
||||||
const expectedUrl = `${baseUrl}?project=jdk&vendor=ibm&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
|
const expectedUrl = `${baseUrl}?project=jdk&vendor=ibm&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
|
||||||
distribution['getPlatformOption'] = () => 'mac';
|
distribution['getPlatformOption'] = () => 'mac';
|
||||||
|
|
||||||
@ -116,7 +137,7 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
const resolvedVersion = await distribution['findPackageForDownload'](input);
|
const resolvedVersion = await distribution['findPackageForDownload'](input);
|
||||||
expect(resolvedVersion.version).toBe(expected);
|
expect(resolvedVersion.version).toBe(expected);
|
||||||
});
|
});
|
||||||
@ -128,10 +149,10 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
await expect(distribution['findPackageForDownload']('9.0.8')).rejects.toThrowError(
|
await expect(
|
||||||
/Could not find satisfied version for SemVer */
|
distribution['findPackageForDownload']('9.0.8')
|
||||||
);
|
).rejects.toThrow(/Could not find satisfied version for SemVer */);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('version is not found', async () => {
|
it('version is not found', async () => {
|
||||||
@ -141,8 +162,8 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrowError(
|
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrow(
|
||||||
/Could not find satisfied version for SemVer */
|
/Could not find satisfied version for SemVer */
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -155,7 +176,7 @@ describe('findPackageForDownload', () => {
|
|||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => [];
|
distribution['getAvailableVersions'] = async () => [];
|
||||||
await expect(distribution['findPackageForDownload']('8')).rejects.toThrowError(
|
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||||
/Could not find satisfied version for SemVer */
|
/Could not find satisfied version for SemVer */
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -169,7 +190,7 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
const resolvedVersion = await distribution['findPackageForDownload']('8');
|
const resolvedVersion = await distribution['findPackageForDownload']('8');
|
||||||
expect(resolvedVersion.version).not.toBeNull();
|
expect(resolvedVersion.version).not.toBeNull();
|
||||||
}
|
}
|
||||||
@ -185,7 +206,7 @@ describe('findPackageForDownload', () => {
|
|||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => [];
|
distribution['getAvailableVersions'] = async () => [];
|
||||||
await expect(distribution['findPackageForDownload']('8')).rejects.toThrowError(
|
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||||
`Unsupported architecture for IBM Semeru: ${arch}, the following are supported: x64, x86, ppc64le, ppc64, s390x, aarch64`
|
`Unsupported architecture for IBM Semeru: ${arch}, the following are supported: x64, x86, ppc64le, ppc64, s390x, aarch64`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -200,14 +221,26 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
await expect(distribution['findPackageForDownload'](version)).rejects.toThrowError(
|
await expect(
|
||||||
|
distribution['findPackageForDownload'](version)
|
||||||
|
).rejects.toThrow(
|
||||||
'IBM Semeru does not provide builds for early access versions'
|
'IBM Semeru does not provide builds for early access versions'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
it.each(['jdk+fx', 'jre+fx', 'test', 'test2', 'jdk-fx', 'javafx', 'jdk-javafx', 'ibm', ' '])(
|
it.each([
|
||||||
|
'jdk+fx',
|
||||||
|
'jre+fx',
|
||||||
|
'test',
|
||||||
|
'test2',
|
||||||
|
'jdk-fx',
|
||||||
|
'javafx',
|
||||||
|
'jdk-javafx',
|
||||||
|
'ibm',
|
||||||
|
' '
|
||||||
|
])(
|
||||||
'rejects incorrect `%s` Semeru package type',
|
'rejects incorrect `%s` Semeru package type',
|
||||||
async (packageType: string) => {
|
async (packageType: string) => {
|
||||||
const distribution = new SemeruDistribution({
|
const distribution = new SemeruDistribution({
|
||||||
@ -216,8 +249,8 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: packageType,
|
packageType: packageType,
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
await expect(distribution['findPackageForDownload']('8')).rejects.toThrowError(
|
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||||
'IBM Semeru only provide `jdk` and `jre` package types'
|
'IBM Semeru only provide `jdk` and `jre` package types'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -232,7 +265,7 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: packageType,
|
packageType: packageType,
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
const resolvedVersion = await distribution['findPackageForDownload']('8');
|
const resolvedVersion = await distribution['findPackageForDownload']('8');
|
||||||
await expect(resolvedVersion.version).toMatch(/8[0-9.]+/);
|
await expect(resolvedVersion.version).toMatch(/8[0-9.]+/);
|
||||||
}
|
}
|
||||||
@ -247,7 +280,7 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
})
|
})
|
||||||
).toThrowError(
|
).toThrow(
|
||||||
"The string 'jdk-16.0.2+7_openj9-0.27.1' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information"
|
"The string 'jdk-16.0.2+7_openj9-0.27.1' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
8789
dist/setup/index.js
vendored
8789
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,21 +1,38 @@
|
|||||||
import { JavaBase } from '../base-installer';
|
import {JavaBase} from '../base-installer';
|
||||||
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models';
|
import {
|
||||||
|
JavaDownloadRelease,
|
||||||
|
JavaInstallerOptions,
|
||||||
|
JavaInstallerResults
|
||||||
|
} from '../base-models';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import { extractJdkFile, getDownloadArchiveExtension, isVersionSatisfies } from '../../util';
|
import {
|
||||||
|
extractJdkFile,
|
||||||
|
getDownloadArchiveExtension,
|
||||||
|
isVersionSatisfies
|
||||||
|
} from '../../util';
|
||||||
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 fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { ISemeruAvailableVersions } from './models';
|
import {ISemeruAvailableVersions} from './models';
|
||||||
|
|
||||||
const supportedArchitectures = ['x64', 'x86', 'ppc64le', 'ppc64', 's390x', 'aarch64'];
|
const supportedArchitectures = [
|
||||||
|
'x64',
|
||||||
|
'x86',
|
||||||
|
'ppc64le',
|
||||||
|
'ppc64',
|
||||||
|
's390x',
|
||||||
|
'aarch64'
|
||||||
|
];
|
||||||
|
|
||||||
export class SemeruDistribution extends JavaBase {
|
export class SemeruDistribution extends JavaBase {
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
super('IBM_Semeru', installerOptions);
|
super('IBM_Semeru', installerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async findPackageForDownload(version: string): Promise<JavaDownloadRelease> {
|
protected async findPackageForDownload(
|
||||||
|
version: string
|
||||||
|
): Promise<JavaDownloadRelease> {
|
||||||
if (!supportedArchitectures.includes(this.architecture)) {
|
if (!supportedArchitectures.includes(this.architecture)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unsupported architecture for IBM Semeru: ${
|
`Unsupported architecture for IBM Semeru: ${
|
||||||
@ -25,7 +42,9 @@ export class SemeruDistribution extends JavaBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.stable) {
|
if (!this.stable) {
|
||||||
throw new Error('IBM Semeru does not provide builds for early access versions');
|
throw new Error(
|
||||||
|
'IBM Semeru does not provide builds for early access versions'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.packageType !== 'jdk' && this.packageType !== 'jre') {
|
if (this.packageType !== 'jdk' && this.packageType !== 'jre') {
|
||||||
@ -52,9 +71,12 @@ export class SemeruDistribution extends JavaBase {
|
|||||||
return -semver.compareBuild(a.version, b.version);
|
return -semver.compareBuild(a.version, b.version);
|
||||||
});
|
});
|
||||||
|
|
||||||
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
const resolvedFullVersion =
|
||||||
|
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||||
if (!resolvedFullVersion) {
|
if (!resolvedFullVersion) {
|
||||||
const availableOptions = availableVersionsWithBinaries.map(item => item.version).join(', ');
|
const availableOptions = availableVersionsWithBinaries
|
||||||
|
.map(item => item.version)
|
||||||
|
.join(', ');
|
||||||
const availableOptionsMessage = availableOptions
|
const availableOptionsMessage = availableOptions
|
||||||
? `\nAvailable versions: ${availableOptions}`
|
? `\nAvailable versions: ${availableOptions}`
|
||||||
: '';
|
: '';
|
||||||
@ -66,27 +88,34 @@ export class SemeruDistribution extends JavaBase {
|
|||||||
return resolvedFullVersion;
|
return resolvedFullVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async downloadTool(javaRelease: JavaDownloadRelease): Promise<JavaInstallerResults> {
|
protected async downloadTool(
|
||||||
let javaPath: string;
|
javaRelease: JavaDownloadRelease
|
||||||
let extractedJavaPath: string;
|
): Promise<JavaInstallerResults> {
|
||||||
|
|
||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
let extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
|
|
||||||
extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const extractedJavaPath: string = await extractJdkFile(
|
||||||
|
javaArchivePath,
|
||||||
|
extension
|
||||||
|
);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||||
const version = this.getToolcacheVersionName(javaRelease.version);
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
|
|
||||||
javaPath = await tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture);
|
const javaPath: string = await tc.cacheDir(
|
||||||
|
archivePath,
|
||||||
|
this.toolcacheFolderName,
|
||||||
|
version,
|
||||||
|
this.architecture
|
||||||
|
);
|
||||||
|
|
||||||
return { version: javaRelease.version, path: javaPath };
|
return {version: javaRelease.version, path: javaPath};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get toolcacheFolderName(): string {
|
protected get toolcacheFolderName(): string {
|
||||||
@ -100,7 +129,7 @@ export class SemeruDistribution extends JavaBase {
|
|||||||
const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions
|
const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions
|
||||||
const releaseType = this.stable ? 'ga' : 'ea';
|
const releaseType = this.stable ? 'ga' : 'ea';
|
||||||
|
|
||||||
console.time('semeru-retrieve-available-versions');
|
console.time('semeru-retrieve-available-versions'); // eslint-disable-line no-console
|
||||||
|
|
||||||
const baseRequestArguments = [
|
const baseRequestArguments = [
|
||||||
`project=jdk`,
|
`project=jdk`,
|
||||||
@ -124,7 +153,9 @@ export class SemeruDistribution extends JavaBase {
|
|||||||
const availableVersionsUrl = `https://api.adoptopenjdk.net/v3/assets/version/${versionRange}?${requestArguments}`;
|
const availableVersionsUrl = `https://api.adoptopenjdk.net/v3/assets/version/${versionRange}?${requestArguments}`;
|
||||||
if (core.isDebug() && page_index === 0) {
|
if (core.isDebug() && page_index === 0) {
|
||||||
// url is identical except page_index so print it once for debug
|
// url is identical except page_index so print it once for debug
|
||||||
core.debug(`Gathering available versions from '${availableVersionsUrl}'`);
|
core.debug(
|
||||||
|
`Gathering available versions from '${availableVersionsUrl}'`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
@ -133,13 +164,14 @@ export class SemeruDistribution extends JavaBase {
|
|||||||
|
|
||||||
let iTypedResponse = null;
|
let iTypedResponse = null;
|
||||||
try {
|
try {
|
||||||
iTypedResponse = await this.http.getJson<ISemeruAvailableVersions[]>(availableVersionsUrl);
|
iTypedResponse = await this.http.getJson<ISemeruAvailableVersions[]>(
|
||||||
|
availableVersionsUrl
|
||||||
|
);
|
||||||
} catch (element) {
|
} catch (element) {
|
||||||
console.log('error', element);
|
console.log('error', element); // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
const paginationPage = iTypedResponse!.result;
|
||||||
const paginationPage = iTypedResponse.result;
|
|
||||||
if (paginationPage === null || paginationPage.length === 0) {
|
if (paginationPage === null || paginationPage.length === 0) {
|
||||||
// break infinity loop because we have reached end of pagination
|
// break infinity loop because we have reached end of pagination
|
||||||
break;
|
break;
|
||||||
@ -151,10 +183,12 @@ export class SemeruDistribution extends JavaBase {
|
|||||||
|
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
core.startGroup('Print information about available IBM Semeru versions');
|
core.startGroup('Print information about available IBM Semeru versions');
|
||||||
console.timeEnd('semeru-retrieve-available-versions');
|
console.timeEnd('semeru-retrieve-available-versions'); // eslint-disable-line no-console
|
||||||
console.log(`Available versions: [${availableVersions.length}]`);
|
core.debug(`Available versions: [${availableVersions.length}]`);
|
||||||
console.log(availableVersions.map(item => item.version_data.semver).join(', '));
|
core.debug(
|
||||||
console.log(JSON.stringify(availableVersions));
|
availableVersions.map(item => item.version_data.semver).join(', ')
|
||||||
|
);
|
||||||
|
core.debug(JSON.stringify(availableVersions));
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user