Skip to content

Commit 318a89e

Browse files
add support for dragonwell
1 parent 5ffc13f commit 318a89e

File tree

8 files changed

+1758
-1
lines changed

8 files changed

+1758
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Currently, the following distributions are supported:
105105
| `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/)
106106
| `semeru` | IBM Semeru Runtime Open Edition | [Link](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [Link](https://openjdk.java.net/legal/gplv2+ce.html) |
107107
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
108+
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
108109

109110
**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.
110111

@@ -227,6 +228,7 @@ In the example above multiple JDKs are installed for the same job. The result af
227228
- [Microsoft](docs/advanced-usage.md#Microsoft)
228229
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
229230
- [Oracle](docs/advanced-usage.md#Oracle)
231+
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
230232
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
231233
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
232234
- [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: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
import {HttpClient} from '@actions/http-client';
2+
import * as semver from 'semver';
3+
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
4+
import {IDragonwellAllVersions} from '../../src/distributions/dragonwell/models';
5+
import * as utils from '../../src/util';
6+
import os from 'os';
7+
8+
import manifestData from '../data/dragonwell.json';
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
20+
});
21+
22+
spyUtilGetDownloadArchiveExtension = jest.spyOn(
23+
utils,
24+
'getDownloadArchiveExtension'
25+
);
26+
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
27+
});
28+
29+
afterEach(() => {
30+
jest.resetAllMocks();
31+
jest.clearAllMocks();
32+
jest.restoreAllMocks();
33+
});
34+
35+
const mockPlatform = (
36+
distribution: DragonwellDistribution,
37+
platform: string
38+
) => {
39+
distribution['getPlatformOption'] = () => platform;
40+
const mockedExtension = platform == 'windows' ? 'zip' : 'tar.gz';
41+
spyUtilGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
42+
};
43+
44+
describe('getAvailableVersions', () => {
45+
it.each([
46+
['8', 'x86', 'linux', 0],
47+
['8', 'aarch64', 'linux', 33],
48+
['8.6.6', 'x64', 'linux', 36],
49+
['8', 'x86', 'anolis', 0],
50+
['8', 'x86', 'windows', 0],
51+
['8', 'x86', 'mac', 0],
52+
['11', 'x64', 'linux', 36],
53+
['11', 'aarch64', 'linux', 33],
54+
['17', 'riscv', 'linux', 0]
55+
])(
56+
'load available versions',
57+
async (
58+
jdkVersion: string,
59+
arch: string,
60+
platform: string,
61+
len: number
62+
) => {
63+
const distribution = new DragonwellDistribution({
64+
version: jdkVersion,
65+
architecture: arch,
66+
packageType: 'jdk',
67+
checkLatest: false
68+
});
69+
mockPlatform(distribution, platform);
70+
71+
const availableVersions = await distribution['getAvailableVersions']();
72+
expect(availableVersions).not.toBeNull();
73+
expect(availableVersions.length).toBe(len);
74+
}
75+
);
76+
77+
it.each(['16', '16.0.1', '19'])(
78+
'load unsupported versions',
79+
async (jdkVersion: string) => {
80+
const distribution = new DragonwellDistribution({
81+
version: jdkVersion,
82+
architecture: 'x86',
83+
packageType: 'jdk',
84+
checkLatest: false
85+
});
86+
mockPlatform(distribution, 'linux');
87+
88+
await expect(distribution['getAvailableVersions']()).rejects.toThrow(
89+
'Support dragonwell versions: 8, 11, 17'
90+
);
91+
}
92+
);
93+
});
94+
95+
describe('findPackageForDownload', () => {
96+
it.each([
97+
[
98+
'8',
99+
'linux',
100+
'x64',
101+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
102+
],
103+
[
104+
'8',
105+
'linux',
106+
'aarch64',
107+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_aarch64_linux.tar.gz'
108+
],
109+
[
110+
'8',
111+
'windows',
112+
'x64',
113+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_windows.zip'
114+
],
115+
[
116+
'8.13.14',
117+
'linux',
118+
'x64',
119+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
120+
],
121+
[
122+
'11',
123+
'linux',
124+
'x64',
125+
'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'
126+
],
127+
[
128+
'11',
129+
'linux',
130+
'aarch64',
131+
'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'
132+
],
133+
[
134+
'11',
135+
'windows',
136+
'x64',
137+
'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'
138+
],
139+
[
140+
'11',
141+
'alpine-linux',
142+
'x64',
143+
'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'
144+
],
145+
[
146+
'11.0.17',
147+
'linux',
148+
'x64',
149+
'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'
150+
],
151+
[
152+
'17',
153+
'linux',
154+
'x64',
155+
'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'
156+
],
157+
[
158+
'17',
159+
'linux',
160+
'aarch64',
161+
'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'
162+
],
163+
[
164+
'17',
165+
'windows',
166+
'x64',
167+
'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'
168+
],
169+
[
170+
'17',
171+
'alpine-linux',
172+
'x64',
173+
'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'
174+
],
175+
[
176+
'17.0.4',
177+
'linux',
178+
'x64',
179+
'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'
180+
]
181+
])(
182+
'test for download link',
183+
async (
184+
jdkVersion: string,
185+
platform: string,
186+
arch: string,
187+
expectedLink: string
188+
) => {
189+
const distribution = new DragonwellDistribution({
190+
version: jdkVersion,
191+
architecture: arch,
192+
packageType: 'jdk',
193+
checkLatest: false
194+
});
195+
mockPlatform(distribution, platform);
196+
197+
const availableVersion = await distribution['findPackageForDownload'](
198+
jdkVersion
199+
);
200+
expect(availableVersion).not.toBeNull();
201+
expect(availableVersion.url).toBe(expectedLink);
202+
}
203+
);
204+
205+
it.each([
206+
['8', 'alpine-linux', 'x64'],
207+
['8', 'macos', 'aarch64'],
208+
['11', 'macos', 'aarch64'],
209+
['17', 'linux', 'riscv']
210+
])(
211+
'test for unsupported version',
212+
async (jdkVersion: string, platform: string, arch: string) => {
213+
const distribution = new DragonwellDistribution({
214+
version: jdkVersion,
215+
architecture: arch,
216+
packageType: 'jdk',
217+
checkLatest: false
218+
});
219+
mockPlatform(distribution, platform);
220+
221+
await expect(
222+
distribution['findPackageForDownload'](jdkVersion)
223+
).rejects.toThrow(`Cannot find satisfied version for ${jdkVersion}.`);
224+
}
225+
);
226+
});
227+
});

0 commit comments

Comments
 (0)