Skip to content

Commit 0ab4596

Browse files
Accelerator1996Ivan ZosimovIvanZosimov
authored
add support for dragonwell (actions#532)
* add support for dragonwell * fix: update logic of parsing json file, refactor code * build: rebuild action * chore: update error message * build: rebuild action * tests: fix unit tests, add e2e tests * chore: prettier, lint and rebuild solution * feat: add check for the package type, update unit tests * tests: update e2e tests * tests: remove excess entries from e2e tests * feat: update logic of getting json file * feat: add logic for backuping getting json * chore: update wordings * chore: fix typos, add additional logs * fix: fix review points * chore: rebuild solution * chore: update wordings * chore: refactor code --------- Co-authored-by: Ivan Zosimov <ivanzosimov@github.com> Co-authored-by: Ivan <98037481+IvanZosimov@users.noreply.github.com>
1 parent 4075bfc commit 0ab4596

File tree

12 files changed

+1918
-20
lines changed

12 files changed

+1918
-20
lines changed

.github/workflows/e2e-versions.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ jobs:
2929
'liberica',
3030
'microsoft',
3131
'semeru',
32-
'corretto'
32+
'corretto',
33+
'dragonwell'
3334
] # internally 'adopt-hotspot' is the same as 'adopt'
3435
version: ['8', '11', '17']
3536
exclude:
3637
- distribution: microsoft
3738
version: 8
39+
- distribution: dragonwell
40+
os: macos-latest
3841
include:
3942
- distribution: oracle
4043
os: macos-latest
@@ -45,6 +48,7 @@ jobs:
4548
- distribution: oracle
4649
os: ubuntu-latest
4750
version: 20
51+
4852
steps:
4953
- name: Checkout
5054
uses: actions/checkout@v3
@@ -75,6 +79,12 @@ jobs:
7579
- distribution: oracle
7680
os: ubuntu-latest
7781
version: '20.0.1'
82+
- distribution: dragonwell
83+
os: ubuntu-latest
84+
version: '11.0'
85+
- distribution: dragonwell
86+
os: ubuntu-latest
87+
version: '11.0.13+9'
7888
steps:
7989
- name: Checkout
8090
uses: actions/checkout@v3
@@ -96,7 +106,10 @@ jobs:
96106
fail-fast: false
97107
matrix:
98108
os: [macos-latest, windows-latest, ubuntu-latest]
99-
distribution: ['temurin', 'zulu', 'liberica']
109+
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
110+
exclude:
111+
- distribution: dragonwell
112+
os: macos-latest
100113
steps:
101114
- name: Checkout
102115
uses: actions/checkout@v3
@@ -119,7 +132,10 @@ jobs:
119132
fail-fast: false
120133
matrix:
121134
os: [macos-latest, windows-latest, ubuntu-latest]
122-
distribution: ['temurin', 'zulu', 'liberica']
135+
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
136+
exclude:
137+
- distribution: dragonwell
138+
os: macos-latest
123139
steps:
124140
- name: Checkout
125141
uses: actions/checkout@v3

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: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
import {HttpClient} from '@actions/http-client';
2+
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
3+
import * as utils from '../../src/util';
4+
5+
import manifestData from '../data/dragonwell.json';
6+
7+
describe('getAvailableVersions', () => {
8+
let spyHttpClient: jest.SpyInstance;
9+
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
10+
11+
beforeEach(() => {
12+
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
13+
spyHttpClient.mockReturnValue({
14+
statusCode: 200,
15+
headers: {},
16+
result: manifestData
17+
});
18+
19+
spyUtilGetDownloadArchiveExtension = jest.spyOn(
20+
utils,
21+
'getDownloadArchiveExtension'
22+
);
23+
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
24+
});
25+
26+
afterEach(() => {
27+
jest.resetAllMocks();
28+
jest.clearAllMocks();
29+
jest.restoreAllMocks();
30+
});
31+
32+
const mockPlatform = (
33+
distribution: DragonwellDistribution,
34+
platform: string
35+
) => {
36+
distribution['getPlatformOption'] = () => platform;
37+
const mockedExtension = platform == 'windows' ? 'zip' : 'tar.gz';
38+
spyUtilGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
39+
};
40+
41+
describe('getAvailableVersions', () => {
42+
it.each([
43+
['8', 'x86', 'linux', 0],
44+
['8', 'aarch64', 'linux', 24],
45+
['8.6.6', 'x64', 'linux', 27],
46+
['8', 'x86', 'anolis', 0],
47+
['8', 'x86', 'windows', 0],
48+
['8', 'x86', 'mac', 0],
49+
['11', 'x64', 'linux', 27],
50+
['11', 'aarch64', 'linux', 24],
51+
['17', 'riscv', 'linux', 0],
52+
['16.0.1', 'x64', 'linux', 27]
53+
])(
54+
'should get right number of available versions from JSON',
55+
async (
56+
jdkVersion: string,
57+
arch: string,
58+
platform: string,
59+
len: number
60+
) => {
61+
const distribution = new DragonwellDistribution({
62+
version: jdkVersion,
63+
architecture: arch,
64+
packageType: 'jdk',
65+
checkLatest: false
66+
});
67+
mockPlatform(distribution, platform);
68+
69+
const availableVersions = await distribution['getAvailableVersions']();
70+
expect(availableVersions).not.toBeNull();
71+
expect(availableVersions.length).toBe(len);
72+
}
73+
);
74+
});
75+
76+
describe('findPackageForDownload', () => {
77+
it.each([
78+
[
79+
'8',
80+
'linux',
81+
'x64',
82+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
83+
],
84+
[
85+
'8',
86+
'linux',
87+
'aarch64',
88+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_aarch64_linux.tar.gz'
89+
],
90+
[
91+
'8',
92+
'windows',
93+
'x64',
94+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_windows.zip'
95+
],
96+
[
97+
'8.13.14',
98+
'linux',
99+
'x64',
100+
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
101+
],
102+
[
103+
'11',
104+
'linux',
105+
'x64',
106+
'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'
107+
],
108+
[
109+
'11',
110+
'linux',
111+
'aarch64',
112+
'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'
113+
],
114+
[
115+
'11',
116+
'windows',
117+
'x64',
118+
'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'
119+
],
120+
[
121+
'11',
122+
'alpine-linux',
123+
'x64',
124+
'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'
125+
],
126+
[
127+
'11.0.17',
128+
'linux',
129+
'x64',
130+
'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'
131+
],
132+
[
133+
'17',
134+
'linux',
135+
'x64',
136+
'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'
137+
],
138+
[
139+
'17',
140+
'linux',
141+
'aarch64',
142+
'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'
143+
],
144+
[
145+
'17',
146+
'windows',
147+
'x64',
148+
'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'
149+
],
150+
[
151+
'17',
152+
'alpine-linux',
153+
'x64',
154+
'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'
155+
],
156+
[
157+
'17.0.4',
158+
'linux',
159+
'x64',
160+
'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'
161+
]
162+
])(
163+
'should return proper link according to the specified java-version, platform and arch',
164+
async (
165+
jdkVersion: string,
166+
platform: string,
167+
arch: string,
168+
expectedLink: string
169+
) => {
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'](
179+
jdkVersion
180+
);
181+
expect(availableVersion).not.toBeNull();
182+
expect(availableVersion.url).toBe(expectedLink);
183+
}
184+
);
185+
186+
it.each([
187+
['8', 'alpine-linux', 'x64'],
188+
['8', 'macos', 'aarch64'],
189+
['11', 'macos', 'aarch64'],
190+
['17', 'linux', 'riscv']
191+
])(
192+
'should throw when required version of JDK can not be found in the JSON',
193+
async (jdkVersion: string, platform: string, arch: string) => {
194+
const distribution = new DragonwellDistribution({
195+
version: jdkVersion,
196+
architecture: arch,
197+
packageType: 'jdk',
198+
checkLatest: false
199+
});
200+
mockPlatform(distribution, platform);
201+
202+
await expect(
203+
distribution['findPackageForDownload'](jdkVersion)
204+
).rejects.toThrow(
205+
`Couldn't find any satisfied version for the specified java-version: "${jdkVersion}" and architecture: "${arch}".`
206+
);
207+
}
208+
);
209+
210+
it('should throw when required package type is not jdk', async () => {
211+
const jdkVersion = '17';
212+
const arch = 'x64';
213+
const platform = 'linux';
214+
const distribution = new DragonwellDistribution({
215+
version: jdkVersion,
216+
architecture: arch,
217+
packageType: 'jre',
218+
checkLatest: false
219+
});
220+
mockPlatform(distribution, platform);
221+
await expect(
222+
distribution['findPackageForDownload'](jdkVersion)
223+
).rejects.toThrow('Dragonwell provides only the `jdk` package type');
224+
});
225+
});
226+
});

dist/cleanup/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67020,7 +67020,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6702067020
return (mod && mod.__esModule) ? mod : { "default": mod };
6702167021
};
6702267022
Object.defineProperty(exports, "__esModule", ({ value: true }));
67023-
exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
67023+
exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
6702467024
const os_1 = __importDefault(__nccwpck_require__(2037));
6702567025
const path_1 = __importDefault(__nccwpck_require__(1017));
6702667026
const fs = __importStar(__nccwpck_require__(7147));
@@ -67157,6 +67157,16 @@ function convertVersionToSemver(version) {
6715767157
return mainVersion;
6715867158
}
6715967159
exports.convertVersionToSemver = convertVersionToSemver;
67160+
function getGitHubHttpHeaders() {
67161+
const token = core.getInput('token');
67162+
const auth = !token ? undefined : `token ${token}`;
67163+
const headers = {
67164+
authorization: auth,
67165+
accept: 'application/vnd.github.VERSION.raw'
67166+
};
67167+
return headers;
67168+
}
67169+
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
6716067170

6716167171

6716267172
/***/ }),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy