Skip to content
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

Initial support for early access builds of Oracle GraalVM #83

Merged
merged 7 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
]
components: ['']
include:
- java-version: '22-ea'
distribution: 'graalvm'
os: ubuntu-latest
- java-version: '21'
distribution: ''
os: ubuntu-latest
Expand Down
57 changes: 29 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,6 @@ This action:
- has built-in support for GraalVM components and the [GraalVM Updater][gu]


## Migrating from GraalVM 22.3 or Earlier to the New GraalVM for JDK 17 and Later

The [GraalVM for JDK 17 and JDK 20 release](https://medium.com/graalvm/a-new-graalvm-release-and-new-free-license-4aab483692f5) aligns the GraalVM version scheme with OpenJDK.
As a result, this action no longer requires the `version` option to select a specific GraalVM version.
At the same time, it introduces a new `distribution` option to select a specific GraalVM distribution (`graalvm`, `graalvm-community`, or `mandrel`).
Therefore, to migrate your workflow to use the latest GraalVM release, replace the `version` with the `distribution` option in the workflow `yml` config, for example:

```yml
# ...
- uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
version: '22.3.2' # Old 'version' option for the GraalVM version
# ...
```

can be replaced with:

```yml
# ...
- uses: graalvm/setup-graalvm@v1
with:
java-version: '17.0.7' # for a specific JDK 17; or '17' for the latest JDK 17
distribution: 'graalvm' # New 'distribution' option
# ...
```


## Templates

### Quickstart Template
Expand Down Expand Up @@ -162,6 +134,35 @@ jobs:

</details>


## Migrating from GraalVM 22.3 or Earlier to the New GraalVM for JDK 17 and Later

The [GraalVM for JDK 17 and JDK 20 release](https://medium.com/graalvm/a-new-graalvm-release-and-new-free-license-4aab483692f5) aligns the GraalVM version scheme with OpenJDK.
As a result, this action no longer requires the `version` option to select a specific GraalVM version.
At the same time, it introduces a new `distribution` option to select a specific GraalVM distribution (`graalvm`, `graalvm-community`, or `mandrel`).
Therefore, to migrate your workflow to use the latest GraalVM release, replace the `version` with the `distribution` option in the workflow `yml` config, for example:

```yml
# ...
- uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
version: '22.3.2' # Old 'version' option for the GraalVM version
# ...
```

can be replaced with:

```yml
# ...
- uses: graalvm/setup-graalvm@v1
with:
java-version: '17.0.7' # for a specific JDK 17; or '17' for the latest JDK 17
distribution: 'graalvm' # New 'distribution' option
# ...
```


## Options

| Name | Default | Description |
Expand Down
108 changes: 57 additions & 51 deletions __tests__/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ describe('dependency cache', () => {
})

it('throws error if unsupported package manager specified', () => {
return expect(restore('ant')).rejects.toThrowError(
return expect(restore('ant')).rejects.toThrow(
'unknown package manager specified: ant'
)
})

describe('for maven', () => {
it('throws error if no pom.xml found', async () => {
await expect(restore('maven')).rejects.toThrowError(
await expect(restore('maven')).rejects.toThrow(
`No file in ${projectRoot(
workspace
)} matched to [**/pom.xml], make sure you have checked out the target repository`
Expand All @@ -118,14 +118,14 @@ describe('dependency cache', () => {
createFile(join(workspace, 'pom.xml'))

await restore('maven')
expect(spyCacheRestore).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith('maven cache is not found')
expect(spyCacheRestore).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found')
})
})
describe('for gradle', () => {
it('throws error if no build.gradle found', async () => {
await expect(restore('gradle')).rejects.toThrowError(
await expect(restore('gradle')).rejects.toThrow(
`No file in ${projectRoot(
workspace
)} matched to [**/*.gradle*,**/gradle-wrapper.properties,buildSrc/**/Versions.kt,buildSrc/**/Dependencies.kt], make sure you have checked out the target repository`
Expand All @@ -135,31 +135,31 @@ describe('dependency cache', () => {
createFile(join(workspace, 'build.gradle'))

await restore('gradle')
expect(spyCacheRestore).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith('gradle cache is not found')
expect(spyCacheRestore).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found')
})
it('downloads cache based on build.gradle.kts', async () => {
createFile(join(workspace, 'build.gradle.kts'))

await restore('gradle')
expect(spyCacheRestore).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith('gradle cache is not found')
expect(spyCacheRestore).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found')
})
})
it('downloads cache based on buildSrc/Versions.kt', async () => {
createDirectory(join(workspace, 'buildSrc'))
createFile(join(workspace, 'buildSrc', 'Versions.kt'))

await restore('gradle')
expect(spyCacheRestore).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith('gradle cache is not found')
expect(spyCacheRestore).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found')
})
describe('for sbt', () => {
it('throws error if no build.sbt found', async () => {
await expect(restore('sbt')).rejects.toThrowError(
await expect(restore('sbt')).rejects.toThrow(
`No file in ${projectRoot(
workspace
)} matched to [**/*.sbt,**/project/build.properties,**/project/**.{scala,sbt}], make sure you have checked out the target repository`
Expand All @@ -169,9 +169,9 @@ describe('dependency cache', () => {
createFile(join(workspace, 'build.sbt'))

await restore('sbt')
expect(spyCacheRestore).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith('sbt cache is not found')
expect(spyCacheRestore).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith('sbt cache is not found')
})
})
})
Expand All @@ -191,7 +191,7 @@ describe('dependency cache', () => {
})

it('throws error if unsupported package manager specified', () => {
return expect(save('ant')).rejects.toThrowError(
return expect(save('ant')).rejects.toThrow(
'unknown package manager specified: ant'
)
})
Expand All @@ -201,10 +201,10 @@ describe('dependency cache', () => {
createStateForMissingBuildFile()

await save('maven')
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalled()
expect(spyInfo).toBeCalledWith(
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
)
})
Expand All @@ -225,24 +225,26 @@ describe('dependency cache', () => {
it('uploads cache even if no pom.xml found', async () => {
createStateForMissingBuildFile()
await save('maven')
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
})
it('does not upload cache if no restore run before', async () => {
createFile(join(workspace, 'pom.xml'))

await save('maven')
expect(spyCacheSave).not.toBeCalled()
expect(spyWarning).toBeCalledWith('Error retrieving key from state.')
expect(spyCacheSave).not.toHaveBeenCalled()
expect(spyWarning).toHaveBeenCalledWith(
'Error retrieving key from state.'
)
})
it('uploads cache', async () => {
createFile(join(workspace, 'pom.xml'))
createStateForSuccessfulRestore()

await save('maven')
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith(
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
)
})
Expand All @@ -252,24 +254,26 @@ describe('dependency cache', () => {
createStateForMissingBuildFile()

await save('gradle')
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
})
it('does not upload cache if no restore run before', async () => {
createFile(join(workspace, 'build.gradle'))

await save('gradle')
expect(spyCacheSave).not.toBeCalled()
expect(spyWarning).toBeCalledWith('Error retrieving key from state.')
expect(spyCacheSave).not.toHaveBeenCalled()
expect(spyWarning).toHaveBeenCalledWith(
'Error retrieving key from state.'
)
})
it('uploads cache based on build.gradle', async () => {
createFile(join(workspace, 'build.gradle'))
createStateForSuccessfulRestore()

await save('gradle')
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith(
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
)
})
Expand All @@ -278,9 +282,9 @@ describe('dependency cache', () => {
createStateForSuccessfulRestore()

await save('gradle')
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith(
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
)
})
Expand All @@ -290,9 +294,9 @@ describe('dependency cache', () => {
createStateForSuccessfulRestore()

await save('gradle')
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith(
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
)
})
Expand All @@ -301,24 +305,26 @@ describe('dependency cache', () => {
it('uploads cache even if no build.sbt found', async () => {
createStateForMissingBuildFile()
await save('sbt')
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
})
it('does not upload cache if no restore run before', async () => {
createFile(join(workspace, 'build.sbt'))

await save('sbt')
expect(spyCacheSave).not.toBeCalled()
expect(spyWarning).toBeCalledWith('Error retrieving key from state.')
expect(spyCacheSave).not.toHaveBeenCalled()
expect(spyWarning).toHaveBeenCalledWith(
'Error retrieving key from state.'
)
})
it('uploads cache', async () => {
createFile(join(workspace, 'build.sbt'))
createStateForSuccessfulRestore()

await save('sbt')
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyInfo).toBeCalledWith(
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
)
})
Expand Down
7 changes: 3 additions & 4 deletions __tests__/cleanup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import {run as cleanup} from '../src/cleanup'
import * as core from '@actions/core'
import * as cache from '@actions/cache'
import * as util from '../src/utils'

describe('cleanup', () => {
let spyWarning: jest.SpyInstance<void, Parameters<typeof core.warning>>
Expand Down Expand Up @@ -62,8 +61,8 @@ describe('cleanup', () => {
return name === 'cache' ? 'gradle' : ''
})
await cleanup()
expect(spyCacheSave).toBeCalled()
expect(spyWarning).not.toBeCalled()
expect(spyCacheSave).toHaveBeenCalled()
expect(spyWarning).not.toHaveBeenCalled()
})

it('does not fail even though the save process throws error', async () => {
Expand All @@ -74,7 +73,7 @@ describe('cleanup', () => {
return name === 'cache' ? 'gradle' : ''
})
await cleanup()
expect(spyCacheSave).toBeCalled()
expect(spyCacheSave).toHaveBeenCalled()
})
})

Expand Down
34 changes: 34 additions & 0 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as path from 'path'
import {expect, test} from '@jest/globals'
import {toSemVer} from '../src/utils'

test('convert version', async () => {
for (var inputAndExpectedOutput of [
['22', '22.0.0'],
['22.0', '22.0.0'],
['22.0.0', '22.0.0'],
['22.0.0.2', '22.0.0-2'],
['22-ea', '22.0.0-ea'],
['22.0-ea', '22.0.0-ea'],
['22.0.0-ea', '22.0.0-ea']
]) {
expect(toSemVer(inputAndExpectedOutput[0])).toBe(inputAndExpectedOutput[1])
}
})

test('convert invalid version', async () => {
for (var input of ['dev', 'abc', 'a.b.c']) {
let error = new Error('unexpected')
try {
toSemVer(input)
} catch (err) {
if (!(err instanceof Error)) {
fail(`Unexpected non-Error: ${err}`)
}
error = err
}

expect(error).not.toBeUndefined()
expect(error.message).toContain('Unable to convert')
}
})
Loading
Loading