This commit is contained in:
qhy040404 2022-09-09 09:47:37 +08:00
parent d854b6da19
commit d0bb48b8b8
No known key found for this signature in database
GPG key ID: B1E14E493E9BB96C
9 changed files with 8895 additions and 8895 deletions

View file

@ -26,7 +26,7 @@ describe('cleanup', () => {
resetState(); resetState();
}); });
it('does not fail nor warn even when the save provess throws a ReserveCacheError', async () => { it('does not fail nor warn even when the save process throws a ReserveCacheError', async () => {
spyCacheSave.mockImplementation((paths: string[], key: string) => spyCacheSave.mockImplementation((paths: string[], key: string) =>
Promise.reject( Promise.reject(
new cache.ReserveCacheError( new cache.ReserveCacheError(

View file

@ -144,8 +144,8 @@ describe('getAvailableVersions', () => {
}); });
}); });
const mockPlatform = (distributon: CorrettoDistribution, platform: string) => { const mockPlatform = (distribution: CorrettoDistribution, platform: string) => {
distributon['getPlatformOption'] = () => platform; distribution['getPlatformOption'] = () => platform;
const mockedExtension = platform === 'windows' ? 'zip' : 'tar.gz'; const mockedExtension = platform === 'windows' ? 'zip' : 'tar.gz';
spyGetDownloadArchiveExtension.mockReturnValue(mockedExtension); spyGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
}; };

View file

@ -110,7 +110,7 @@ describe('findPackageForDownload', () => {
['15', '15.0.2+7'], ['15', '15.0.2+7'],
['9.0.0', '9.0.0+0'], ['9.0.0', '9.0.0+0'],
['9.0', '9.0.1+0'], ['9.0', '9.0.1+0'],
['8.0.262', '8.0.262+19'], // validate correct choise between [8.0.262.17, 8.0.262.19, 8.0.262.18] ['8.0.262', '8.0.262+19'], // validate correct choice between [8.0.262.17, 8.0.262.19, 8.0.262.18]
['8.0.262+17', '8.0.262+17'], ['8.0.262+17', '8.0.262+17'],
['15.0.1+8', '15.0.1+8'], ['15.0.1+8', '15.0.1+8'],
['15.0.1+9', '15.0.1+9'] ['15.0.1+9', '15.0.1+9']

2644
dist/cleanup/index.js vendored

File diff suppressed because it is too large Load diff

15100
dist/setup/index.js vendored

File diff suppressed because it is too large Load diff

View file

@ -116,7 +116,7 @@ export async function save(id: string) {
const packageManager = findPackageManager(id); const packageManager = findPackageManager(id);
const matchedKey = core.getState(CACHE_MATCHED_KEY); const matchedKey = core.getState(CACHE_MATCHED_KEY);
// Inputs are re-evaluted before the post action, so we want the original key used for restore // Inputs are re-evaluated before the post action, so we want the original key used for restore
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
if (!primaryKey) { if (!primaryKey) {

View file

@ -142,12 +142,12 @@ export abstract class JavaBase {
} }
protected setJavaDefault(version: string, toolPath: string) { protected setJavaDefault(version: string, toolPath: string) {
const majorVerssion = version.split('.')[0]; const majorVersion = version.split('.')[0];
core.exportVariable('JAVA_HOME', toolPath); core.exportVariable('JAVA_HOME', toolPath);
core.addPath(path.join(toolPath, 'bin')); core.addPath(path.join(toolPath, 'bin'));
core.setOutput('distribution', this.distribution); core.setOutput('distribution', this.distribution);
core.setOutput('path', toolPath); core.setOutput('path', toolPath);
core.setOutput('version', version); core.setOutput('version', version);
core.exportVariable(`JAVA_HOME_${majorVerssion}_${this.architecture.toUpperCase()}`, toolPath); core.exportVariable(`JAVA_HOME_${majorVersion}_${this.architecture.toUpperCase()}`, toolPath);
} }
} }

View file

@ -5,7 +5,7 @@ import path from 'path';
import { extractJdkFile, getDownloadArchiveExtension } from '../../util'; import { extractJdkFile, getDownloadArchiveExtension } from '../../util';
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 { ICorrettoAllAvailableVersions, ICorettoAvailableVersions } from './models'; import { ICorrettoAllAvailableVersions, ICorrettoAvailableVersions } from './models';
export class CorrettoDistribution extends JavaBase { export class CorrettoDistribution extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) { constructor(installerOptions: JavaInstallerOptions) {
@ -66,13 +66,13 @@ export class CorrettoDistribution extends JavaBase {
return resolvedVersion; return resolvedVersion;
} }
private async getAvailableVersions(): Promise<ICorettoAvailableVersions[]> { private async getAvailableVersions(): Promise<ICorrettoAvailableVersions[]> {
const platform = this.getPlatformOption(); const platform = this.getPlatformOption();
const arch = this.architecture; const arch = this.architecture;
const imageType = this.packageType; const imageType = this.packageType;
if (core.isDebug()) { if (core.isDebug()) {
console.time('coretto-retrieve-available-versions'); console.time('corretto-retrieve-available-versions');
} }
const availableVersionsUrl = const availableVersionsUrl =
@ -85,8 +85,8 @@ export class CorrettoDistribution extends JavaBase {
throw Error(`Could not fetch latest corretto versions from ${availableVersionsUrl}`); throw Error(`Could not fetch latest corretto versions from ${availableVersionsUrl}`);
} }
const eligbleVersions = fetchedCurrentVersions?.[platform]?.[arch]?.[imageType]; const eligibleVersions = fetchedCurrentVersions?.[platform]?.[arch]?.[imageType];
const availableVersions = this.getAvailableVersionsForPlatform(eligbleVersions); const availableVersions = this.getAvailableVersionsForPlatform(eligibleVersions);
if (core.isDebug()) { if (core.isDebug()) {
this.printAvailableVersions(availableVersions); this.printAvailableVersions(availableVersions);
@ -96,19 +96,19 @@ export class CorrettoDistribution extends JavaBase {
} }
private getAvailableVersionsForPlatform( private getAvailableVersionsForPlatform(
eligbleVersions: ICorrettoAllAvailableVersions['os']['arch']['imageType'] | undefined eligibleVersions: ICorrettoAllAvailableVersions['os']['arch']['imageType'] | undefined
): ICorettoAvailableVersions[] { ): ICorrettoAvailableVersions[] {
const availableVersions: ICorettoAvailableVersions[] = []; const availableVersions: ICorrettoAvailableVersions[] = [];
for (const version in eligbleVersions) { for (const version in eligibleVersions) {
const availableVersion = eligbleVersions[version]; const availableVersion = eligibleVersions[version];
for (const fileType in availableVersion) { for (const fileType in availableVersion) {
const skipNonExtractableBinaries = fileType != getDownloadArchiveExtension(); const skipNonExtractableBinaries = fileType != getDownloadArchiveExtension();
if (skipNonExtractableBinaries) { if (skipNonExtractableBinaries) {
continue; continue;
} }
const availableVersionDetails = availableVersion[fileType]; const availableVersionDetails = availableVersion[fileType];
const correttoVersion = this.getCorettoVersion(availableVersionDetails.resource); const correttoVersion = this.getCorrettoVersion(availableVersionDetails.resource);
availableVersions.push({ availableVersions.push({
checksum: availableVersionDetails.checksum, checksum: availableVersionDetails.checksum,
@ -124,9 +124,9 @@ export class CorrettoDistribution extends JavaBase {
return availableVersions; return availableVersions;
} }
private printAvailableVersions(availableVersions: ICorettoAvailableVersions[]) { private printAvailableVersions(availableVersions: ICorrettoAvailableVersions[]) {
core.startGroup('Print information about available versions'); core.startGroup('Print information about available versions');
console.timeEnd('coretto-retrieve-available-versions'); console.timeEnd('corretto-retrieve-available-versions');
console.log(`Available versions: [${availableVersions.length}]`); console.log(`Available versions: [${availableVersions.length}]`);
console.log( console.log(
availableVersions.map(item => `${item.version}: ${item.correttoVersion}`).join(', ') availableVersions.map(item => `${item.version}: ${item.correttoVersion}`).join(', ')
@ -135,7 +135,7 @@ export class CorrettoDistribution extends JavaBase {
} }
private getPlatformOption(): string { private getPlatformOption(): string {
// Coretto has its own platform names so we need to map them // Corretto has its own platform names so we need to map them
switch (process.platform) { switch (process.platform) {
case 'darwin': case 'darwin':
return 'macos'; return 'macos';
@ -146,7 +146,7 @@ export class CorrettoDistribution extends JavaBase {
} }
} }
private getCorettoVersion(resource: string): string { private getCorrettoVersion(resource: string): string {
const regex = /(\d+.+)\//; const regex = /(\d+.+)\//;
const match = regex.exec(resource); const match = regex.exec(resource);
if (match === null) { if (match === null) {

View file

@ -14,7 +14,7 @@ export interface ICorrettoAllAvailableVersions {
}; };
} }
export interface ICorettoAvailableVersions { export interface ICorrettoAvailableVersions {
version: string; version: string;
fileType: string; fileType: string;
checksum: string; checksum: string;