mirror of
https://github.com/actions/setup-java.git
synced 2025-04-19 17:36:45 +00:00
added test cases for windows and linux for zulu, liberica and microsoft
This commit is contained in:
parent
65505d41c2
commit
e707d79108
12 changed files with 1089 additions and 61 deletions
1
.github/.tool-versions
vendored
1
.github/.tool-versions
vendored
|
@ -1 +0,0 @@
|
||||||
java jdk17.0.7
|
|
12
.github/workflows/e2e-versions.yml
vendored
12
.github/workflows/e2e-versions.yml
vendored
|
@ -288,7 +288,6 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution: ['temurin', 'microsoft', 'corretto']
|
distribution: ['temurin', 'microsoft', 'corretto']
|
||||||
java-version-file-array: [.java-version, .tool-versions]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -301,7 +300,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
distribution: ${{ matrix.distribution }}
|
distribution: ${{ matrix.distribution }}
|
||||||
java-version: 11
|
java-version: 11
|
||||||
java-version-file: './${{ matrix.java-version-file-array }}'
|
java-version-file: '.java-version'
|
||||||
- name: Verify Java
|
- name: Verify Java
|
||||||
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
|
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
@ -314,7 +313,6 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto']
|
distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto']
|
||||||
java-version-file-array: [.java-version, .tool-versions]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -326,7 +324,7 @@ jobs:
|
||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
distribution: ${{ matrix.distribution }}
|
distribution: ${{ matrix.distribution }}
|
||||||
java-version-file: './${{ matrix.java-version-file-array }}'
|
java-version-file: '.java-version'
|
||||||
- name: Verify Java
|
- name: Verify Java
|
||||||
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
|
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
@ -339,7 +337,6 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution: ['adopt', 'adopt-openj9', 'zulu']
|
distribution: ['adopt', 'adopt-openj9', 'zulu']
|
||||||
java-version-file-array: [.java-version, .tool-versions]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -351,7 +348,7 @@ jobs:
|
||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
distribution: ${{ matrix.distribution }}
|
distribution: ${{ matrix.distribution }}
|
||||||
java-version-file: './${{ matrix.java-version-file-array }}'
|
java-version-file: '.java-version'
|
||||||
- name: Verify Java
|
- name: Verify Java
|
||||||
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
|
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
@ -364,7 +361,6 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution: ['adopt', 'zulu', 'liberica']
|
distribution: ['adopt', 'zulu', 'liberica']
|
||||||
java-version-file-array: [.java-version, .tool-versions]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -376,7 +372,7 @@ jobs:
|
||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
distribution: ${{ matrix.distribution }}
|
distribution: ${{ matrix.distribution }}
|
||||||
java-version-file: './${{ matrix.java-version-file-array }}'
|
java-version-file: '.java-version'
|
||||||
- name: Verify Java
|
- name: Verify Java
|
||||||
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
|
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
@ -430,5 +430,32 @@
|
||||||
"interimVersion": 0,
|
"interimVersion": 0,
|
||||||
"version": "8u232+9",
|
"version": "8u232+9",
|
||||||
"featureVersion": 8
|
"featureVersion": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buildVersion": 14,
|
||||||
|
"updateVersion": 2,
|
||||||
|
"patchVersion": 0,
|
||||||
|
"downloadUrl": "https://download.bell-sw.com/java/21.0.2+14/bellsoft-jdk21.0.2+14-windows-aarch64.zip",
|
||||||
|
"interimVersion": 0,
|
||||||
|
"version": "21.0.2+14",
|
||||||
|
"featureVersion": 21
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buildVersion": 13,
|
||||||
|
"updateVersion": 10,
|
||||||
|
"patchVersion": 0,
|
||||||
|
"downloadUrl": "https://download.bell-sw.com/java/17.0.10+13/bellsoft-jdk17.0.10+13-windows-aarch64.zip",
|
||||||
|
"interimVersion": 0,
|
||||||
|
"version": "17.0.10+13",
|
||||||
|
"featureVersion": 17
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buildVersion": 13,
|
||||||
|
"updateVersion": 10,
|
||||||
|
"patchVersion": 0,
|
||||||
|
"downloadUrl":"https://download.bell-sw.com/java/17.0.10+13/bellsoft-jdk17.0.10+13-linux-amd64.tar.gz",
|
||||||
|
"interimVersion": 0,
|
||||||
|
"version": "17.0.10+13",
|
||||||
|
"featureVersion": 17
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -243,5 +243,20 @@
|
||||||
"name": "zulu15.29.15-ca-jdk15.0.2-macosx_x64.tar.gz",
|
"name": "zulu15.29.15-ca-jdk15.0.2-macosx_x64.tar.gz",
|
||||||
"zulu_version": [15, 29, 15, 0],
|
"zulu_version": [15, 29, 15, 0],
|
||||||
"jdk_version": [15, 0, 2, 7]
|
"jdk_version": [15, 0, 2, 7]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 12446,
|
||||||
|
"url": "https://cdn.azul.com/zulu/bin/zulu17.48.15-ca-jdk17.0.10-windows_aarch64.zip",
|
||||||
|
"name": "zulu17.48.15-ca-jdk17.0.10-win_aarhc4.zip",
|
||||||
|
"zulu_version": [17, 48, 15, 0],
|
||||||
|
"jdk_version": [17, 0, 10, 7]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 12447,
|
||||||
|
"url": "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz",
|
||||||
|
"name": "zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz",
|
||||||
|
"zulu_version": [21, 32, 17, 0],
|
||||||
|
"jdk_version": [21, 0, 2, 6]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
290
__tests__/distributors/liberica-linux-installer.test.ts
Normal file
290
__tests__/distributors/liberica-linux-installer.test.ts
Normal file
|
@ -0,0 +1,290 @@
|
||||||
|
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';
|
||||||
|
|
||||||
|
import manifestData from '../data/liberica.json';
|
||||||
|
|
||||||
|
describe('getAvailableVersions', () => {
|
||||||
|
let spyHttpClient: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||||
|
spyHttpClient.mockReturnValue({
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: manifestData as LibericaVersion[]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
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
|
||||||
|
},
|
||||||
|
'bundle-type=jdk&bitness=32&arch=x86&build-type=ea'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
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
|
||||||
|
},
|
||||||
|
'bundle-type=jre&bitness=64&arch=x86&build-type=all'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
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
|
||||||
|
},
|
||||||
|
'bundle-type=jre-full&bitness=64&arch=arm&build-type=all'
|
||||||
|
]
|
||||||
|
])('build correct url for %s -> %s', async (input, urlParams) => {
|
||||||
|
const additionalParams =
|
||||||
|
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
|
||||||
|
'updateVersion%2CbuildVersion';
|
||||||
|
const distribution = new LibericaDistributions(input);
|
||||||
|
distribution['getPlatformOption'] = () => 'linux';
|
||||||
|
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=linux&${urlParams}${additionalParams}`;
|
||||||
|
|
||||||
|
await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||||
|
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
type DistroArch = {
|
||||||
|
bitness: string;
|
||||||
|
arch: string;
|
||||||
|
};
|
||||||
|
it.each([
|
||||||
|
['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) => {
|
||||||
|
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
||||||
|
|
||||||
|
const distribution = new LibericaDistributions({
|
||||||
|
version: '17',
|
||||||
|
architecture: '', // to get default value
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const additionalParams =
|
||||||
|
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
|
||||||
|
'updateVersion%2CbuildVersion';
|
||||||
|
distribution['getPlatformOption'] = () => 'linux';
|
||||||
|
|
||||||
|
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=linux&bundle-type=jdk&bitness=${distroArch.bitness}&arch=${distroArch.arch}&build-type=all${additionalParams}`;
|
||||||
|
|
||||||
|
await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||||
|
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('load available versions', async () => {
|
||||||
|
const distribution = new LibericaDistributions({
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
|
expect(availableVersions).toEqual(manifestData);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
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: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(distributions['getArchitectureOptions']()).toEqual(expected);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['armv6', 's390x'])('not support architecture %s', input => {
|
||||||
|
const distributions = new LibericaDistributions({
|
||||||
|
architecture: input,
|
||||||
|
checkLatest: false,
|
||||||
|
packageType: '',
|
||||||
|
version: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(() => distributions['getArchitectureOptions']()).toThrow(
|
||||||
|
/Architecture '\w+' is not supported\. Supported architectures: .*/
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('findPackageForDownload', () => {
|
||||||
|
let distribution: LibericaDistributions;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
distribution = new LibericaDistributions({
|
||||||
|
version: '',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['8', '8.0.302+8'],
|
||||||
|
['11.x', '11.0.12+7'],
|
||||||
|
['8.0', '8.0.302+8'],
|
||||||
|
['11.0.x', '11.0.12+7'],
|
||||||
|
['15', '15.0.2+10'],
|
||||||
|
['15.0', '15.0.2+10'],
|
||||||
|
['15.0.0', '15.0.0+36'],
|
||||||
|
['8.0.232', '8.0.232+10'],
|
||||||
|
['8.0.232+9', '8.0.232+9'],
|
||||||
|
['15.0.2+8', '15.0.2+8'],
|
||||||
|
['15.0.2+10', '15.0.2+10']
|
||||||
|
])('version is %s -> %s', async (input, expected) => {
|
||||||
|
const result = await distribution['findPackageForDownload'](input);
|
||||||
|
expect(result.version).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error', async () => {
|
||||||
|
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
|
||||||
|
/Could not find satisfied version for semver */
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getPlatformOption', () => {
|
||||||
|
const distributions = new LibericaDistributions({
|
||||||
|
architecture: 'x64',
|
||||||
|
version: '11',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['linux', 'linux'],
|
||||||
|
['darwin', 'macos'],
|
||||||
|
['win32', 'windows'],
|
||||||
|
['cygwin', 'windows'],
|
||||||
|
['sunos', 'solaris']
|
||||||
|
])('os version %s -> %s', (input, expected) => {
|
||||||
|
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
|
||||||
|
|
||||||
|
expect(actual).toEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
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: .+/);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('convertVersionToSemver', () => {
|
||||||
|
const distributions = new LibericaDistributions({
|
||||||
|
architecture: 'x64',
|
||||||
|
version: '11',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
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'
|
||||||
|
]
|
||||||
|
])('%s -> %s', (input, expected) => {
|
||||||
|
const actual = distributions['convertVersionToSemver']({
|
||||||
|
downloadUrl: '',
|
||||||
|
version: '',
|
||||||
|
...input
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(actual).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
290
__tests__/distributors/liberica-windows-installer.test.ts
Normal file
290
__tests__/distributors/liberica-windows-installer.test.ts
Normal file
|
@ -0,0 +1,290 @@
|
||||||
|
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';
|
||||||
|
|
||||||
|
import manifestData from '../data/liberica.json';
|
||||||
|
|
||||||
|
describe('getAvailableVersions', () => {
|
||||||
|
let spyHttpClient: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||||
|
spyHttpClient.mockReturnValue({
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: manifestData as LibericaVersion[]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
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
|
||||||
|
},
|
||||||
|
'bundle-type=jdk&bitness=32&arch=x86&build-type=ea'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
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
|
||||||
|
},
|
||||||
|
'bundle-type=jre&bitness=64&arch=x86&build-type=all'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
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
|
||||||
|
},
|
||||||
|
'bundle-type=jre-full&bitness=64&arch=arm&build-type=all'
|
||||||
|
]
|
||||||
|
])('build correct url for %s -> %s', async (input, urlParams) => {
|
||||||
|
const additionalParams =
|
||||||
|
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
|
||||||
|
'updateVersion%2CbuildVersion';
|
||||||
|
const distribution = new LibericaDistributions(input);
|
||||||
|
distribution['getPlatformOption'] = () => 'windows';
|
||||||
|
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=windows&${urlParams}${additionalParams}`;
|
||||||
|
|
||||||
|
await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||||
|
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
type DistroArch = {
|
||||||
|
bitness: string;
|
||||||
|
arch: string;
|
||||||
|
};
|
||||||
|
it.each([
|
||||||
|
['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) => {
|
||||||
|
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
||||||
|
|
||||||
|
const distribution = new LibericaDistributions({
|
||||||
|
version: '17',
|
||||||
|
architecture: '', // to get default value
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const additionalParams =
|
||||||
|
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
|
||||||
|
'updateVersion%2CbuildVersion';
|
||||||
|
distribution['getPlatformOption'] = () => 'windows';
|
||||||
|
|
||||||
|
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=windows&bundle-type=jdk&bitness=${distroArch.bitness}&arch=${distroArch.arch}&build-type=all${additionalParams}`;
|
||||||
|
|
||||||
|
await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||||
|
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('load available versions', async () => {
|
||||||
|
const distribution = new LibericaDistributions({
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
|
expect(availableVersions).toEqual(manifestData);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
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: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(distributions['getArchitectureOptions']()).toEqual(expected);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['armv6', 's390x'])('not support architecture %s', input => {
|
||||||
|
const distributions = new LibericaDistributions({
|
||||||
|
architecture: input,
|
||||||
|
checkLatest: false,
|
||||||
|
packageType: '',
|
||||||
|
version: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(() => distributions['getArchitectureOptions']()).toThrow(
|
||||||
|
/Architecture '\w+' is not supported\. Supported architectures: .*/
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('findPackageForDownload', () => {
|
||||||
|
let distribution: LibericaDistributions;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
distribution = new LibericaDistributions({
|
||||||
|
version: '',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['8', '8.0.302+8'],
|
||||||
|
['11.x', '11.0.12+7'],
|
||||||
|
['8.0', '8.0.302+8'],
|
||||||
|
['11.0.x', '11.0.12+7'],
|
||||||
|
['15', '15.0.2+10'],
|
||||||
|
['15.0', '15.0.2+10'],
|
||||||
|
['15.0.0', '15.0.0+36'],
|
||||||
|
['8.0.232', '8.0.232+10'],
|
||||||
|
['8.0.232+9', '8.0.232+9'],
|
||||||
|
['15.0.2+8', '15.0.2+8'],
|
||||||
|
['15.0.2+10', '15.0.2+10']
|
||||||
|
])('version is %s -> %s', async (input, expected) => {
|
||||||
|
const result = await distribution['findPackageForDownload'](input);
|
||||||
|
expect(result.version).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error', async () => {
|
||||||
|
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
|
||||||
|
/Could not find satisfied version for semver */
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getPlatformOption', () => {
|
||||||
|
const distributions = new LibericaDistributions({
|
||||||
|
architecture: 'x64',
|
||||||
|
version: '11',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['linux', 'linux'],
|
||||||
|
['darwin', 'macos'],
|
||||||
|
['win32', 'windows'],
|
||||||
|
['cygwin', 'windows'],
|
||||||
|
['sunos', 'solaris']
|
||||||
|
])('os version %s -> %s', (input, expected) => {
|
||||||
|
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
|
||||||
|
|
||||||
|
expect(actual).toEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
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: .+/);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('convertVersionToSemver', () => {
|
||||||
|
const distributions = new LibericaDistributions({
|
||||||
|
architecture: 'x64',
|
||||||
|
version: '11',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
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'
|
||||||
|
]
|
||||||
|
])('%s -> %s', (input, expected) => {
|
||||||
|
const actual = distributions['convertVersionToSemver']({
|
||||||
|
downloadUrl: '',
|
||||||
|
version: '',
|
||||||
|
...input
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(actual).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
229
__tests__/distributors/zulu-linux-installer.test.ts
Normal file
229
__tests__/distributors/zulu-linux-installer.test.ts
Normal file
|
@ -0,0 +1,229 @@
|
||||||
|
import {HttpClient} from '@actions/http-client';
|
||||||
|
import * as semver from 'semver';
|
||||||
|
import {ZuluDistribution} from '../../src/distributions/zulu/installer';
|
||||||
|
import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||||
|
import * as utils from '../../src/util';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
|
import manifestData from '../data/zulu-releases-default.json';
|
||||||
|
|
||||||
|
describe('getAvailableVersions', () => {
|
||||||
|
let spyHttpClient: jest.SpyInstance;
|
||||||
|
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||||
|
spyHttpClient.mockReturnValue({
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: manifestData as IZuluVersions[]
|
||||||
|
});
|
||||||
|
|
||||||
|
spyUtilGetDownloadArchiveExtension = jest.spyOn(
|
||||||
|
utils,
|
||||||
|
'getDownloadArchiveExtension'
|
||||||
|
);
|
||||||
|
spyUtilGetDownloadArchiveExtension.mockReturnValue('zip');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '11-ea',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '8',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '8',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jre',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=linux&ext=zip&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '8',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk+fx',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=linux&ext=zip&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '8',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jre+fx',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=linux&ext=zip&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'arm64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=64&release_status=ga'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'arm',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=&release_status=ga'
|
||||||
|
]
|
||||||
|
])('build correct url for %s -> %s', async (input, parsedUrl) => {
|
||||||
|
const distribution = new ZuluDistribution(input);
|
||||||
|
distribution['getPlatformOption'] = () => 'linux';
|
||||||
|
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/${parsedUrl}`;
|
||||||
|
|
||||||
|
await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||||
|
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
type DistroArch = {
|
||||||
|
bitness: string;
|
||||||
|
arch: string;
|
||||||
|
};
|
||||||
|
it.each([
|
||||||
|
['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) => {
|
||||||
|
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
||||||
|
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '17',
|
||||||
|
architecture: '', // to get default value
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getPlatformOption'] = () => 'linux';
|
||||||
|
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=${distroArch.arch}&hw_bitness=${distroArch.bitness}&release_status=ga`;
|
||||||
|
|
||||||
|
await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||||
|
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('load available versions', async () => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
|
expect(availableVersions).toHaveLength(manifestData.length);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getArchitectureOptions', () => {
|
||||||
|
it.each([
|
||||||
|
[{architecture: 'x64'}, {arch: 'x86', hw_bitness: '64', abi: ''}],
|
||||||
|
[{architecture: 'x86'}, {arch: 'x86', hw_bitness: '32', abi: ''}],
|
||||||
|
[{architecture: 'x32'}, {arch: 'x32', hw_bitness: '', abi: ''}],
|
||||||
|
[{architecture: 'arm'}, {arch: 'arm', hw_bitness: '', abi: ''}]
|
||||||
|
])('%s -> %s', (input, expected) => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '11',
|
||||||
|
architecture: input.architecture,
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
expect(distribution['getArchitectureOptions']()).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('findPackageForDownload', () => {
|
||||||
|
it.each([
|
||||||
|
['8', '8.0.282+8'],
|
||||||
|
['11.x', '11.0.10+9'],
|
||||||
|
['8.0', '8.0.282+8'],
|
||||||
|
['11.0.x', '11.0.10+9'],
|
||||||
|
['15', '15.0.2+7'],
|
||||||
|
['9.0.0', '9.0.0+0'],
|
||||||
|
['9.0', '9.0.1+0'],
|
||||||
|
['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'],
|
||||||
|
['15.0.1+8', '15.0.1+8'],
|
||||||
|
['15.0.1+9', '15.0.1+9']
|
||||||
|
])('version is %s -> %s', async (input, expected) => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: input,
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
const result = await distribution['findPackageForDownload'](
|
||||||
|
distribution['version']
|
||||||
|
);
|
||||||
|
expect(result.version).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '',
|
||||||
|
architecture: 'arm64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
const result = await distribution['findPackageForDownload']('21.0.2');
|
||||||
|
expect(result.url).toBe(
|
||||||
|
'https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error', async () => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '18',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
await expect(
|
||||||
|
distribution['findPackageForDownload'](distribution['version'])
|
||||||
|
).rejects.toThrow(/Could not find satisfied version for semver */);
|
||||||
|
});
|
||||||
|
});
|
229
__tests__/distributors/zulu-windows-installer.test.ts
Normal file
229
__tests__/distributors/zulu-windows-installer.test.ts
Normal file
|
@ -0,0 +1,229 @@
|
||||||
|
import {HttpClient} from '@actions/http-client';
|
||||||
|
import * as semver from 'semver';
|
||||||
|
import {ZuluDistribution} from '../../src/distributions/zulu/installer';
|
||||||
|
import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||||
|
import * as utils from '../../src/util';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
|
import manifestData from '../data/zulu-releases-default.json';
|
||||||
|
|
||||||
|
describe('getAvailableVersions', () => {
|
||||||
|
let spyHttpClient: jest.SpyInstance;
|
||||||
|
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||||
|
spyHttpClient.mockReturnValue({
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: manifestData as IZuluVersions[]
|
||||||
|
});
|
||||||
|
|
||||||
|
spyUtilGetDownloadArchiveExtension = jest.spyOn(
|
||||||
|
utils,
|
||||||
|
'getDownloadArchiveExtension'
|
||||||
|
);
|
||||||
|
spyUtilGetDownloadArchiveExtension.mockReturnValue('zip');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '11-ea',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '8',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '8',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jre',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=windows&ext=zip&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '8',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk+fx',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=windows&ext=zip&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '8',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jre+fx',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=windows&ext=zip&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'arm64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=64&release_status=ga'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'arm',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=&release_status=ga'
|
||||||
|
]
|
||||||
|
])('build correct url for %s -> %s', async (input, parsedUrl) => {
|
||||||
|
const distribution = new ZuluDistribution(input);
|
||||||
|
distribution['getPlatformOption'] = () => 'windows';
|
||||||
|
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/${parsedUrl}`;
|
||||||
|
|
||||||
|
await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||||
|
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
type DistroArch = {
|
||||||
|
bitness: string;
|
||||||
|
arch: string;
|
||||||
|
};
|
||||||
|
it.each([
|
||||||
|
['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) => {
|
||||||
|
jest.spyOn(os, 'arch').mockReturnValue(osArch);
|
||||||
|
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '17',
|
||||||
|
architecture: '', // to get default value
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getPlatformOption'] = () => 'windows';
|
||||||
|
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=${distroArch.arch}&hw_bitness=${distroArch.bitness}&release_status=ga`;
|
||||||
|
|
||||||
|
await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||||
|
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('load available versions', async () => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
|
expect(availableVersions).toHaveLength(manifestData.length);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getArchitectureOptions', () => {
|
||||||
|
it.each([
|
||||||
|
[{architecture: 'x64'}, {arch: 'x86', hw_bitness: '64', abi: ''}],
|
||||||
|
[{architecture: 'x86'}, {arch: 'x86', hw_bitness: '32', abi: ''}],
|
||||||
|
[{architecture: 'x32'}, {arch: 'x32', hw_bitness: '', abi: ''}],
|
||||||
|
[{architecture: 'arm'}, {arch: 'arm', hw_bitness: '', abi: ''}]
|
||||||
|
])('%s -> %s', (input, expected) => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '11',
|
||||||
|
architecture: input.architecture,
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
expect(distribution['getArchitectureOptions']()).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('findPackageForDownload', () => {
|
||||||
|
it.each([
|
||||||
|
['8', '8.0.282+8'],
|
||||||
|
['11.x', '11.0.10+9'],
|
||||||
|
['8.0', '8.0.282+8'],
|
||||||
|
['11.0.x', '11.0.10+9'],
|
||||||
|
['15', '15.0.2+7'],
|
||||||
|
['9.0.0', '9.0.0+0'],
|
||||||
|
['9.0', '9.0.1+0'],
|
||||||
|
['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'],
|
||||||
|
['15.0.1+8', '15.0.1+8'],
|
||||||
|
['15.0.1+9', '15.0.1+9']
|
||||||
|
])('version is %s -> %s', async (input, expected) => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: input,
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
const result = await distribution['findPackageForDownload'](
|
||||||
|
distribution['version']
|
||||||
|
);
|
||||||
|
expect(result.version).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '',
|
||||||
|
architecture: 'arm64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
const result = await distribution['findPackageForDownload']('17.0.10');
|
||||||
|
expect(result.url).toBe(
|
||||||
|
'https://cdn.azul.com/zulu/bin/zulu17.48.15-ca-jdk17.0.10-windows_aarch64.zip'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error', async () => {
|
||||||
|
const distribution = new ZuluDistribution({
|
||||||
|
version: '18',
|
||||||
|
architecture: 'x86',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
|
await expect(
|
||||||
|
distribution['findPackageForDownload'](distribution['version'])
|
||||||
|
).rejects.toThrow(/Could not find satisfied version for semver */);
|
||||||
|
});
|
||||||
|
});
|
16
dist/setup/index.js
vendored
16
dist/setup/index.js
vendored
|
@ -123685,15 +123685,9 @@ class LibericaDistributions extends base_installer_1.JavaBase {
|
||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
if (process.platform === 'win32' &&
|
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')) {
|
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
|
@ -124641,15 +124635,9 @@ class ZuluDistribution extends base_installer_1.JavaBase {
|
||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
let javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
if (process.platform === 'win32' &&
|
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')) {
|
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
|
||||||
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
|
||||||
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
|
|
|
@ -31,19 +31,10 @@ export class LibericaDistributions extends JavaBase {
|
||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
if (
|
|
||||||
process.platform === 'win32' &&
|
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')
|
|
||||||
) {
|
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
await fs.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
|
||||||
|
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
|
|
|
@ -33,12 +33,6 @@
|
||||||
"arch": "aarch64",
|
"arch": "aarch64",
|
||||||
"platform": "linux",
|
"platform": "linux",
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-aarch64.tar.gz"
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-aarch64.tar.gz"
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-21.0.0-windows-aarch64.zip",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"platform": "win32",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-aarch64.zip"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -76,13 +70,7 @@
|
||||||
"arch": "aarch64",
|
"arch": "aarch64",
|
||||||
"platform": "linux",
|
"platform": "linux",
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-aarch64.tar.gz"
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-aarch64.tar.gz"
|
||||||
},
|
}
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-17.0.7-windows-aarch64.zip",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"platform": "win32",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-aarch64.zip"
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -341,12 +329,6 @@
|
||||||
"arch": "aarch64",
|
"arch": "aarch64",
|
||||||
"platform": "linux",
|
"platform": "linux",
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-linux-aarch64.tar.gz"
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-linux-aarch64.tar.gz"
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "microsoft-jdk-11.0.19-windows-aarch64.zip",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"platform": "win32",
|
|
||||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-windows-aarch64.zip"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -76,18 +76,10 @@ export class ZuluDistribution extends JavaBase {
|
||||||
core.info(
|
core.info(
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
);
|
);
|
||||||
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
const extension = getDownloadArchiveExtension();
|
const extension = getDownloadArchiveExtension();
|
||||||
if (
|
|
||||||
process.platform === 'win32' &&
|
|
||||||
(this.architecture === 'arm64' || this.architecture === 'aarch64')
|
|
||||||
) {
|
|
||||||
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
|
|
||||||
await fs.renameSync(javaArchivePath, javaArchivePathRenamed);
|
|
||||||
javaArchivePath = javaArchivePathRenamed;
|
|
||||||
}
|
|
||||||
|
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue