mirror of
https://gitea.com/actions/setup-java.git
synced 2025-04-06 23:39:37 +00:00
Add and configure ESLint and update configuration for Prettier (#458)
* Add ESLint config and update Prettier * Update test files * Rebuild action * Update docs * Update licenses * Update tsconfig * Rebuild action * Update tsconfig.json * Fix console.time calls * Rebuild action * Rebuild action on Linux
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
import { LibericaDistributions } from '../../src/distributions/liberica/installer';
|
||||
import { ArchitectureOptions, LibericaVersion } from '../../src/distributions/liberica/models';
|
||||
import { HttpClient } from '@actions/http-client';
|
||||
import {LibericaDistributions} from '../../src/distributions/liberica/installer';
|
||||
import {
|
||||
ArchitectureOptions,
|
||||
LibericaVersion
|
||||
} from '../../src/distributions/liberica/models';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
|
||||
const manifestData = require('../data/liberica.json') as LibericaVersion[];
|
||||
import manifestData from '../data/liberica.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
@ -13,7 +16,7 @@ describe('getAvailableVersions', () => {
|
||||
spyHttpClient.mockReturnValue({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: manifestData
|
||||
result: manifestData as LibericaVersion[]
|
||||
});
|
||||
});
|
||||
|
||||
@ -25,27 +28,57 @@ describe('getAvailableVersions', () => {
|
||||
|
||||
it.each([
|
||||
[
|
||||
{ version: '11.x', architecture: 'x86', packageType: 'jdk', checkLatest: false },
|
||||
{
|
||||
version: '11.x',
|
||||
architecture: 'x86',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
},
|
||||
'bundle-type=jdk&bitness=32&arch=x86&build-type=all'
|
||||
],
|
||||
[
|
||||
{ version: '11-ea', architecture: 'x86', packageType: 'jdk', checkLatest: false },
|
||||
{
|
||||
version: '11-ea',
|
||||
architecture: 'x86',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
},
|
||||
'bundle-type=jdk&bitness=32&arch=x86&build-type=ea'
|
||||
],
|
||||
[
|
||||
{ version: '16.0.2', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
{
|
||||
version: '16.0.2',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
},
|
||||
'bundle-type=jdk&bitness=64&arch=x86&build-type=all'
|
||||
],
|
||||
[
|
||||
{ version: '16.0.2', architecture: 'x64', packageType: 'jre', checkLatest: false },
|
||||
{
|
||||
version: '16.0.2',
|
||||
architecture: 'x64',
|
||||
packageType: 'jre',
|
||||
checkLatest: false
|
||||
},
|
||||
'bundle-type=jre&bitness=64&arch=x86&build-type=all'
|
||||
],
|
||||
[
|
||||
{ version: '8', architecture: 'armv7', packageType: 'jdk+fx', checkLatest: false },
|
||||
{
|
||||
version: '8',
|
||||
architecture: 'armv7',
|
||||
packageType: 'jdk+fx',
|
||||
checkLatest: false
|
||||
},
|
||||
'bundle-type=jdk-full&bitness=32&arch=arm&build-type=all'
|
||||
],
|
||||
[
|
||||
{ version: '8', architecture: 'aarch64', packageType: 'jre+fx', checkLatest: false },
|
||||
{
|
||||
version: '8',
|
||||
architecture: 'aarch64',
|
||||
packageType: 'jre+fx',
|
||||
checkLatest: false
|
||||
},
|
||||
'bundle-type=jre-full&bitness=64&arch=arm&build-type=all'
|
||||
]
|
||||
])('build correct url for %s -> %s', async (input, urlParams) => {
|
||||
@ -67,8 +100,8 @@ describe('getAvailableVersions', () => {
|
||||
arch: string;
|
||||
};
|
||||
it.each([
|
||||
['amd64', { bitness: '64', arch: 'x86' }],
|
||||
['arm64', { bitness: '64', arch: 'arm' }]
|
||||
['amd64', {bitness: '64', arch: 'x86'}],
|
||||
['arm64', {bitness: '64', arch: 'arm'}]
|
||||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
async (osArch: string, distroArch: DistroArch) => {
|
||||
@ -109,21 +142,24 @@ describe('getAvailableVersions', () => {
|
||||
|
||||
describe('getArchitectureOptions', () => {
|
||||
it.each([
|
||||
['x86', { bitness: '32', arch: 'x86' }],
|
||||
['x64', { bitness: '64', arch: 'x86' }],
|
||||
['armv7', { bitness: '32', arch: 'arm' }],
|
||||
['aarch64', { bitness: '64', arch: 'arm' }],
|
||||
['ppc64le', { bitness: '64', arch: 'ppc' }]
|
||||
] as [string, ArchitectureOptions][])('parse architecture %s -> %s', (input, expected) => {
|
||||
const distributions = new LibericaDistributions({
|
||||
architecture: input,
|
||||
checkLatest: false,
|
||||
packageType: '',
|
||||
version: ''
|
||||
});
|
||||
['x86', {bitness: '32', arch: 'x86'}],
|
||||
['x64', {bitness: '64', arch: 'x86'}],
|
||||
['armv7', {bitness: '32', arch: 'arm'}],
|
||||
['aarch64', {bitness: '64', arch: 'arm'}],
|
||||
['ppc64le', {bitness: '64', arch: 'ppc'}]
|
||||
] as [string, ArchitectureOptions][])(
|
||||
'parse architecture %s -> %s',
|
||||
(input, expected) => {
|
||||
const distributions = new LibericaDistributions({
|
||||
architecture: input,
|
||||
checkLatest: false,
|
||||
packageType: '',
|
||||
version: ''
|
||||
});
|
||||
|
||||
expect(distributions['getArchitectureOptions']()).toEqual(expected);
|
||||
});
|
||||
expect(distributions['getArchitectureOptions']()).toEqual(expected);
|
||||
}
|
||||
);
|
||||
|
||||
it.each(['armv6', 's390x'])('not support architecture %s', input => {
|
||||
const distributions = new LibericaDistributions({
|
||||
@ -199,9 +235,9 @@ describe('getPlatformOption', () => {
|
||||
it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd'])(
|
||||
'not support os version %s',
|
||||
input => {
|
||||
expect(() => distributions['getPlatformOption'](input as NodeJS.Platform)).toThrow(
|
||||
/Platform '\w+' is not supported\. Supported platforms: .+/
|
||||
);
|
||||
expect(() =>
|
||||
distributions['getPlatformOption'](input as NodeJS.Platform)
|
||||
).toThrow(/Platform '\w+' is not supported\. Supported platforms: .+/);
|
||||
}
|
||||
);
|
||||
});
|
||||
@ -215,9 +251,33 @@ describe('convertVersionToSemver', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ featureVersion: 11, interimVersion: 0, updateVersion: 12, buildVersion: 7 }, '11.0.12+7'],
|
||||
[{ featureVersion: 11, interimVersion: 0, updateVersion: 12, buildVersion: 0 }, '11.0.12'],
|
||||
[{ featureVersion: 11, interimVersion: 0, updateVersion: 0, buildVersion: 13 }, '11.0.0+13']
|
||||
[
|
||||
{
|
||||
featureVersion: 11,
|
||||
interimVersion: 0,
|
||||
updateVersion: 12,
|
||||
buildVersion: 7
|
||||
},
|
||||
'11.0.12+7'
|
||||
],
|
||||
[
|
||||
{
|
||||
featureVersion: 11,
|
||||
interimVersion: 0,
|
||||
updateVersion: 12,
|
||||
buildVersion: 0
|
||||
},
|
||||
'11.0.12'
|
||||
],
|
||||
[
|
||||
{
|
||||
featureVersion: 11,
|
||||
interimVersion: 0,
|
||||
updateVersion: 0,
|
||||
buildVersion: 13
|
||||
},
|
||||
'11.0.0+13'
|
||||
]
|
||||
])('%s -> %s', (input, expected) => {
|
||||
const actual = distributions['convertVersionToSemver']({
|
||||
downloadUrl: '',
|
||||
|
Reference in New Issue
Block a user