mirror of
https://github.com/actions/setup-java.git
synced 2026-07-08 16:20:44 +03:00
dist: Support Tencent Kona JDK (#672)
* Support Tencent Kona JDK (#672) Signed-off-by: John Jiang <johnsjiang@tencent.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Address Copilot review feedback for Kona distribution - Sort matching releases by semver descending so range versions (e.g. >=17) resolve to the newest matching Kona JDK instead of the lowest - Rename downloaded archive on Windows before extraction (renameWinArchive) to avoid extraction failures - Import semver for version sorting Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Signed-off-by: John Jiang <johnsjiang@tencent.com> Co-authored-by: Bruno Borges <brborges@microsoft.com> Co-authored-by: Bruno Borges <bruno.borges@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,223 @@
|
||||
import {KonaDistribution} from '../../src/distributions/kona/installer';
|
||||
|
||||
import manifestData from '../data/kona.json';
|
||||
|
||||
function mockDistr(
|
||||
version: string,
|
||||
os: string,
|
||||
arch: string,
|
||||
packageType: string
|
||||
): KonaDistribution {
|
||||
const distribution = new KonaDistribution({
|
||||
version: version,
|
||||
architecture: arch,
|
||||
packageType: packageType,
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
distribution['getOs'] = () => os;
|
||||
distribution['fetchReleaseInfo'] = async () => manifestData;
|
||||
|
||||
return distribution;
|
||||
}
|
||||
|
||||
describe('Check getAvailableReleases', () => {
|
||||
it.each([
|
||||
['8', 'linux', 'aarch64', 'linux-aarch64'],
|
||||
['8.0.20', 'macos', 'x86_64', 'macosx-x86_64'],
|
||||
['11', 'linux', 'x86_64', 'linux-x86_64'],
|
||||
['11.0.25', 'macos', 'aarch64', 'macosx-aarch64'],
|
||||
['17.0.13', 'windows', 'x86_64', 'windows-x86_64'],
|
||||
['21.0.5', 'linux', 'x86_64', 'linux-x86_64']
|
||||
])(
|
||||
'should get releases with the specified version "%s", OS "%s" and arch "%s"',
|
||||
async (
|
||||
version: string,
|
||||
os: string,
|
||||
arch: string,
|
||||
expectedPattern: string
|
||||
) => {
|
||||
const distribution = mockDistr(version, os, arch, 'jdk');
|
||||
|
||||
const releases = await distribution['getAvailableReleases']();
|
||||
expect(releases).not.toBeNull();
|
||||
expect(releases.length).toBe(4);
|
||||
releases.forEach(release =>
|
||||
expect(release.downloadUrl).toContain(expectedPattern)
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('Check findPackageForDownload', () => {
|
||||
it.each([
|
||||
[
|
||||
'8',
|
||||
'linux',
|
||||
'aarch64',
|
||||
'https://github.com/Tencent/TencentKona-8/releases/download/8.0.20-GA/TencentKona8.0.20.b1_jdk_linux-aarch64_8u432.tar.gz'
|
||||
],
|
||||
[
|
||||
'8.0.20',
|
||||
'linux',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-8/releases/download/8.0.20-GA/TencentKona8.0.20.b1_jdk_linux-x86_64_8u432.tar.gz'
|
||||
],
|
||||
[
|
||||
'8.0.20',
|
||||
'macos',
|
||||
'aarch64',
|
||||
'https://github.com/Tencent/TencentKona-8/releases/download/8.0.20-GA/TencentKona8.0.20.b1_jdk_macosx-aarch64_8u432_notarized.tar.gz'
|
||||
],
|
||||
[
|
||||
'8.0.20',
|
||||
'macos',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-8/releases/download/8.0.20-GA/TencentKona8.0.20.b1_jdk_macosx-x86_64_8u432_notarized.tar.gz'
|
||||
],
|
||||
[
|
||||
'8.0.20',
|
||||
'windows',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-8/releases/download/8.0.20-GA/TencentKona8.0.20.b1_jdk_windows-x86_64_8u432_signed.zip'
|
||||
],
|
||||
|
||||
[
|
||||
'11',
|
||||
'linux',
|
||||
'aarch64',
|
||||
'https://github.com/Tencent/TencentKona-11/releases/download/kona11.0.25/TencentKona-11.0.25.b1-jdk_linux-aarch64.tar.gz'
|
||||
],
|
||||
[
|
||||
'11.0.25',
|
||||
'linux',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-11/releases/download/kona11.0.25/TencentKona-11.0.25.b1-jdk_linux-x86_64.tar.gz'
|
||||
],
|
||||
[
|
||||
'11.0.25',
|
||||
'macos',
|
||||
'aarch64',
|
||||
'https://github.com/Tencent/TencentKona-11/releases/download/kona11.0.25/TencentKona-11.0.25.b1_jdk_macosx-aarch64_notarized.tar.gz'
|
||||
],
|
||||
[
|
||||
'11.0.25',
|
||||
'macos',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-11/releases/download/kona11.0.25/TencentKona-11.0.25.b1_jdk_macosx-x86_64_notarized.tar.gz'
|
||||
],
|
||||
[
|
||||
'11.0.25',
|
||||
'windows',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-11/releases/download/kona11.0.25/TencentKona-11.0.25.b1_jdk_windows-x86_64_signed.zip'
|
||||
],
|
||||
|
||||
[
|
||||
'17',
|
||||
'linux',
|
||||
'aarch64',
|
||||
'https://github.com/Tencent/TencentKona-17/releases/download/TencentKona-17.0.13/TencentKona-17.0.13.b1-jdk_linux-aarch64.tar.gz'
|
||||
],
|
||||
[
|
||||
'17.0.13',
|
||||
'linux',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-17/releases/download/TencentKona-17.0.13/TencentKona-17.0.13.b1-jdk_linux-x86_64.tar.gz'
|
||||
],
|
||||
[
|
||||
'17.0.13',
|
||||
'macos',
|
||||
'aarch64',
|
||||
'https://github.com/Tencent/TencentKona-17/releases/download/TencentKona-17.0.13/TencentKona-17.0.13.b1_jdk_macosx-aarch64_notarized.tar.gz'
|
||||
],
|
||||
[
|
||||
'17.0.13',
|
||||
'macos',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-17/releases/download/TencentKona-17.0.13/TencentKona-17.0.13.b1_jdk_macosx-x86_64_notarized.tar.gz'
|
||||
],
|
||||
[
|
||||
'17.0.13',
|
||||
'windows',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-17/releases/download/TencentKona-17.0.13/TencentKona-17.0.13.b1_jdk_windows-x86_64_signed.zip'
|
||||
],
|
||||
|
||||
[
|
||||
'21',
|
||||
'linux',
|
||||
'aarch64',
|
||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.5/TencentKona-21.0.5.b1-jdk_linux-aarch64.tar.gz'
|
||||
],
|
||||
[
|
||||
'21.0.5',
|
||||
'linux',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.5/TencentKona-21.0.5.b1-jdk_linux-x86_64.tar.gz'
|
||||
],
|
||||
[
|
||||
'21.0.5',
|
||||
'macos',
|
||||
'aarch64',
|
||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.5/TencentKona-21.0.5.b1_jdk_macosx-aarch64_notarized.tar.gz'
|
||||
],
|
||||
[
|
||||
'21.0.5',
|
||||
'macos',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.5/TencentKona-21.0.5.b1_jdk_macosx-x86_64_notarized.tar.gz'
|
||||
],
|
||||
[
|
||||
'21.0.5',
|
||||
'windows',
|
||||
'x86_64',
|
||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.5/TencentKona-21.0.5.b1_jdk_windows-x86_64_signed.zip'
|
||||
]
|
||||
])(
|
||||
'should return the download URL with the specified version "%s", OS "%s" and arch "%s"',
|
||||
async (version: string, os: string, arch: string, expectedUrl: string) => {
|
||||
const distribution = mockDistr(version, os, arch, 'jdk');
|
||||
|
||||
const availableRelease =
|
||||
await distribution['findPackageForDownload'](version);
|
||||
expect(availableRelease).not.toBeNull();
|
||||
expect(availableRelease.url).toBe(expectedUrl);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('No release is found', () => {
|
||||
it.each([
|
||||
['8', 'linux', 'x86'],
|
||||
['8.0.0', 'linux', 'x86_64'],
|
||||
['11', 'linux', 'ppc64'],
|
||||
['17', 'solaris', 'x86_64'],
|
||||
['17', 'windows', 'aarch64'],
|
||||
['22', 'macos', 'x86_64']
|
||||
])(
|
||||
`should throw an error due to no release with the specified version "%s", os "%s" and arch "%s"`,
|
||||
async (version: string, os: string, arch: string) => {
|
||||
const distribution = mockDistr(version, os, arch, 'jdk');
|
||||
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](version)
|
||||
).rejects.toThrow(
|
||||
`No Kona release for the specified version "${version}" on OS "${os}" and arch "${arch}".`
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('The package type must be jdk', () => {
|
||||
it('should throw an error due to the specified package type is not jdk', async () => {
|
||||
const version = '8.0.20';
|
||||
const os = 'linux';
|
||||
const arch = 'x86_64';
|
||||
const distribution = mockDistr(version, os, arch, 'jre');
|
||||
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](version)
|
||||
).rejects.toThrow('Kona provides jdk only');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user