Skip to content

Commit 5431304

Browse files
add support for dragonwell
1 parent ea15b3b commit 5431304

File tree

8 files changed

+1729
-2
lines changed

8 files changed

+1729
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Currently, the following distributions are supported:
104104
| `microsoft` | Microsoft Build of OpenJDK | [Link](https://www.microsoft.com/openjdk) | [Link](https://docs.microsoft.com/java/openjdk/faq)
105105
| `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/)
106106
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
107+
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
107108

108109
**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
109110

@@ -226,6 +227,7 @@ In the example above multiple JDKs are installed for the same job. The result af
226227
- [Microsoft](docs/advanced-usage.md#Microsoft)
227228
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
228229
- [Oracle](docs/advanced-usage.md#Oracle)
230+
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
229231
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
230232
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
231233
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)

__tests__/data/dragonwell.json

Lines changed: 1138 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
import { HttpClient } from '@actions/http-client';
2+
import * as semver from 'semver';
3+
import { DragonwellDistribution } from '../../src/distributions/dragonwell/installer';
4+
import { IDragonwellVersions } from '../../src/distributions/dragonwell/models';
5+
import * as utils from '../../src/util';
6+
import os from 'os';
7+
8+
const manifestData = require('../data/dragonwell.json') as [];
9+
10+
describe('getAvailableVersions', () => {
11+
let spyHttpClient: jest.SpyInstance;
12+
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
13+
14+
beforeEach(() => {
15+
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
16+
spyHttpClient.mockReturnValue({
17+
statusCode: 200,
18+
headers: {},
19+
result: manifestData as IDragonwellVersions[]
20+
});
21+
22+
spyUtilGetDownloadArchiveExtension = jest.spyOn(utils, 'getDownloadArchiveExtension');
23+
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
24+
});
25+
26+
afterEach(() => {
27+
jest.resetAllMocks();
28+
jest.clearAllMocks();
29+
jest.restoreAllMocks();
30+
});
31+
32+
const mockPlatform = (distribution: DragonwellDistribution, platform: string) => {
33+
distribution['getPlatformOption'] = () => platform;
34+
const mockedExtension = platform == 'windows' ? 'zip' : 'tar.gz';
35+
spyUtilGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
36+
};
37+
38+
describe('getAvailableVersions', () => {
39+
it.each([
40+
['8', 'x86', 'linux', 36],
41+
['8', 'aarch64', 'linux', 33],
42+
['8.6.6', 'x64', 'linux', 36],
43+
['8', 'x86', 'anolis', 0],
44+
['8', 'x86', 'windows', 35],
45+
['8', 'x86', 'mac', 0],
46+
['11', 'x64', 'linux', 36],
47+
['11', 'aarch64', 'linux', 33],
48+
['17', 'riscv', 'linux', 0]
49+
])(
50+
'load available versions',
51+
async (jdkVersion: string, arch: string, platform: string, len: number) => {
52+
const distribution = new DragonwellDistribution({
53+
version: jdkVersion,
54+
architecture: arch,
55+
packageType: 'jdk',
56+
checkLatest: false
57+
});
58+
mockPlatform(distribution, platform);
59+
60+
const availableVersions = await distribution['getAvailableVersions']();
61+
expect(availableVersions).not.toBeNull();
62+
expect(availableVersions.length).toBe(len);
63+
}
64+
);
65+
66+
it.each(['16', '16.0.1', '19'])('load unsupported versions', async (jdkVersion: string) => {
67+
const distribution = new DragonwellDistribution({
68+
version: jdkVersion,
69+
architecture: 'x86',
70+
packageType: 'jdk',
71+
checkLatest: false
72+
});
73+
mockPlatform(distribution, 'linux');
74+
75+
await expect(distribution['getAvailableVersions']()).rejects.toThrowError(
76+
'Support dragonwell versions: 8, 11, 17'
77+
);
78+
});
79+
});
80+
81+
describe('findPackageForDownload', () => {
82+
it.each([
83+
[
84+
'8',
85+
'linux',
86+
'x64',
87+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
88+
],
89+
[
90+
'8',
91+
'linux',
92+
'aarch64',
93+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_aarch64_linux.tar.gz'
94+
],
95+
[
96+
'8',
97+
'windows',
98+
'x64',
99+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_windows.zip'
100+
],
101+
[
102+
'8.13.14',
103+
'linux',
104+
'x64',
105+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
106+
],
107+
[
108+
'11',
109+
'linux',
110+
'x64',
111+
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
112+
],
113+
[
114+
'11',
115+
'linux',
116+
'aarch64',
117+
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_aarch64_linux.tar.gz'
118+
],
119+
[
120+
'11',
121+
'windows',
122+
'x64',
123+
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_windows.zip'
124+
],
125+
[
126+
'11',
127+
'alpine-linux',
128+
'x64',
129+
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_alpine-linux.tar.gz'
130+
],
131+
[
132+
'11.0.17',
133+
'linux',
134+
'x64',
135+
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
136+
],
137+
[
138+
'17',
139+
'linux',
140+
'x64',
141+
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_linux.tar.gz'
142+
],
143+
[
144+
'17',
145+
'linux',
146+
'aarch64',
147+
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_aarch64_linux.tar.gz'
148+
],
149+
[
150+
'17',
151+
'windows',
152+
'x64',
153+
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_windows.zip'
154+
],
155+
[
156+
'17',
157+
'alpine-linux',
158+
'x64',
159+
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_alpine-linux.tar.gz'
160+
],
161+
[
162+
'17.0.4',
163+
'linux',
164+
'x64',
165+
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.4.0.4%2B8_jdk-17.0.4-ga/Alibaba_Dragonwell_Standard_17.0.4.0.4%2B8_x64_linux.tar.gz'
166+
]
167+
])(
168+
'test for download link',
169+
async (jdkVersion: string, platform: string, arch: string, expectedLink: string) => {
170+
const distribution = new DragonwellDistribution({
171+
version: jdkVersion,
172+
architecture: arch,
173+
packageType: 'jdk',
174+
checkLatest: false
175+
});
176+
mockPlatform(distribution, platform);
177+
178+
const availableVersion = await distribution['findPackageForDownload'](jdkVersion);
179+
expect(availableVersion).not.toBeNull();
180+
expect(availableVersion.url).toBe(expectedLink);
181+
}
182+
);
183+
184+
it.each([
185+
['8', 'alpine-linux', 'x64'],
186+
['8', 'macos', 'aarch64'],
187+
['11', 'macos', 'aarch64'],
188+
['17', 'linux', 'riscv']
189+
])(
190+
'test for unsupported version',
191+
async (jdkVersion: string, platform: string, arch: string) => {
192+
const distribution = new DragonwellDistribution({
193+
version: jdkVersion,
194+
architecture: arch,
195+
packageType: 'jdk',
196+
checkLatest: false
197+
});
198+
mockPlatform(distribution, platform);
199+
200+
await expect(distribution['findPackageForDownload'](jdkVersion)).rejects.toThrowError(
201+
`Cannot find satisfied version for ${jdkVersion}.`
202+
);
203+
}
204+
);
205+
});
206+
});

0 commit comments

Comments
 (0)