-
Notifications
You must be signed in to change notification settings - Fork 30
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
Added Liberica Native Image Kit as new distribution #87
Closed
Closed
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f4d9dcc
Added Liberica distribution
petermz d498bca
Musl support
petermz 28079d6
Added Liberica to README
petermz e3034b8
Removed mentions of 'version=core'
petermz ad288a9
Bumped version
petermz 25bad63
Use `java-package` input instead of `version`
petermz 5dba04a
Cleanups
petermz 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 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 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 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 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,138 @@ | ||
import * as liberica from '../src/liberica' | ||
import * as c from '../src/constants' | ||
import * as path from 'path' | ||
import * as semver from 'semver' | ||
import {expect, test} from '@jest/globals' | ||
|
||
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE') | ||
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP') | ||
|
||
test('find latest JDK version', async () => { | ||
// Make sure the action can find the latest Java version for known major versions | ||
await expectLatestToBe('11', atLeast('11.0.22+12')) | ||
await expectLatestToBe('11.0.22', upToBuild('11.0.22+12')) | ||
await expectLatestToBe('11.0.22+12', exactly('11.0.22+12')) | ||
|
||
await expectLatestToBe('17', atLeast('17.0.10+13')) | ||
await expectLatestToBe('17.0.10', upToBuild('17.0.10+13')) | ||
await expectLatestToBe('17.0.10+13', exactly('17.0.10+13')) | ||
|
||
await expectLatestToBe('21', atLeast('21.0.2+14')) | ||
await expectLatestToBe('21.0.2', upToBuild('21.0.2+14')) | ||
await expectLatestToBe('21.0.2+14', exactly('21.0.2+14')) | ||
|
||
// Outdated major version | ||
await expectLatestToFail('20') | ||
|
||
// Outdated CPU versions | ||
await expectLatestToFail('11.0.2') // should not resolve to 11.0.22 | ||
await expectLatestToFail('17.0.1') // should not resolve to 17.0.10 | ||
await expectLatestToFail('17.0.7+11') | ||
await expectLatestToFail('21.0.0+8') | ||
await expectLatestToFail('21.0.1') | ||
|
||
// Incorrect build number | ||
await expectLatestToFail('17.0.10+10') | ||
}, 30000) | ||
|
||
test('find asset URL', async () => { | ||
await expectURL('11.0.22+12', '', 'bellsoft-liberica-vm-openjdk11.0.22') | ||
await expectURL('17.0.10+13', 'std', 'bellsoft-liberica-vm-openjdk17.0.10') | ||
|
||
if (!c.IS_LINUX) { | ||
// This check can fail on Linux because there's no `full` version for aarch64 and/or musl | ||
await expectURL( | ||
'21.0.2+14', | ||
'full', | ||
'bellsoft-liberica-vm-full-openjdk21.0.2' | ||
) | ||
} | ||
}, 10000) | ||
|
||
type verifier = ( | ||
version: string, | ||
major: number, | ||
minor: number, | ||
patch: number | ||
) => void | ||
|
||
function atLeast(expectedMinVersion: string): verifier { | ||
const expectedMajor = semver.major(expectedMinVersion) | ||
return function ( | ||
version: string, | ||
major: number, | ||
minor: number, | ||
patch: number | ||
) { | ||
expect(major).toBe(expectedMajor) | ||
if (semver.compareBuild(version, expectedMinVersion) < 0) { | ||
throw new Error(`Version ${version} is older than ${expectedMinVersion}`) | ||
} | ||
} | ||
} | ||
|
||
function upToBuild(expectedMinVersion: string): verifier { | ||
const expectedMinor = semver.minor(expectedMinVersion) | ||
const expectedPatch = semver.patch(expectedMinVersion) | ||
const atLeastVerifier = atLeast(expectedMinVersion) | ||
return function ( | ||
version: string, | ||
major: number, | ||
minor: number, | ||
patch: number | ||
) { | ||
atLeastVerifier(version, major, minor, patch) | ||
expect(minor).toBe(expectedMinor) | ||
expect(patch).toBe(expectedPatch) | ||
} | ||
} | ||
|
||
function exactly(expectedVersion: string): verifier { | ||
return function ( | ||
version: string, | ||
major: number, | ||
minor: number, | ||
patch: number | ||
) { | ||
if (semver.compareBuild(version, expectedVersion) != 0) { | ||
throw new Error(`Expected version ${expectedVersion} but got ${version}`) | ||
} | ||
} | ||
} | ||
|
||
async function expectLatestToBe(pattern: string, verify: verifier) { | ||
const result = await liberica.findLatestLibericaJavaVersion(pattern) | ||
expect(semver.valid(result)).toBeDefined() | ||
const major = semver.major(result) | ||
const minor = semver.minor(result) | ||
const patch = semver.patch(result) | ||
verify(result, major, minor, patch) | ||
} | ||
|
||
async function expectLatestToFail(pattern: string) { | ||
try { | ||
const result = await liberica.findLatestLibericaJavaVersion(pattern) | ||
throw new Error( | ||
`findLatest(${pattern}) should have failed but returned ${result}` | ||
) | ||
} catch (err) { | ||
if (!(err instanceof Error)) { | ||
throw new Error(`Unexpected non-Error: ${err}`) | ||
} | ||
expect(err.message).toContain( | ||
`Unable to find the latest version for JDK${pattern}` | ||
) | ||
} | ||
} | ||
|
||
async function expectURL( | ||
javaVersion: string, | ||
version: string, | ||
expectedPrefix: string | ||
) { | ||
const url = await liberica.findLibericaURL(javaVersion, version) | ||
expect(url).toBeDefined() | ||
const parts = url.split('/') | ||
const file = parts[parts.length - 1] | ||
expect(file.startsWith(expectedPrefix)).toBe(true) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually am phasing out
version
in favor of just thejava-version
. It seems there are different variants of Liberica. Can these also be pulled bysetup-java
and if yes, how?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT this is controlled by the
java-package
parameter:The value of
jdk
corresponds toversion: std
, andjdk+fx
corresponds toversion: full
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Mapping
jdk+fx
tofull
seems like a hack, assuming fx stands for JavaFX? If Liberica users are more familiar withstd
andfull
, I'm ok with using those directly, maybe also allowingjdk
andjdk+fx
for full compatibility withsetup-java
. In any case, we should add thejava-package
input fromsetup-java
and not use theversion
input for this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've added the
java-package: jdk | jdk+fx
input