-
Couldn't load subscription status.
- Fork 815
Add support for Oracle GraalVM #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| import {GraalVMDistribution} from '../../src/distributions/graalvm/installer'; | ||
| import os from 'os'; | ||
| import * as core from '@actions/core'; | ||
| import {getDownloadArchiveExtension} from '../../src/util'; | ||
| import {HttpClient} from '@actions/http-client'; | ||
|
|
||
| describe('findPackageForDownload', () => { | ||
| let distribution: GraalVMDistribution; | ||
| let spyDebug: jest.SpyInstance; | ||
| let spyHttpClient: jest.SpyInstance; | ||
|
|
||
| beforeEach(() => { | ||
| distribution = new GraalVMDistribution({ | ||
| version: '', | ||
| architecture: 'x64', | ||
| packageType: 'jdk', | ||
| checkLatest: false | ||
| }); | ||
|
|
||
| spyDebug = jest.spyOn(core, 'debug'); | ||
| spyDebug.mockImplementation(() => {}); | ||
| }); | ||
|
|
||
| it.each([ | ||
| [ | ||
| '21', | ||
| '21', | ||
| 'https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' | ||
| ], | ||
| [ | ||
| '21.0.4', | ||
| '21.0.4', | ||
| 'https://download.oracle.com/graalvm/21/archive/graalvm-jdk-21.0.4_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' | ||
| ], | ||
| [ | ||
| '17', | ||
| '17', | ||
| 'https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' | ||
| ], | ||
| [ | ||
| '17.0.12', | ||
| '17.0.12', | ||
| 'https://download.oracle.com/graalvm/17/archive/graalvm-jdk-17.0.12_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' | ||
| ] | ||
| ])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => { | ||
| /* Needed only for this particular test because /latest/ urls tend to change */ | ||
| spyHttpClient = jest.spyOn(HttpClient.prototype, 'head'); | ||
| spyHttpClient.mockReturnValue( | ||
| Promise.resolve({ | ||
| message: { | ||
| statusCode: 200 | ||
| } | ||
| }) | ||
| ); | ||
|
|
||
| const result = await distribution['findPackageForDownload'](input); | ||
|
|
||
| jest.restoreAllMocks(); | ||
|
|
||
| expect(result.version).toBe(expectedVersion); | ||
| const osType = distribution.getPlatform(); | ||
| const archiveType = getDownloadArchiveExtension(); | ||
| const url = expectedUrl | ||
| .replace('{{OS_TYPE}}', osType) | ||
| .replace('{{ARCHIVE_TYPE}}', archiveType); | ||
| expect(result.url).toBe(url); | ||
| }); | ||
|
|
||
| it.each([ | ||
| [ | ||
| '24-ea', | ||
| /^https:\/\/github\.com\/graalvm\/oracle-graalvm-ea-builds\/releases\/download\/jdk-24\.0\.0-ea\./ | ||
| ] | ||
| ])('version is %s -> %s', async (version, expectedUrlPrefix) => { | ||
| /* Needed only for this particular test because /latest/ urls tend to change */ | ||
| spyHttpClient = jest.spyOn(HttpClient.prototype, 'head'); | ||
| spyHttpClient.mockReturnValue( | ||
| Promise.resolve({ | ||
| message: { | ||
| statusCode: 200 | ||
| } | ||
| }) | ||
| ); | ||
|
|
||
| const eaDistro = new GraalVMDistribution({ | ||
| version, | ||
| architecture: '', // to get default value | ||
| packageType: 'jdk', | ||
| checkLatest: false | ||
| }); | ||
|
|
||
| const versionWithoutEA = version.split('-')[0]; | ||
| const result = await eaDistro['findPackageForDownload'](versionWithoutEA); | ||
|
|
||
| jest.restoreAllMocks(); | ||
|
|
||
| expect(result.url).toEqual(expect.stringMatching(expectedUrlPrefix)); | ||
| }); | ||
|
|
||
| it.each([ | ||
| ['amd64', 'x64'], | ||
| ['arm64', 'aarch64'] | ||
| ])( | ||
| 'defaults to os.arch(): %s mapped to distro arch: %s', | ||
| async (osArch: string, distroArch: string) => { | ||
| jest.spyOn(os, 'arch').mockReturnValue(osArch); | ||
| jest.spyOn(os, 'platform').mockReturnValue('linux'); | ||
|
|
||
| const version = '21'; | ||
| const distro = new GraalVMDistribution({ | ||
| version, | ||
| architecture: '', // to get default value | ||
| packageType: 'jdk', | ||
| checkLatest: false | ||
| }); | ||
|
|
||
| const osType = distribution.getPlatform(); | ||
| if (osType === 'windows' && distroArch == 'aarch64') { | ||
| return; // skip, aarch64 is not available for Windows | ||
| } | ||
| const archiveType = getDownloadArchiveExtension(); | ||
| const result = await distro['findPackageForDownload'](version); | ||
| const expectedUrl = `https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_${osType}-${distroArch}_bin.${archiveType}`; | ||
|
|
||
| expect(result.url).toBe(expectedUrl); | ||
| } | ||
| ); | ||
|
|
||
| it('should throw an error', async () => { | ||
| await expect(distribution['findPackageForDownload']('8')).rejects.toThrow( | ||
| /GraalVM is only supported for JDK 17 and later/ | ||
| ); | ||
| await expect(distribution['findPackageForDownload']('11')).rejects.toThrow( | ||
| /GraalVM is only supported for JDK 17 and later/ | ||
| ); | ||
| await expect(distribution['findPackageForDownload']('18')).rejects.toThrow( | ||
| /Could not find GraalVM for SemVer */ | ||
| ); | ||
|
|
||
| const unavailableEADistro = new GraalVMDistribution({ | ||
| version: '17-ea', | ||
| architecture: '', // to get default value | ||
| packageType: 'jdk', | ||
| checkLatest: false | ||
| }); | ||
| await expect( | ||
| unavailableEADistro['findPackageForDownload']('17') | ||
| ).rejects.toThrow( | ||
| /No GraalVM EA build found\. Are you sure java-version: '17-ea' is correct\?/ | ||
| ); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.