Support new GraalVM for JDK17/JDK20 release

This commit adds support for the new GraalVM for JDK17/JDK20 release, including the new Oracle GraalVM distribution.
For this, users only need to specify the 'java-version' option and the new 'distribution' option.
The 'version' option is now marked as optional and kept for compatibility with older GraalVM releases and Mandrel.
This commit is contained in:
Fabio Niephaus
2023-06-16 09:19:49 +02:00
committed by Fabio Niephaus
parent 2f50b91043
commit c871f91ee0
14 changed files with 756 additions and 216 deletions

View File

@@ -1,5 +1,5 @@
import * as path from 'path'
import {downloadGraalVMEE, fetchArtifact} from '../src/gds'
import {downloadGraalVMEELegacy, fetchArtifact} from '../src/gds'
import {expect, test} from '@jest/globals'
const TEST_USER_AGENT = 'GraalVMGitHubActionTest/1.0.4'
@@ -32,13 +32,15 @@ test('fetch artifacts', async () => {
})
test('errors when downloading artifacts', async () => {
await expect(downloadGraalVMEE('invalid', '22.1.0', '11')).rejects.toThrow(
await expect(
downloadGraalVMEELegacy('invalid', '22.1.0', '11')
).rejects.toThrow(
'The provided "gds-token" was rejected (reason: "Invalid download token", opc-request-id: /'
)
await expect(downloadGraalVMEE('invalid', '1.0.0', '11')).rejects.toThrow(
'Unable to find JDK11-based GraalVM EE 1.0.0'
)
await expect(downloadGraalVMEE('invalid', '22.1.0', '1')).rejects.toThrow(
'Unable to find JDK1-based GraalVM EE 22.1.0'
)
await expect(
downloadGraalVMEELegacy('invalid', '1.0.0', '11')
).rejects.toThrow('Unable to find JDK11-based GraalVM EE 1.0.0')
await expect(
downloadGraalVMEELegacy('invalid', '22.1.0', '1')
).rejects.toThrow('Unable to find JDK1-based GraalVM EE 22.1.0')
})

View File

@@ -19,7 +19,7 @@ test('request invalid version/javaVersion', async () => {
await graalvm.setUpGraalVMRelease('', combination[0], combination[1])
} catch (err) {
if (!(err instanceof Error)) {
fail(`Unexpected non-Erro: ${err}`)
fail(`Unexpected non-Error: ${err}`)
}
error = err
}
@@ -31,6 +31,23 @@ test('request invalid version/javaVersion', async () => {
})
test('find version/javaVersion', async () => {
// Make sure the action can find the latest Java version for known major versions
for (var majorJavaVersion of ['17', '20']) {
await graalvm.findLatestGraalVMJDKCEJavaVersion(majorJavaVersion)
}
let error = new Error('unexpected')
try {
await graalvm.findLatestGraalVMJDKCEJavaVersion('11')
fail('Should not find Java version for 11')
} catch (err) {
if (!(err instanceof Error)) {
fail(`Unexpected non-Error: ${err}`)
}
error = err
}
expect(error.message).toContain('Unable to find the latest Java version for')
const latestRelease = await getTaggedRelease(
GRAALVM_RELEASES_REPO,
'vm-22.3.1'
@@ -40,7 +57,7 @@ test('find version/javaVersion', async () => {
const latestJavaVersion = findHighestJavaVersion(latestRelease, latestVersion)
expect(latestJavaVersion).not.toBe('')
let error = new Error('unexpected')
error = new Error('unexpected')
try {
const invalidRelease = {...latestRelease, tag_name: 'invalid'}
findGraalVMVersion(invalidRelease)
@@ -56,7 +73,7 @@ test('find version/javaVersion', async () => {
findHighestJavaVersion(latestRelease, 'invalid')
} catch (err) {
if (!(err instanceof Error)) {
fail(`Unexpected non-Erro: ${err}`)
fail(`Unexpected non-Error: ${err}`)
}
error = err
}