Enable support for GraalVM Enterprise Edition.

Fixes #5.
This commit is contained in:
Fabio Niephaus 2022-04-19 21:27:19 +02:00
parent 8cce0a82bf
commit e343c9a746
No known key found for this signature in database
GPG Key ID: F21CF5275F31DFD6
6 changed files with 34 additions and 33 deletions

View File

@ -75,9 +75,9 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
version: ['21.3.0', 'latest'] version: ['22.1.0', 'latest']
java-version: ['11', '17'] java-version: ['11', '17']
components: [''] # ['native-image'] (activate after 22.1.0 is released) components: ['native-image']
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -96,14 +96,14 @@ jobs:
echo "JAVA_HOME: $JAVA_HOME" echo "JAVA_HOME: $JAVA_HOME"
java --version java --version
java --version | grep "GraalVM EE" || exit 23 java --version | grep "GraalVM EE" || exit 23
# native-image --version (activate after 22.1.0 is released) native-image --version
if: runner.os != 'Windows' if: runner.os != 'Windows'
- name: Check Windows environment - name: Check Windows environment
run: | run: |
echo "GRAALVM_HOME: $env:GRAALVM_HOME" echo "GRAALVM_HOME: $env:GRAALVM_HOME"
echo "JAVA_HOME: $env:JAVA_HOME" echo "JAVA_HOME: $env:JAVA_HOME"
java --version java --version
# native-image --version (activate after 22.1.0 is released) native-image --version
if: runner.os == 'Windows' if: runner.os == 'Windows'
test-mandrel: test-mandrel:
name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }} name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}

View File

@ -10,21 +10,21 @@ test('fetch artifacts', async () => {
let artifact = await fetchArtifact( let artifact = await fetchArtifact(
TEST_USER_AGENT, TEST_USER_AGENT,
'isBase:True', 'isBase:True',
'21.3.0', '22.1.0',
'11' '11'
) )
expect(artifact.id).toBe('D540A9EA0F406A12E0530F15000A38C7') expect(artifact.id).toBe('DCECD1C1B0B5B8DBE0536E16000A5C74')
expect(artifact.checksum).toBe( expect(artifact.checksum).toBe(
'78e1ee14861eb6a58fd0d7f64878d544ad11515c237a6557452f4d3a63a070fc' '4280782f6c7fcabe0ba707e8389cbfaf7bbe6b0cf634d309e6efcd1b172e3ce6'
) )
artifact = await fetchArtifact(TEST_USER_AGENT, 'isBase:True', '21.3.0', '17') artifact = await fetchArtifact(TEST_USER_AGENT, 'isBase:True', '22.1.0', '17')
expect(artifact.id).toBe('D540A9EA10C26A12E0530F15000A38C7') expect(artifact.id).toBe('DCECD2068882A0E9E0536E16000A9504')
expect(artifact.checksum).toBe( expect(artifact.checksum).toBe(
'173e0e2b1f80033115216ebbad574c977e74fc4a37fa30ae5e6eff0f215070f4' 'e897add7d94bc456a61e6f927e831dff759efa3392a4b69c720dd3debc8f947d'
) )
await expect( await expect(
fetchArtifact(TEST_USER_AGENT, 'isBase:False', '21.3.0', '11') fetchArtifact(TEST_USER_AGENT, 'isBase:False', '22.1.0', '11')
).rejects.toThrow('Found more than one GDS artifact') ).rejects.toThrow('Found more than one GDS artifact')
await expect( await expect(
fetchArtifact(TEST_USER_AGENT, 'isBase:True', '1.0.0', '11') fetchArtifact(TEST_USER_AGENT, 'isBase:True', '1.0.0', '11')
@ -32,13 +32,13 @@ test('fetch artifacts', async () => {
}) })
test('errors when downloading artifacts', async () => { test('errors when downloading artifacts', async () => {
await expect(downloadGraalVMEE('invalid', '21.3.0', '11')).rejects.toThrow( await expect(downloadGraalVMEE('invalid', '22.1.0', '11')).rejects.toThrow(
'The provided "gds-token" was rejected (reason: "Invalid download token", opc-request-id: /' 'The provided "gds-token" was rejected (reason: "Invalid download token", opc-request-id: /'
) )
await expect(downloadGraalVMEE('invalid', '1.0.0', '11')).rejects.toThrow( await expect(downloadGraalVMEE('invalid', '1.0.0', '11')).rejects.toThrow(
'Unable to find JDK11-based GraalVM EE 1.0.0' 'Unable to find JDK11-based GraalVM EE 1.0.0'
) )
await expect(downloadGraalVMEE('invalid', '21.3.0', '1')).rejects.toThrow( await expect(downloadGraalVMEE('invalid', '22.1.0', '1')).rejects.toThrow(
'Unable to find JDK1-based GraalVM EE 21.3.0' 'Unable to find JDK1-based GraalVM EE 22.1.0'
) )
}) })

15
dist/index.js generated vendored
View File

@ -254,12 +254,15 @@ function fetchArtifact(userAgent, metadata, version, javaVersion) {
const http = new httpClient.HttpClient(userAgent); const http = new httpClient.HttpClient(userAgent);
let filter; let filter;
if (version === c.VERSION_LATEST) { if (version === c.VERSION_LATEST) {
filter = `sortBy=timeCreated&limit=1`; // latest and only one item filter = `sortBy=displayName&sortOrder=DESC&limit=1`; // latest and only one item
} }
else { else {
filter = `metadata=version:${version}`; filter = `metadata=version:${version}`;
} }
const response = yield http.get(`${c.GDS_BASE}/artifacts?productId=${c.GDS_GRAALVM_PRODUCT_ID}&${filter}&metadata=java:jdk${javaVersion}&metadata=os:${c.GRAALVM_PLATFORM}&metadata=arch:${c.GRAALVM_ARCH}&metadata=${metadata}&status=PUBLISHED&responseFields=id&responseFields=checksum`, { accept: 'application/json' }); const catalogOS = c.IS_MACOS ? 'macos' : c.GRAALVM_PLATFORM;
const requestUrl = `${c.GDS_BASE}/artifacts?productId=${c.GDS_GRAALVM_PRODUCT_ID}&${filter}&metadata=java:jdk${javaVersion}&metadata=os:${catalogOS}&metadata=arch:${c.GRAALVM_ARCH}&metadata=${metadata}&status=PUBLISHED&responseFields=id&responseFields=checksum`;
core.debug(`Requesting ${requestUrl}`);
const response = yield http.get(requestUrl, { accept: 'application/json' });
if (response.message.statusCode !== 200) { if (response.message.statusCode !== 200) {
throw new Error(`Unable to find JDK${javaVersion}-based GraalVM EE ${version}`); throw new Error(`Unable to find JDK${javaVersion}-based GraalVM EE ${version}`);
} }
@ -523,11 +526,9 @@ const COMPONENT_TO_POST_INSTALL_HOOK = new Map([
]); ]);
function setUpGUComponents(gdsToken, graalVMHome, components) { function setUpGUComponents(gdsToken, graalVMHome, components) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const optionalFlags = []; yield (0, utils_1.exec)('gu', BASE_FLAGS.concat(components), {
if (gdsToken.length > 0) { env: Object.assign(Object.assign({}, process.env), { GRAAL_EE_DOWNLOAD_TOKEN: gdsToken })
optionalFlags.push('--token', gdsToken); });
}
yield (0, utils_1.exec)('gu', BASE_FLAGS.concat(optionalFlags, components));
const platformHooks = COMPONENT_TO_POST_INSTALL_HOOK.get(constants_1.GRAALVM_PLATFORM); const platformHooks = COMPONENT_TO_POST_INSTALL_HOOK.get(constants_1.GRAALVM_PLATFORM);
if (platformHooks) { if (platformHooks) {
for (const component of components) { for (const component of components) {

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -52,15 +52,15 @@ export async function fetchArtifact(
let filter let filter
if (version === c.VERSION_LATEST) { if (version === c.VERSION_LATEST) {
filter = `sortBy=timeCreated&limit=1` // latest and only one item filter = `sortBy=displayName&sortOrder=DESC&limit=1` // latest and only one item
} else { } else {
filter = `metadata=version:${version}` filter = `metadata=version:${version}`
} }
const response = await http.get( const catalogOS = c.IS_MACOS ? 'macos' : c.GRAALVM_PLATFORM
`${c.GDS_BASE}/artifacts?productId=${c.GDS_GRAALVM_PRODUCT_ID}&${filter}&metadata=java:jdk${javaVersion}&metadata=os:${c.GRAALVM_PLATFORM}&metadata=arch:${c.GRAALVM_ARCH}&metadata=${metadata}&status=PUBLISHED&responseFields=id&responseFields=checksum`, const requestUrl = `${c.GDS_BASE}/artifacts?productId=${c.GDS_GRAALVM_PRODUCT_ID}&${filter}&metadata=java:jdk${javaVersion}&metadata=os:${catalogOS}&metadata=arch:${c.GRAALVM_ARCH}&metadata=${metadata}&status=PUBLISHED&responseFields=id&responseFields=checksum`
{accept: 'application/json'} core.debug(`Requesting ${requestUrl}`)
) const response = await http.get(requestUrl, {accept: 'application/json'})
if (response.message.statusCode !== 200) { if (response.message.statusCode !== 200) {
throw new Error( throw new Error(
`Unable to find JDK${javaVersion}-based GraalVM EE ${version}` `Unable to find JDK${javaVersion}-based GraalVM EE ${version}`

View File

@ -26,12 +26,12 @@ export async function setUpGUComponents(
graalVMHome: string, graalVMHome: string,
components: string[] components: string[]
): Promise<void> { ): Promise<void> {
const optionalFlags = [] await exec('gu', BASE_FLAGS.concat(components), {
if (gdsToken.length > 0) { env: {
optionalFlags.push('--token', gdsToken) ...process.env,
} GRAAL_EE_DOWNLOAD_TOKEN: gdsToken
}
await exec('gu', BASE_FLAGS.concat(optionalFlags, components)) })
const platformHooks = COMPONENT_TO_POST_INSTALL_HOOK.get(GRAALVM_PLATFORM) const platformHooks = COMPONENT_TO_POST_INSTALL_HOOK.get(GRAALVM_PLATFORM)
if (platformHooks) { if (platformHooks) {