Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions __tests__/distributors/corretto-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
beforeAll,
afterAll
} from '@jest/globals';
import fs from 'fs';
import type {JavaInstallerOptions} from '../../src/distributions/base-models.js';
import {HttpClient} from '@actions/http-client';

Expand Down Expand Up @@ -323,3 +324,50 @@ describe('getAvailableVersions', () => {
spyGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
};
});

describe('Corretto getPlatformOption libc selection', () => {
const originalPlatform = Object.getOwnPropertyDescriptor(
process,
'platform'
) as PropertyDescriptor;

const setPlatform = (platform: NodeJS.Platform) =>
Object.defineProperty(process, 'platform', {
...originalPlatform,
value: platform
});

const distribution = new CorrettoDistribution({
version: '21',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});

afterEach(() => {
Object.defineProperty(process, 'platform', originalPlatform);
jest.restoreAllMocks();
});

it('selects the musl artifacts on Alpine', () => {
setPlatform('linux');
jest.spyOn(fs, 'existsSync').mockReturnValue(true);

expect(distribution['getPlatformOption']()).toBe('alpine');
});

it('selects the glibc artifacts on other Linux runners', () => {
setPlatform('linux');
jest.spyOn(fs, 'existsSync').mockReturnValue(false);

expect(distribution['getPlatformOption']()).toBe('linux');
});

it('does not probe for Alpine off Linux', () => {
setPlatform('darwin');
const existsSync = jest.spyOn(fs, 'existsSync');

expect(distribution['getPlatformOption']()).toBe('macos');
expect(existsSync).not.toHaveBeenCalled();
});
});
48 changes: 48 additions & 0 deletions __tests__/distributors/dragonwell-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
beforeAll,
afterAll
} from '@jest/globals';
import fs from 'fs';
import {HttpClient} from '@actions/http-client';

import manifestData from '../data/dragonwell.json' with {type: 'json'};
Expand Down Expand Up @@ -307,3 +308,50 @@ describe('getAvailableVersions', () => {
});
});
});

describe('Dragonwell getPlatformOption libc selection', () => {
const originalPlatform = Object.getOwnPropertyDescriptor(
process,
'platform'
) as PropertyDescriptor;

const setPlatform = (platform: NodeJS.Platform) =>
Object.defineProperty(process, 'platform', {
...originalPlatform,
value: platform
});

const distribution = new DragonwellDistribution({
version: '21',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});

afterEach(() => {
Object.defineProperty(process, 'platform', originalPlatform);
jest.restoreAllMocks();
});

it('selects the musl artifacts on Alpine', () => {
setPlatform('linux');
jest.spyOn(fs, 'existsSync').mockReturnValue(true);

expect(distribution['getPlatformOption']()).toBe('alpine-linux');
});

it('selects the glibc artifacts on other Linux runners', () => {
setPlatform('linux');
jest.spyOn(fs, 'existsSync').mockReturnValue(false);

expect(distribution['getPlatformOption']()).toBe('linux');
});

it('does not probe for Alpine off Linux', () => {
setPlatform('win32');
const existsSync = jest.spyOn(fs, 'existsSync');

expect(distribution['getPlatformOption']()).toBe('windows');
expect(existsSync).not.toHaveBeenCalled();
});
});
43 changes: 43 additions & 0 deletions __tests__/distributors/liberica-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
beforeAll,
afterAll
} from '@jest/globals';
import fs from 'fs';
import type {
ArchitectureOptions,
LibericaVersion
Expand Down Expand Up @@ -260,6 +261,16 @@ describe('findPackageForDownload', () => {
});

describe('getPlatformOption', () => {
beforeEach(() => {
// The linux row below is glibc, so pin the Alpine probe rather than
// letting it depend on the machine running the suite.
jest.spyOn(fs, 'existsSync').mockReturnValue(false);
});

afterEach(() => {
jest.restoreAllMocks();
});

const distributions = new LibericaDistributions({
architecture: 'x64',
version: '11',
Expand Down Expand Up @@ -335,3 +346,35 @@ describe('convertVersionToSemver', () => {
expect(actual).toEqual(expected);
});
});

describe('Liberica getPlatformOption libc selection', () => {
const distributions = new LibericaDistributions({
architecture: 'x64',
version: '11',
packageType: 'jdk',
checkLatest: false
});

afterEach(() => {
jest.restoreAllMocks();
});

it('selects the musl artifacts on Alpine', () => {
jest.spyOn(fs, 'existsSync').mockReturnValue(true);

expect(distributions['getPlatformOption']('linux')).toBe('linux-musl');
});

it('selects the glibc artifacts on other Linux runners', () => {
jest.spyOn(fs, 'existsSync').mockReturnValue(false);

expect(distributions['getPlatformOption']('linux')).toBe('linux');
});

it('does not probe for Alpine off Linux', () => {
const existsSync = jest.spyOn(fs, 'existsSync');

expect(distributions['getPlatformOption']('darwin')).toBe('macos');
expect(existsSync).not.toHaveBeenCalled();
});
});
43 changes: 43 additions & 0 deletions __tests__/distributors/liberica-nik-installer.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {jest, describe, it, expect, beforeEach, afterEach} from '@jest/globals';
import fs from 'fs';
import type {
ArchitectureOptions,
NikVersion
Expand Down Expand Up @@ -170,6 +171,16 @@ describe('findPackageForDownload', () => {
});

describe('getPlatformOption', () => {
beforeEach(() => {
// The linux row below is glibc, so pin the Alpine probe rather than
// letting it depend on the machine running the suite.
jest.spyOn(fs, 'existsSync').mockReturnValue(false);
});

afterEach(() => {
jest.restoreAllMocks();
});

const distributions = new LibericaNikDistributions({
architecture: 'x64',
version: '21',
Expand Down Expand Up @@ -217,3 +228,35 @@ describe('convertVersionToSemver', () => {
expect(actual).toEqual(expected);
});
});

describe('Liberica NIK getPlatformOption libc selection', () => {
const distributions = new LibericaNikDistributions({
architecture: 'x64',
version: '21',
packageType: 'jdk',
checkLatest: false
});

afterEach(() => {
jest.restoreAllMocks();
});

it('selects the musl artifacts on Alpine', () => {
jest.spyOn(fs, 'existsSync').mockReturnValue(true);

expect(distributions['getPlatformOption']('linux')).toBe('linux-musl');
});

it('selects the glibc artifacts on other Linux runners', () => {
jest.spyOn(fs, 'existsSync').mockReturnValue(false);

expect(distributions['getPlatformOption']('linux')).toBe('linux');
});

it('does not probe for Alpine off Linux', () => {
const existsSync = jest.spyOn(fs, 'existsSync');

expect(distributions['getPlatformOption']('darwin')).toBe('macos');
expect(existsSync).not.toHaveBeenCalled();
});
});
48 changes: 48 additions & 0 deletions __tests__/distributors/zulu-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
beforeAll,
afterAll
} from '@jest/globals';
import fs from 'fs';
import type {IZuluVersions} from '../../src/distributions/zulu/models.js';
import {HttpClient} from '@actions/http-client';
import os from 'os';
Expand Down Expand Up @@ -346,3 +347,50 @@ describe('findPackageForDownload', () => {
).rejects.toThrow(/No matching version found for SemVer/);
});
});

describe('Zulu getPlatformOption libc selection', () => {
const originalPlatform = Object.getOwnPropertyDescriptor(
process,
'platform'
) as PropertyDescriptor;

const setPlatform = (platform: NodeJS.Platform) =>
Object.defineProperty(process, 'platform', {
...originalPlatform,
value: platform
});

const distribution = new ZuluDistribution({
version: '21',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});

afterEach(() => {
Object.defineProperty(process, 'platform', originalPlatform);
jest.restoreAllMocks();
});

it('selects the musl artifacts on Alpine', () => {
setPlatform('linux');
jest.spyOn(fs, 'existsSync').mockReturnValue(true);

expect(distribution['getPlatformOption']()).toBe('linux_musl');
});

it('selects the glibc artifacts on other Linux runners', () => {
setPlatform('linux');
jest.spyOn(fs, 'existsSync').mockReturnValue(false);

expect(distribution['getPlatformOption']()).toBe('linux_glibc');
});

it('does not probe for Alpine off Linux', () => {
setPlatform('win32');
const existsSync = jest.spyOn(fs, 'existsSync');

expect(distribution['getPlatformOption']()).toBe('windows');
expect(existsSync).not.toHaveBeenCalled();
});
});
4 changes: 4 additions & 0 deletions dist/setup/126.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const modules = {
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4527);
/* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6242);
/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7444);




Expand Down Expand Up @@ -136,6 +138,8 @@ class CorrettoDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4
return 'macos';
case 'win32':
return 'windows';
case 'linux':
return (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_5__/* .isAlpineLinux */ .G6)() ? 'alpine' : 'linux';
default:
return process.platform;
}
Expand Down
16 changes: 9 additions & 7 deletions dist/setup/524.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export const modules = {
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(semver__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4527);
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3838);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9896);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6928);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7444);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9896);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6928);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_6__);




Expand All @@ -38,8 +40,8 @@ class LibericaNikDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODU
javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_2__/* .renameWinArchive */ .n2)(javaArchivePath);
}
const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_2__/* .extractJdkFile */ .PE)(javaArchivePath, extension);
const archiveName = fs__WEBPACK_IMPORTED_MODULE_4___default().readdirSync(extractedJavaPath)[0];
const archivePath = path__WEBPACK_IMPORTED_MODULE_5___default().join(extractedJavaPath, archiveName);
const archiveName = fs__WEBPACK_IMPORTED_MODULE_5___default().readdirSync(extractedJavaPath)[0];
const archivePath = path__WEBPACK_IMPORTED_MODULE_6___default().join(extractedJavaPath, archiveName);
const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_2__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
return { version: javaRelease.version, path: javaPath };
}
Expand Down Expand Up @@ -118,7 +120,7 @@ class LibericaNikDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODU
case 'cygwin':
return 'windows';
case 'linux':
return 'linux';
return (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_4__/* .isAlpineLinux */ .G6)(platform) ? 'linux-musl' : 'linux';
default:
throw new Error(`Platform '${platform}' is not supported. Supported platforms: ${supportedPlatform}`);
}
Expand Down
16 changes: 9 additions & 7 deletions dist/setup/63.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export const modules = {
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(semver__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4527);
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3838);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9896);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6928);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7444);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9896);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6928);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_6__);




Expand All @@ -38,8 +40,8 @@ class LibericaDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODULE_
javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_2__/* .renameWinArchive */ .n2)(javaArchivePath);
}
const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_2__/* .extractJdkFile */ .PE)(javaArchivePath, extension);
const archiveName = fs__WEBPACK_IMPORTED_MODULE_4___default().readdirSync(extractedJavaPath)[0];
const archivePath = path__WEBPACK_IMPORTED_MODULE_5___default().join(extractedJavaPath, archiveName);
const archiveName = fs__WEBPACK_IMPORTED_MODULE_5___default().readdirSync(extractedJavaPath)[0];
const archivePath = path__WEBPACK_IMPORTED_MODULE_6___default().join(extractedJavaPath, archiveName);
const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_2__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
return { version: javaRelease.version, path: javaPath };
}
Expand Down Expand Up @@ -118,7 +120,7 @@ class LibericaDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODULE_
case 'cygwin':
return 'windows';
case 'linux':
return 'linux';
return (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_4__/* .isAlpineLinux */ .G6)(platform) ? 'linux-musl' : 'linux';
case 'sunos':
return 'solaris';
default:
Expand Down
Loading
Loading