Skip to content

Commit 0a40ce6

Browse files
authored
Add support for Oracle GraalVM (actions#501)
* Add support for Oracle GraalVM * Add support for EA builds of Oracle GraalVM
1 parent bcfbca5 commit 0a40ce6

File tree

8 files changed

+550
-5
lines changed

8 files changed

+550
-5
lines changed

.github/workflows/e2e-versions.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,22 @@ jobs:
4545
version: 17
4646
- distribution: oracle
4747
os: windows-latest
48-
version: 20
48+
version: 21
4949
- distribution: oracle
5050
os: ubuntu-latest
51-
version: 20
52-
51+
version: 21
52+
- distribution: graalvm
53+
os: macos-latest
54+
version: 17
55+
- distribution: graalvm
56+
os: windows-latest
57+
version: 21
58+
- distribution: graalvm
59+
os: ubuntu-latest
60+
version: 21
61+
- distribution: graalvm
62+
os: ubuntu-latest
63+
version: '24-ea'
5364
steps:
5465
- name: Checkout
5566
uses: actions/checkout@v4
@@ -79,7 +90,10 @@ jobs:
7990
include:
8091
- distribution: oracle
8192
os: ubuntu-latest
82-
version: '20.0.1'
93+
version: '21.0.4'
94+
- distribution: graalvm
95+
os: ubuntu-latest
96+
version: '21.0.4'
8397
- distribution: dragonwell
8498
os: ubuntu-latest
8599
version: '11.0'

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Currently, the following distributions are supported:
109109
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
110110
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
111111
| `sapmachine` | SAP SapMachine JDK/JRE | [Link](https://sapmachine.io/) | [Link](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
112+
| `graalvm` | Oracle GraalVM | [Link](https://www.graalvm.org/) | [Link](https://www.oracle.com/downloads/licenses/graal-free-license.html)
112113

113114
**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.
114115

@@ -259,6 +260,7 @@ In the example above multiple JDKs are installed for the same job. The result af
259260
- [Oracle](docs/advanced-usage.md#Oracle)
260261
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
261262
- [SapMachine](docs/advanced-usage.md#SapMachine)
263+
- [GraalVM](docs/advanced-usage.md#GraalVM)
262264
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
263265
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
264266
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
2+
import os from 'os';
3+
import * as core from '@actions/core';
4+
import {getDownloadArchiveExtension} from '../../src/util';
5+
import {HttpClient} from '@actions/http-client';
6+
7+
describe('findPackageForDownload', () => {
8+
let distribution: GraalVMDistribution;
9+
let spyDebug: jest.SpyInstance;
10+
let spyHttpClient: jest.SpyInstance;
11+
12+
beforeEach(() => {
13+
distribution = new GraalVMDistribution({
14+
version: '',
15+
architecture: 'x64',
16+
packageType: 'jdk',
17+
checkLatest: false
18+
});
19+
20+
spyDebug = jest.spyOn(core, 'debug');
21+
spyDebug.mockImplementation(() => {});
22+
});
23+
24+
it.each([
25+
[
26+
'21',
27+
'21',
28+
'https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
29+
],
30+
[
31+
'21.0.4',
32+
'21.0.4',
33+
'https://download.oracle.com/graalvm/21/archive/graalvm-jdk-21.0.4_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
34+
],
35+
[
36+
'17',
37+
'17',
38+
'https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
39+
],
40+
[
41+
'17.0.12',
42+
'17.0.12',
43+
'https://download.oracle.com/graalvm/17/archive/graalvm-jdk-17.0.12_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
44+
]
45+
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
46+
/* Needed only for this particular test because /latest/ urls tend to change */
47+
spyHttpClient = jest.spyOn(HttpClient.prototype, 'head');
48+
spyHttpClient.mockReturnValue(
49+
Promise.resolve({
50+
message: {
51+
statusCode: 200
52+
}
53+
})
54+
);
55+
56+
const result = await distribution['findPackageForDownload'](input);
57+
58+
jest.restoreAllMocks();
59+
60+
expect(result.version).toBe(expectedVersion);
61+
const osType = distribution.getPlatform();
62+
const archiveType = getDownloadArchiveExtension();
63+
const url = expectedUrl
64+
.replace('{{OS_TYPE}}', osType)
65+
.replace('{{ARCHIVE_TYPE}}', archiveType);
66+
expect(result.url).toBe(url);
67+
});
68+
69+
it.each([
70+
[
71+
'24-ea',
72+
/^https:\/\/github\.com\/graalvm\/oracle-graalvm-ea-builds\/releases\/download\/jdk-24\.0\.0-ea\./
73+
]
74+
])('version is %s -> %s', async (version, expectedUrlPrefix) => {
75+
/* Needed only for this particular test because /latest/ urls tend to change */
76+
spyHttpClient = jest.spyOn(HttpClient.prototype, 'head');
77+
spyHttpClient.mockReturnValue(
78+
Promise.resolve({
79+
message: {
80+
statusCode: 200
81+
}
82+
})
83+
);
84+
85+
const eaDistro = new GraalVMDistribution({
86+
version,
87+
architecture: '', // to get default value
88+
packageType: 'jdk',
89+
checkLatest: false
90+
});
91+
92+
const versionWithoutEA = version.split('-')[0];
93+
const result = await eaDistro['findPackageForDownload'](versionWithoutEA);
94+
95+
jest.restoreAllMocks();
96+
97+
expect(result.url).toEqual(expect.stringMatching(expectedUrlPrefix));
98+
});
99+
100+
it.each([
101+
['amd64', 'x64'],
102+
['arm64', 'aarch64']
103+
])(
104+
'defaults to os.arch(): %s mapped to distro arch: %s',
105+
async (osArch: string, distroArch: string) => {
106+
jest.spyOn(os, 'arch').mockReturnValue(osArch);
107+
jest.spyOn(os, 'platform').mockReturnValue('linux');
108+
109+
const version = '21';
110+
const distro = new GraalVMDistribution({
111+
version,
112+
architecture: '', // to get default value
113+
packageType: 'jdk',
114+
checkLatest: false
115+
});
116+
117+
const osType = distribution.getPlatform();
118+
if (osType === 'windows' && distroArch == 'aarch64') {
119+
return; // skip, aarch64 is not available for Windows
120+
}
121+
const archiveType = getDownloadArchiveExtension();
122+
const result = await distro['findPackageForDownload'](version);
123+
const expectedUrl = `https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_${osType}-${distroArch}_bin.${archiveType}`;
124+
125+
expect(result.url).toBe(expectedUrl);
126+
}
127+
);
128+
129+
it('should throw an error', async () => {
130+
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
131+
/GraalVM is only supported for JDK 17 and later/
132+
);
133+
await expect(distribution['findPackageForDownload']('11')).rejects.toThrow(
134+
/GraalVM is only supported for JDK 17 and later/
135+
);
136+
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
137+
/Could not find GraalVM for SemVer */
138+
);
139+
140+
const unavailableEADistro = new GraalVMDistribution({
141+
version: '17-ea',
142+
architecture: '', // to get default value
143+
packageType: 'jdk',
144+
checkLatest: false
145+
});
146+
await expect(
147+
unavailableEADistro['findPackageForDownload']('17')
148+
).rejects.toThrow(
149+
/No GraalVM EA build found\. Are you sure java-version: '17-ea' is correct\?/
150+
);
151+
});
152+
});

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