Skip to content

Commit ec1af22

Browse files
add support for dragonwell
1 parent 5ffc13f commit ec1af22

File tree

8 files changed

+1724
-1
lines changed

8 files changed

+1724
-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: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
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+
['16.0.1', 'x64', 'linux', 36]
56+
])(
57+
'load available versions',
58+
async (
59+
jdkVersion: string,
60+
arch: string,
61+
platform: string,
62+
len: number
63+
) => {
64+
const distribution = new DragonwellDistribution({
65+
version: jdkVersion,
66+
architecture: arch,
67+
packageType: 'jdk',
68+
checkLatest: false
69+
});
70+
mockPlatform(distribution, platform);
71+
72+
const availableVersions = await distribution['getAvailableVersions']();
73+
expect(availableVersions).not.toBeNull();
74+
expect(availableVersions.length).toBe(len);
75+
}
76+
);
77+
});
78+
79+
describe('findPackageForDownload', () => {
80+
it.each([
81+
[
82+
'8',
83+
'linux',
84+
'x64',
85+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
86+
],
87+
[
88+
'8',
89+
'linux',
90+
'aarch64',
91+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_aarch64_linux.tar.gz'
92+
],
93+
[
94+
'8',
95+
'windows',
96+
'x64',
97+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_windows.zip'
98+
],
99+
[
100+
'8.13.14',
101+
'linux',
102+
'x64',
103+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
104+
],
105+
[
106+
'11',
107+
'linux',
108+
'x64',
109+
'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'
110+
],
111+
[
112+
'11',
113+
'linux',
114+
'aarch64',
115+
'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'
116+
],
117+
[
118+
'11',
119+
'windows',
120+
'x64',
121+
'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'
122+
],
123+
[
124+
'11',
125+
'alpine-linux',
126+
'x64',
127+
'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'
128+
],
129+
[
130+
'11.0.17',
131+
'linux',
132+
'x64',
133+
'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'
134+
],
135+
[
136+
'17',
137+
'linux',
138+
'x64',
139+
'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'
140+
],
141+
[
142+
'17',
143+
'linux',
144+
'aarch64',
145+
'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'
146+
],
147+
[
148+
'17',
149+
'windows',
150+
'x64',
151+
'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'
152+
],
153+
[
154+
'17',
155+
'alpine-linux',
156+
'x64',
157+
'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'
158+
],
159+
[
160+
'17.0.4',
161+
'linux',
162+
'x64',
163+
'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'
164+
]
165+
])(
166+
'test for download link',
167+
async (
168+
jdkVersion: string,
169+
platform: string,
170+
arch: string,
171+
expectedLink: string
172+
) => {
173+
const distribution = new DragonwellDistribution({
174+
version: jdkVersion,
175+
architecture: arch,
176+
packageType: 'jdk',
177+
checkLatest: false
178+
});
179+
mockPlatform(distribution, platform);
180+
181+
const availableVersion = await distribution['findPackageForDownload'](
182+
jdkVersion
183+
);
184+
expect(availableVersion).not.toBeNull();
185+
expect(availableVersion.url).toBe(expectedLink);
186+
}
187+
);
188+
189+
it.each([
190+
['8', 'alpine-linux', 'x64'],
191+
['8', 'macos', 'aarch64'],
192+
['11', 'macos', 'aarch64'],
193+
['17', 'linux', 'riscv']
194+
])(
195+
'test for unsupported version',
196+
async (jdkVersion: string, platform: string, arch: string) => {
197+
const distribution = new DragonwellDistribution({
198+
version: jdkVersion,
199+
architecture: arch,
200+
packageType: 'jdk',
201+
checkLatest: false
202+
});
203+
mockPlatform(distribution, platform);
204+
205+
await expect(
206+
distribution['findPackageForDownload'](jdkVersion)
207+
).rejects.toThrow(
208+
`Couldn't find any satisfied version for the specified: "${jdkVersion}".`
209+
);
210+
}
211+
);
212+
});
213+
});

0 commit comments

Comments
 (0)