Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d72e3dbf5f | ||
|
|
22551b2bec | ||
|
|
bf3e45bce6 | ||
|
|
1588b03f82 | ||
|
|
6df9f698c6 | ||
|
|
2408275e34 | ||
|
|
a638430bc0 | ||
|
|
3bd233e767 | ||
|
|
c99915cc1a | ||
|
|
a0f131ece5 | ||
|
|
a1b47fdf04 | ||
|
|
129a551a10 | ||
|
|
b8dc5fccfb | ||
|
|
1c219f5b27 | ||
|
|
2a93b69fdf | ||
|
|
0b782b6b90 | ||
|
|
d5b07dd118 | ||
|
|
40dc6ae006 | ||
|
|
cde0daed27 | ||
|
|
22b65d7de0 | ||
|
|
c2fd2d6d8e | ||
|
|
2b3d0bde8f | ||
|
|
6c7d417a1e | ||
|
|
8dd4f51a5e | ||
|
|
2fb264a6b0 |
6
.github/workflows/check-dist.yml
vendored
6
.github/workflows/check-dist.yml
vendored
@@ -26,10 +26,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set Node.js 16.x
|
- name: Set Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 20.x
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
27
.github/workflows/test.yml
vendored
27
.github/workflows/test.yml
vendored
@@ -27,8 +27,17 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
java-version: ['21', '17', '20', 'dev']
|
java-version: ['21', '17', '20', 'dev']
|
||||||
distribution: ['graalvm', 'graalvm-community']
|
distribution: ['graalvm', 'graalvm-community']
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [
|
||||||
|
ubuntu-latest,
|
||||||
|
macos-14, # macOS on Apple silicon
|
||||||
|
macos-12, # macOS on Intel
|
||||||
|
windows-latest
|
||||||
|
]
|
||||||
|
components: ['']
|
||||||
include:
|
include:
|
||||||
|
- java-version: '22-ea'
|
||||||
|
distribution: 'graalvm'
|
||||||
|
os: ubuntu-latest
|
||||||
- java-version: '21'
|
- java-version: '21'
|
||||||
distribution: ''
|
distribution: ''
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
@@ -39,6 +48,9 @@ jobs:
|
|||||||
distribution: 'graalvm-community'
|
distribution: 'graalvm-community'
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
components: 'native-image' # should print a warning but not fail
|
components: 'native-image' # should print a warning but not fail
|
||||||
|
- java-version: '21.0.0' # test for GA version (see #63)
|
||||||
|
distribution: 'graalvm'
|
||||||
|
os: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
@@ -47,6 +59,7 @@ jobs:
|
|||||||
java-version: ${{ matrix.java-version }}
|
java-version: ${{ matrix.java-version }}
|
||||||
distribution: ${{ matrix.distribution }}
|
distribution: ${{ matrix.distribution }}
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
components: ${{ matrix.components }}
|
||||||
- name: Check environment
|
- name: Check environment
|
||||||
run: |
|
run: |
|
||||||
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
||||||
@@ -185,7 +198,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
version: ['mandrel-22.2.0.0-Final', 'mandrel-latest']
|
version: ['mandrel-22.2.0.0-Final', '23.0.1.2-Final', 'mandrel-latest']
|
||||||
java-version: ['17']
|
java-version: ['17']
|
||||||
distribution: ['mandrel']
|
distribution: ['mandrel']
|
||||||
os: [windows-latest, ubuntu-latest]
|
os: [windows-latest, ubuntu-latest]
|
||||||
@@ -194,10 +207,10 @@ jobs:
|
|||||||
java-version: '17'
|
java-version: '17'
|
||||||
distribution: '' # test empty distribution for backward compatibility
|
distribution: '' # test empty distribution for backward compatibility
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
exclude: # temporarily disable Mandrel latest builds on Windows due to unavailability
|
- version: '' # test with no version
|
||||||
- version: 'mandrel-latest'
|
java-version: '21'
|
||||||
java-version: '17'
|
distribution: 'mandrel'
|
||||||
os: windows-latest
|
os: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
@@ -301,7 +314,7 @@ jobs:
|
|||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '17.0.8'
|
||||||
distribution: 'graalvm'
|
distribution: 'graalvm'
|
||||||
components: 'espresso,llvm-toolchain,native-image,nodejs,python,ruby,wasm'
|
components: 'espresso,llvm-toolchain,native-image,nodejs,python,ruby,wasm'
|
||||||
set-java-home: 'false'
|
set-java-home: 'false'
|
||||||
|
|||||||
59
README.md
59
README.md
@@ -15,34 +15,6 @@ This action:
|
|||||||
- has built-in support for GraalVM components and the [GraalVM Updater][gu]
|
- 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
|
## Templates
|
||||||
|
|
||||||
### Quickstart Template
|
### Quickstart Template
|
||||||
@@ -162,6 +134,35 @@ jobs:
|
|||||||
|
|
||||||
</details>
|
</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
|
## Options
|
||||||
|
|
||||||
| Name | Default | Description |
|
| Name | Default | Description |
|
||||||
@@ -176,7 +177,7 @@ jobs:
|
|||||||
| `native-image-job-reports` *) | `'false'` | If set to `'true'`, post a job summary containing a Native Image build report. |
|
| `native-image-job-reports` *) | `'false'` | If set to `'true'`, post a job summary containing a Native Image build report. |
|
||||||
| `native-image-pr-reports` *) | `'false'` | If set to `'true'`, post a comment containing a Native Image build report on pull requests. Requires `write` permissions for the [`pull-requests` scope][gha-permissions]. |
|
| `native-image-pr-reports` *) | `'false'` | If set to `'true'`, post a comment containing a Native Image build report on pull requests. Requires `write` permissions for the [`pull-requests` scope][gha-permissions]. |
|
||||||
| `components` | `''` | Comma-separated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
|
| `components` | `''` | Comma-separated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
|
||||||
| `version` | `''` | `X.Y.Z` (e.g., `22.3.0`) for a specific [GraalVM release][releases] up to `22.3.2`<br>`mandrel-X.Y.Z` (e.g., `mandrel-21.3.0.0-Final`) for a specific [Mandrel release][mandrel-releases],<br>`mandrel-latest` for [latest Mandrel stable release][mandrel-stable]. |
|
| `version` | `''` | `X.Y.Z` (e.g., `22.3.0`) for a specific [GraalVM release][releases] up to `22.3.2`<br>`mandrel-X.Y.Z.W` or `X.Y.Z.W-Final` (e.g., `mandrel-21.3.0.0-Final` or `21.3.0.0-Final`) for a specific [Mandrel release][mandrel-releases],<br>`mandrel-latest` or `latest` for the latest Mandrel stable release. |
|
||||||
| `gds-token` | `''` | Download token for the GraalVM Download Service. If a non-empty token is provided, the action will set up GraalVM Enterprise Edition (see [GraalVM EE template](#template-for-graalvm-enterprise-edition)). |
|
| `gds-token` | `''` | Download token for the GraalVM Download Service. If a non-empty token is provided, the action will set up GraalVM Enterprise Edition (see [GraalVM EE template](#template-for-graalvm-enterprise-edition)). |
|
||||||
|
|
||||||
**) Make sure that Native Image is used only once per build job. Otherwise, the report is only generated for the last Native Image build.*
|
**) Make sure that Native Image is used only once per build job. Otherwise, the report is only generated for the last Native Image build.*
|
||||||
|
|||||||
@@ -101,14 +101,14 @@ describe('dependency cache', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws error if unsupported package manager specified', () => {
|
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'
|
'unknown package manager specified: ant'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('for maven', () => {
|
describe('for maven', () => {
|
||||||
it('throws error if no pom.xml found', async () => {
|
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(
|
`No file in ${projectRoot(
|
||||||
workspace
|
workspace
|
||||||
)} matched to [**/pom.xml], make sure you have checked out the target repository`
|
)} matched to [**/pom.xml], make sure you have checked out the target repository`
|
||||||
@@ -118,14 +118,14 @@ describe('dependency cache', () => {
|
|||||||
createFile(join(workspace, 'pom.xml'))
|
createFile(join(workspace, 'pom.xml'))
|
||||||
|
|
||||||
await restore('maven')
|
await restore('maven')
|
||||||
expect(spyCacheRestore).toBeCalled()
|
expect(spyCacheRestore).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith('maven cache is not found')
|
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('for gradle', () => {
|
describe('for gradle', () => {
|
||||||
it('throws error if no build.gradle found', async () => {
|
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(
|
`No file in ${projectRoot(
|
||||||
workspace
|
workspace
|
||||||
)} matched to [**/*.gradle*,**/gradle-wrapper.properties,buildSrc/**/Versions.kt,buildSrc/**/Dependencies.kt], make sure you have checked out the target repository`
|
)} matched to [**/*.gradle*,**/gradle-wrapper.properties,buildSrc/**/Versions.kt,buildSrc/**/Dependencies.kt], make sure you have checked out the target repository`
|
||||||
@@ -135,17 +135,17 @@ describe('dependency cache', () => {
|
|||||||
createFile(join(workspace, 'build.gradle'))
|
createFile(join(workspace, 'build.gradle'))
|
||||||
|
|
||||||
await restore('gradle')
|
await restore('gradle')
|
||||||
expect(spyCacheRestore).toBeCalled()
|
expect(spyCacheRestore).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith('gradle cache is not found')
|
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found')
|
||||||
})
|
})
|
||||||
it('downloads cache based on build.gradle.kts', async () => {
|
it('downloads cache based on build.gradle.kts', async () => {
|
||||||
createFile(join(workspace, 'build.gradle.kts'))
|
createFile(join(workspace, 'build.gradle.kts'))
|
||||||
|
|
||||||
await restore('gradle')
|
await restore('gradle')
|
||||||
expect(spyCacheRestore).toBeCalled()
|
expect(spyCacheRestore).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith('gradle cache is not found')
|
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('downloads cache based on buildSrc/Versions.kt', async () => {
|
it('downloads cache based on buildSrc/Versions.kt', async () => {
|
||||||
@@ -153,13 +153,13 @@ describe('dependency cache', () => {
|
|||||||
createFile(join(workspace, 'buildSrc', 'Versions.kt'))
|
createFile(join(workspace, 'buildSrc', 'Versions.kt'))
|
||||||
|
|
||||||
await restore('gradle')
|
await restore('gradle')
|
||||||
expect(spyCacheRestore).toBeCalled()
|
expect(spyCacheRestore).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith('gradle cache is not found')
|
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found')
|
||||||
})
|
})
|
||||||
describe('for sbt', () => {
|
describe('for sbt', () => {
|
||||||
it('throws error if no build.sbt found', async () => {
|
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(
|
`No file in ${projectRoot(
|
||||||
workspace
|
workspace
|
||||||
)} matched to [**/*.sbt,**/project/build.properties,**/project/**.{scala,sbt}], make sure you have checked out the target repository`
|
)} matched to [**/*.sbt,**/project/build.properties,**/project/**.{scala,sbt}], make sure you have checked out the target repository`
|
||||||
@@ -169,9 +169,9 @@ describe('dependency cache', () => {
|
|||||||
createFile(join(workspace, 'build.sbt'))
|
createFile(join(workspace, 'build.sbt'))
|
||||||
|
|
||||||
await restore('sbt')
|
await restore('sbt')
|
||||||
expect(spyCacheRestore).toBeCalled()
|
expect(spyCacheRestore).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith('sbt cache is not found')
|
expect(spyInfo).toHaveBeenCalledWith('sbt cache is not found')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -191,7 +191,7 @@ describe('dependency cache', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws error if unsupported package manager specified', () => {
|
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'
|
'unknown package manager specified: ant'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -201,10 +201,10 @@ describe('dependency cache', () => {
|
|||||||
createStateForMissingBuildFile()
|
createStateForMissingBuildFile()
|
||||||
|
|
||||||
await save('maven')
|
await save('maven')
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalled()
|
expect(spyInfo).toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith(
|
expect(spyInfo).toHaveBeenCalledWith(
|
||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -225,24 +225,26 @@ describe('dependency cache', () => {
|
|||||||
it('uploads cache even if no pom.xml found', async () => {
|
it('uploads cache even if no pom.xml found', async () => {
|
||||||
createStateForMissingBuildFile()
|
createStateForMissingBuildFile()
|
||||||
await save('maven')
|
await save('maven')
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
it('does not upload cache if no restore run before', async () => {
|
it('does not upload cache if no restore run before', async () => {
|
||||||
createFile(join(workspace, 'pom.xml'))
|
createFile(join(workspace, 'pom.xml'))
|
||||||
|
|
||||||
await save('maven')
|
await save('maven')
|
||||||
expect(spyCacheSave).not.toBeCalled()
|
expect(spyCacheSave).not.toHaveBeenCalled()
|
||||||
expect(spyWarning).toBeCalledWith('Error retrieving key from state.')
|
expect(spyWarning).toHaveBeenCalledWith(
|
||||||
|
'Error retrieving key from state.'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
it('uploads cache', async () => {
|
it('uploads cache', async () => {
|
||||||
createFile(join(workspace, 'pom.xml'))
|
createFile(join(workspace, 'pom.xml'))
|
||||||
createStateForSuccessfulRestore()
|
createStateForSuccessfulRestore()
|
||||||
|
|
||||||
await save('maven')
|
await save('maven')
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith(
|
expect(spyInfo).toHaveBeenCalledWith(
|
||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -252,24 +254,26 @@ describe('dependency cache', () => {
|
|||||||
createStateForMissingBuildFile()
|
createStateForMissingBuildFile()
|
||||||
|
|
||||||
await save('gradle')
|
await save('gradle')
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
it('does not upload cache if no restore run before', async () => {
|
it('does not upload cache if no restore run before', async () => {
|
||||||
createFile(join(workspace, 'build.gradle'))
|
createFile(join(workspace, 'build.gradle'))
|
||||||
|
|
||||||
await save('gradle')
|
await save('gradle')
|
||||||
expect(spyCacheSave).not.toBeCalled()
|
expect(spyCacheSave).not.toHaveBeenCalled()
|
||||||
expect(spyWarning).toBeCalledWith('Error retrieving key from state.')
|
expect(spyWarning).toHaveBeenCalledWith(
|
||||||
|
'Error retrieving key from state.'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
it('uploads cache based on build.gradle', async () => {
|
it('uploads cache based on build.gradle', async () => {
|
||||||
createFile(join(workspace, 'build.gradle'))
|
createFile(join(workspace, 'build.gradle'))
|
||||||
createStateForSuccessfulRestore()
|
createStateForSuccessfulRestore()
|
||||||
|
|
||||||
await save('gradle')
|
await save('gradle')
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith(
|
expect(spyInfo).toHaveBeenCalledWith(
|
||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -278,9 +282,9 @@ describe('dependency cache', () => {
|
|||||||
createStateForSuccessfulRestore()
|
createStateForSuccessfulRestore()
|
||||||
|
|
||||||
await save('gradle')
|
await save('gradle')
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith(
|
expect(spyInfo).toHaveBeenCalledWith(
|
||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -290,9 +294,9 @@ describe('dependency cache', () => {
|
|||||||
createStateForSuccessfulRestore()
|
createStateForSuccessfulRestore()
|
||||||
|
|
||||||
await save('gradle')
|
await save('gradle')
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith(
|
expect(spyInfo).toHaveBeenCalledWith(
|
||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -301,24 +305,26 @@ describe('dependency cache', () => {
|
|||||||
it('uploads cache even if no build.sbt found', async () => {
|
it('uploads cache even if no build.sbt found', async () => {
|
||||||
createStateForMissingBuildFile()
|
createStateForMissingBuildFile()
|
||||||
await save('sbt')
|
await save('sbt')
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
it('does not upload cache if no restore run before', async () => {
|
it('does not upload cache if no restore run before', async () => {
|
||||||
createFile(join(workspace, 'build.sbt'))
|
createFile(join(workspace, 'build.sbt'))
|
||||||
|
|
||||||
await save('sbt')
|
await save('sbt')
|
||||||
expect(spyCacheSave).not.toBeCalled()
|
expect(spyCacheSave).not.toHaveBeenCalled()
|
||||||
expect(spyWarning).toBeCalledWith('Error retrieving key from state.')
|
expect(spyWarning).toHaveBeenCalledWith(
|
||||||
|
'Error retrieving key from state.'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
it('uploads cache', async () => {
|
it('uploads cache', async () => {
|
||||||
createFile(join(workspace, 'build.sbt'))
|
createFile(join(workspace, 'build.sbt'))
|
||||||
createStateForSuccessfulRestore()
|
createStateForSuccessfulRestore()
|
||||||
|
|
||||||
await save('sbt')
|
await save('sbt')
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
expect(spyInfo).toBeCalledWith(
|
expect(spyInfo).toHaveBeenCalledWith(
|
||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
import {run as cleanup} from '../src/cleanup'
|
import {run as cleanup} from '../src/cleanup'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as cache from '@actions/cache'
|
import * as cache from '@actions/cache'
|
||||||
import * as util from '../src/utils'
|
|
||||||
|
|
||||||
describe('cleanup', () => {
|
describe('cleanup', () => {
|
||||||
let spyWarning: jest.SpyInstance<void, Parameters<typeof core.warning>>
|
let spyWarning: jest.SpyInstance<void, Parameters<typeof core.warning>>
|
||||||
@@ -62,8 +61,8 @@ describe('cleanup', () => {
|
|||||||
return name === 'cache' ? 'gradle' : ''
|
return name === 'cache' ? 'gradle' : ''
|
||||||
})
|
})
|
||||||
await cleanup()
|
await cleanup()
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
expect(spyWarning).not.toBeCalled()
|
expect(spyWarning).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not fail even though the save process throws error', async () => {
|
it('does not fail even though the save process throws error', async () => {
|
||||||
@@ -74,7 +73,7 @@ describe('cleanup', () => {
|
|||||||
return name === 'cache' ? 'gradle' : ''
|
return name === 'cache' ? 'gradle' : ''
|
||||||
})
|
})
|
||||||
await cleanup()
|
await cleanup()
|
||||||
expect(spyCacheSave).toBeCalled()
|
expect(spyCacheSave).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
75
__tests__/mandrel.test.ts
Normal file
75
__tests__/mandrel.test.ts
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import * as path from 'path'
|
||||||
|
import * as mandrel from '../src/mandrel'
|
||||||
|
import {expect, test} from '@jest/globals'
|
||||||
|
import {getLatestRelease} from '../src/utils'
|
||||||
|
|
||||||
|
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
|
||||||
|
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
|
||||||
|
|
||||||
|
test('request invalid version/javaVersion combination', async () => {
|
||||||
|
for (var combination of [
|
||||||
|
['mandrel-23.1.1.0-Final', '17'],
|
||||||
|
['mandrel-23.0.2.1-Final', '21']
|
||||||
|
]) {
|
||||||
|
let error = new Error('unexpected')
|
||||||
|
try {
|
||||||
|
await mandrel.setUpMandrel(combination[0], combination[1])
|
||||||
|
} catch (err) {
|
||||||
|
if (!(err instanceof Error)) {
|
||||||
|
fail(`Unexpected non-Error: ${err}`)
|
||||||
|
}
|
||||||
|
error = err
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).not.toBeUndefined()
|
||||||
|
expect(error.message).toContain('Failed to download')
|
||||||
|
expect(error.message).toContain('Are you sure version')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
test('request invalid version', async () => {
|
||||||
|
for (var combination of [
|
||||||
|
['mandrel-23.1.1.0', '21'],
|
||||||
|
['mandrel-23.0.2.1', '17']
|
||||||
|
]) {
|
||||||
|
let error = new Error('unexpected')
|
||||||
|
try {
|
||||||
|
await mandrel.setUpMandrel(combination[0], combination[1])
|
||||||
|
} catch (err) {
|
||||||
|
if (!(err instanceof Error)) {
|
||||||
|
fail(`Unexpected non-Error: ${err}`)
|
||||||
|
}
|
||||||
|
error = err
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).not.toBeUndefined()
|
||||||
|
expect(error.message).toContain('Failed to download')
|
||||||
|
expect(error.message).toContain('Are you sure version')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test('find latest', async () => {
|
||||||
|
// Make sure the action can find the latest Mandrel release
|
||||||
|
const latestRelease = await getLatestRelease(mandrel.MANDREL_REPO)
|
||||||
|
const tag_name = latestRelease.tag_name
|
||||||
|
expect(tag_name).toContain(mandrel.MANDREL_TAG_PREFIX)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('get known latest Mandrel for specific JDK', async () => {
|
||||||
|
// Test deprecated versions that won't get updates anymore
|
||||||
|
for (var combination of [
|
||||||
|
['11', '22.2.0.0-Final'],
|
||||||
|
['20', '23.0.1.2-Final']
|
||||||
|
]) {
|
||||||
|
const latest = await mandrel.getLatestMandrelReleaseUrl(combination[0])
|
||||||
|
expect(latest).toContain(`mandrel-java${combination[0]}`)
|
||||||
|
expect(latest).toContain(combination[1])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test('get latest Mandrel for specific JDK', async () => {
|
||||||
|
// Test supported versions
|
||||||
|
for (var javaVersion of ['17', '21']) {
|
||||||
|
const latest = await mandrel.getLatestMandrelReleaseUrl(javaVersion)
|
||||||
|
expect(latest).toContain(`mandrel-java${javaVersion}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
34
__tests__/utils.test.ts
Normal file
34
__tests__/utils.test.ts
Normal file
@@ -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')
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -54,7 +54,7 @@ outputs:
|
|||||||
cache-hit:
|
cache-hit:
|
||||||
description: 'A boolean value to indicate an exact match was found for the primary key'
|
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/main/index.js'
|
main: 'dist/main/index.js'
|
||||||
post: 'dist/cleanup/index.js'
|
post: 'dist/cleanup/index.js'
|
||||||
post-if: 'success()'
|
post-if: 'success()'
|
||||||
|
|||||||
33151
dist/cleanup/index.js
generated
vendored
33151
dist/cleanup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
32832
dist/main/index.js
generated
vendored
32832
dist/main/index.js
generated
vendored
File diff suppressed because one or more lines are too long
9449
package-lock.json
generated
9449
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
56
package.json
56
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-graalvm",
|
"name": "setup-graalvm",
|
||||||
"version": "1.1.4",
|
"version": "1.1.7",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "GitHub Action for GraalVM",
|
"description": "GitHub Action for GraalVM",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
@@ -27,33 +27,37 @@
|
|||||||
"author": "GraalVM Community",
|
"author": "GraalVM Community",
|
||||||
"license": "UPL",
|
"license": "UPL",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.0.4",
|
"@actions/cache": "^3.2.3",
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^6.0.0",
|
||||||
"@actions/glob": "^0.3.0",
|
"@actions/glob": "^0.4.0",
|
||||||
"@actions/http-client": "^1.0.11",
|
"@actions/http-client": "^2.2.0",
|
||||||
"@actions/io": "^1.1.1",
|
"@actions/io": "^1.1.3",
|
||||||
"@actions/tool-cache": "^1.7.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"@octokit/core": "^3.5.1",
|
"@octokit/core": "^5.1.0",
|
||||||
"@octokit/types": "^6.34.0",
|
"@octokit/types": "^12.0.0",
|
||||||
"semver": "^7.5.2",
|
"semver": "^7.5.4",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^9.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.5.2",
|
"@types/jest": "^29.5.11",
|
||||||
"@types/node": "^18.15.11",
|
"@types/node": "^20.11.10",
|
||||||
"@types/semver": "^7.3.13",
|
"@types/semver": "^7.5.6",
|
||||||
"@types/uuid": "^8.3.4",
|
"@types/uuid": "^9.0.8",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
||||||
"@vercel/ncc": "^0.33.4",
|
"@typescript-eslint/parser": "^6.19.1",
|
||||||
"eslint": "^8.6.0",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint-plugin-github": "^4.3.5",
|
"eslint": "^8.56.0",
|
||||||
"eslint-plugin-jest": "^25.3.4",
|
"eslint-plugin-github": "^4.10.1",
|
||||||
"jest": "^29.5.0",
|
"eslint-plugin-jest": "^27.6.3",
|
||||||
|
"eslint-plugin-jsonc": "^2.13.0",
|
||||||
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
|
"jest": "^29.7.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"prettier": "2.5.1",
|
"prettier": "^3.2.4",
|
||||||
"ts-jest": "^29.1.0",
|
"prettier-eslint": "^16.3.0",
|
||||||
"typescript": "^5.0.4"
|
"ts-jest": "^29.1.2",
|
||||||
|
"typescript": "^5.3.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ export type LatestReleaseResponse =
|
|||||||
export type MatchingRefsResponse =
|
export type MatchingRefsResponse =
|
||||||
otypes.Endpoints['GET /repos/{owner}/{repo}/git/matching-refs/{ref}']['response']
|
otypes.Endpoints['GET /repos/{owner}/{repo}/git/matching-refs/{ref}']['response']
|
||||||
|
|
||||||
|
export type ReleasesResponse =
|
||||||
|
otypes.Endpoints['GET /repos/{owner}/{repo}/releases']['response']
|
||||||
|
|
||||||
function determineJDKArchitecture(): string {
|
function determineJDKArchitecture(): string {
|
||||||
switch (process.arch) {
|
switch (process.arch) {
|
||||||
case 'x64': {
|
case 'x64': {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
|
||||||
export async function checkForUpdates(
|
export function checkForUpdates(
|
||||||
graalVMVersion: string,
|
graalVMVersion: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
): Promise<void> {
|
): void {
|
||||||
if (javaVersion === '20') {
|
if (javaVersion === '20') {
|
||||||
core.notice(
|
core.notice(
|
||||||
'A new GraalVM release is available! Please consider upgrading to GraalVM for JDK 21: https://medium.com/p/ee01177dd12d'
|
'A new GraalVM release is available! Please consider upgrading to GraalVM for JDK 21: https://medium.com/graalvm/graalvm-for-jdk-21-is-here-ee01177dd12d'
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,8 +369,8 @@ function createReport(data: BuildOutput): string {
|
|||||||
details.total_bytes
|
details.total_bytes
|
||||||
)}</td>
|
)}</td>
|
||||||
<td align="left">${objectCount}${bytesToHuman(
|
<td align="left">${objectCount}${bytesToHuman(
|
||||||
details.image_heap.resources.bytes
|
details.image_heap.resources.bytes
|
||||||
)} for ${details.image_heap.resources.count.toLocaleString()} resources</td>
|
)} for ${details.image_heap.resources.count.toLocaleString()} resources</td>
|
||||||
</tr>${debugInfoLine}
|
</tr>${debugInfoLine}
|
||||||
<tr>
|
<tr>
|
||||||
<td align="left"><a href="${DOCS_BASE}#glossary-other-data" target="_blank">Other data</a></td>
|
<td align="left"><a href="${DOCS_BASE}#glossary-other-data" target="_blank">Other data</a></td>
|
||||||
@@ -404,16 +404,16 @@ function createReport(data: BuildOutput): string {
|
|||||||
<td align="left">${bytesToHuman(
|
<td align="left">${bytesToHuman(
|
||||||
resources.memory.peak_rss_bytes
|
resources.memory.peak_rss_bytes
|
||||||
)} (${toPercent(
|
)} (${toPercent(
|
||||||
resources.memory.peak_rss_bytes,
|
resources.memory.peak_rss_bytes,
|
||||||
resources.memory.system_total
|
resources.memory.system_total
|
||||||
)} of ${bytesToHuman(resources.memory.system_total)} system memory)</td>
|
)} of ${bytesToHuman(resources.memory.system_total)} system memory)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="left"><a href="${DOCS_BASE}#glossary-cpu-load" target="_blank">CPU load</a></td>
|
<td align="left"><a href="${DOCS_BASE}#glossary-cpu-load" target="_blank">CPU load</a></td>
|
||||||
<td align="left">${resources.cpu.load.toFixed(3)} (${toPercent(
|
<td align="left">${resources.cpu.load.toFixed(3)} (${toPercent(
|
||||||
resources.cpu.load,
|
resources.cpu.load,
|
||||||
resources.cpu.total_cores
|
resources.cpu.total_cores
|
||||||
)} of ${resources.cpu.total_cores} CPU cores)</td>
|
)} of ${resources.cpu.total_cores} CPU cores)</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import * as io from '@actions/io'
|
|||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as stream from 'stream'
|
import * as stream from 'stream'
|
||||||
import * as util from 'util'
|
import * as util from 'util'
|
||||||
import {IHeaders} from '@actions/http-client/interfaces'
|
import {IncomingHttpHeaders, OutgoingHttpHeaders} from 'http'
|
||||||
import {IncomingHttpHeaders} from 'http'
|
|
||||||
import {RetryHelper} from '@actions/tool-cache/lib/retry-helper'
|
import {RetryHelper} from '@actions/tool-cache/lib/retry-helper'
|
||||||
import {calculateSHA256} from './utils'
|
import {calculateSHA256} from './utils'
|
||||||
import {ok} from 'assert'
|
import {ok} from 'assert'
|
||||||
@@ -32,7 +31,7 @@ export async function downloadGraalVMEELegacy(
|
|||||||
version: string,
|
version: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const userAgent = `GraalVMGitHubAction/1.1.4 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`
|
const userAgent = `GraalVMGitHubAction/1.1.7 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`
|
||||||
const baseArtifact = await fetchArtifact(
|
const baseArtifact = await fetchArtifact(
|
||||||
userAgent,
|
userAgent,
|
||||||
'isBase:True',
|
'isBase:True',
|
||||||
@@ -132,7 +131,7 @@ class HTTPError extends Error {
|
|||||||
async function downloadTool(
|
async function downloadTool(
|
||||||
url: string,
|
url: string,
|
||||||
userAgent: string,
|
userAgent: string,
|
||||||
headers?: IHeaders
|
headers?: OutgoingHttpHeaders
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const dest = path.join(getTempDirectory(), uuidv4())
|
const dest = path.join(getTempDirectory(), uuidv4())
|
||||||
await io.mkdirP(path.dirname(dest))
|
await io.mkdirP(path.dirname(dest))
|
||||||
@@ -169,7 +168,7 @@ async function downloadToolAttempt(
|
|||||||
url: string,
|
url: string,
|
||||||
userAgent: string,
|
userAgent: string,
|
||||||
dest: string,
|
dest: string,
|
||||||
headers?: IHeaders
|
headers?: OutgoingHttpHeaders
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (fs.existsSync(dest)) {
|
if (fs.existsSync(dest)) {
|
||||||
throw new Error(`Destination file path ${dest} already exists`)
|
throw new Error(`Destination file path ${dest} already exists`)
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
import * as c from './constants'
|
import * as c from './constants'
|
||||||
|
import * as semver from 'semver'
|
||||||
import {
|
import {
|
||||||
downloadAndExtractJDK,
|
downloadAndExtractJDK,
|
||||||
downloadExtractAndCacheJDK,
|
downloadExtractAndCacheJDK,
|
||||||
|
getLatestPrerelease,
|
||||||
getLatestRelease,
|
getLatestRelease,
|
||||||
getMatchingTags,
|
getMatchingTags,
|
||||||
getTaggedRelease
|
getTaggedRelease,
|
||||||
|
toSemVer
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import {downloadGraalVMEELegacy} from './gds'
|
import {downloadGraalVMEELegacy} from './gds'
|
||||||
import {downloadTool} from '@actions/tool-cache'
|
import {downloadTool} from '@actions/tool-cache'
|
||||||
import {basename} from 'path'
|
import {basename} from 'path'
|
||||||
import {gt as semverGt, valid as semverValid} from 'semver'
|
|
||||||
|
|
||||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm'
|
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm'
|
||||||
const GRAALVM_CE_DL_BASE = `https://github.com/graalvm/${c.GRAALVM_RELEASES_REPO}/releases/download`
|
const GRAALVM_CE_DL_BASE = `https://github.com/graalvm/${c.GRAALVM_RELEASES_REPO}/releases/download`
|
||||||
|
const ORACLE_GRAALVM_REPO_EA_BUILDS = 'oracle-graalvm-dev-builds'
|
||||||
const GRAALVM_REPO_DEV_BUILDS = 'graalvm-ce-dev-builds'
|
const GRAALVM_REPO_DEV_BUILDS = 'graalvm-ce-dev-builds'
|
||||||
const GRAALVM_JDK_TAG_PREFIX = 'jdk-'
|
const GRAALVM_JDK_TAG_PREFIX = 'jdk-'
|
||||||
const GRAALVM_TAG_PREFIX = 'vm-'
|
const GRAALVM_TAG_PREFIX = 'vm-'
|
||||||
@@ -27,17 +30,54 @@ export async function setUpGraalVMJDK(
|
|||||||
}
|
}
|
||||||
const javaVersion = javaVersionOrDev
|
const javaVersion = javaVersionOrDev
|
||||||
const toolName = determineToolName(javaVersion, false)
|
const toolName = determineToolName(javaVersion, false)
|
||||||
|
let downloadName = toolName
|
||||||
let downloadUrl: string
|
let downloadUrl: string
|
||||||
if (javaVersion.includes('.')) {
|
if (javaVersion.includes('.')) {
|
||||||
const majorJavaVersion = javaVersion.split('.')[0]
|
if (semver.valid(javaVersion)) {
|
||||||
downloadUrl = `${GRAALVM_DL_BASE}/${majorJavaVersion}/archive/${toolName}${c.GRAALVM_FILE_EXTENSION}`
|
const majorJavaVersion = semver.major(javaVersion)
|
||||||
|
const minorJavaVersion = semver.minor(javaVersion)
|
||||||
|
const patchJavaVersion = semver.patch(javaVersion)
|
||||||
|
const isGARelease = minorJavaVersion === 0 && patchJavaVersion === 0
|
||||||
|
if (isGARelease) {
|
||||||
|
// For GA versions of JDKs, /archive/ does not use minor and patch version (see https://www.oracle.com/java/technologies/jdk-script-friendly-urls/)
|
||||||
|
downloadName = determineToolName(majorJavaVersion.toString(), false)
|
||||||
|
}
|
||||||
|
downloadUrl = `${GRAALVM_DL_BASE}/${majorJavaVersion}/archive/${downloadName}${c.GRAALVM_FILE_EXTENSION}`
|
||||||
|
} else {
|
||||||
|
throw new Error(
|
||||||
|
`java-version set to '${javaVersion}'. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if (javaVersion === '22-ea') {
|
||||||
|
downloadUrl = await findLatestEABuildDownloadUrl(javaVersion)
|
||||||
} else {
|
} else {
|
||||||
downloadUrl = `${GRAALVM_DL_BASE}/${javaVersion}/latest/${toolName}${c.GRAALVM_FILE_EXTENSION}`
|
downloadUrl = `${GRAALVM_DL_BASE}/${javaVersion}/latest/${downloadName}${c.GRAALVM_FILE_EXTENSION}`
|
||||||
}
|
}
|
||||||
const downloader = async () => downloadGraalVMJDK(downloadUrl, javaVersion)
|
const downloader = async () => downloadGraalVMJDK(downloadUrl, javaVersion)
|
||||||
return downloadExtractAndCacheJDK(downloader, toolName, javaVersion)
|
return downloadExtractAndCacheJDK(downloader, toolName, javaVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function findLatestEABuildDownloadUrl(
|
||||||
|
javaEaVersion: string
|
||||||
|
): Promise<string> {
|
||||||
|
const latestPrerelease = await getLatestPrerelease(
|
||||||
|
ORACLE_GRAALVM_REPO_EA_BUILDS
|
||||||
|
)
|
||||||
|
const expectedFileNamePrefix = 'graalvm-jdk-'
|
||||||
|
const expectedFileNameSuffix = `_${c.JDK_PLATFORM}-${c.JDK_ARCH}_bin${c.GRAALVM_FILE_EXTENSION}`
|
||||||
|
for (const asset of latestPrerelease.assets) {
|
||||||
|
if (
|
||||||
|
asset.name.startsWith(expectedFileNamePrefix) &&
|
||||||
|
asset.name.endsWith(expectedFileNameSuffix)
|
||||||
|
) {
|
||||||
|
return asset.browser_download_url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
`Could not find Oracle GraalVM build for ${javaEaVersion}. ${c.ERROR_HINT}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export async function setUpGraalVMJDKCE(
|
export async function setUpGraalVMJDKCE(
|
||||||
javaVersionOrDev: string
|
javaVersionOrDev: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
@@ -71,8 +111,8 @@ export async function findLatestGraalVMJDKCEJavaVersion(
|
|||||||
for (const matchingRef of matchingRefs) {
|
for (const matchingRef of matchingRefs) {
|
||||||
const currentVersion = matchingRef.ref.substring(versionNumberStartIndex)
|
const currentVersion = matchingRef.ref.substring(versionNumberStartIndex)
|
||||||
if (
|
if (
|
||||||
semverValid(currentVersion) &&
|
semver.valid(currentVersion) &&
|
||||||
semverGt(currentVersion, highestVersion)
|
semver.gt(currentVersion, highestVersion)
|
||||||
) {
|
) {
|
||||||
highestVersion = currentVersion
|
highestVersion = currentVersion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import * as c from './constants'
|
import * as c from './constants'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import * as semver from 'semver'
|
||||||
import {GRAALVM_PLATFORM} from './constants'
|
import {GRAALVM_PLATFORM} from './constants'
|
||||||
import {exec} from './utils'
|
import {exec} from './utils'
|
||||||
import {join} from 'path'
|
import {join} from 'path'
|
||||||
import {gte as semverGte, valid as semverValid} from 'semver'
|
|
||||||
|
|
||||||
const BASE_FLAGS = ['--non-interactive', 'install', '--no-progress']
|
const BASE_FLAGS = ['--non-interactive', 'install', '--no-progress']
|
||||||
const COMPONENT_TO_POST_INSTALL_HOOK = new Map<string, Map<string, string>>([
|
const COMPONENT_TO_POST_INSTALL_HOOK = new Map<string, Map<string, string>>([
|
||||||
@@ -34,10 +34,11 @@ export async function setUpGUComponents(
|
|||||||
if (components.length == 0) {
|
if (components.length == 0) {
|
||||||
return // nothing to do
|
return // nothing to do
|
||||||
}
|
}
|
||||||
|
const coercedJavaVersion = semver.coerce(javaVersion)
|
||||||
if (
|
if (
|
||||||
graalVMVersion === c.VERSION_DEV ||
|
graalVMVersion === c.VERSION_DEV ||
|
||||||
javaVersion === c.VERSION_DEV ||
|
javaVersion === c.VERSION_DEV ||
|
||||||
(semverValid(javaVersion) && semverGte(javaVersion, '21.0.0'))
|
(coercedJavaVersion != null && semver.gte(coercedJavaVersion, '21.0.0'))
|
||||||
) {
|
) {
|
||||||
if (components.length == 1 && components[0] === 'native-image') {
|
if (components.length == 1 && components[0] === 'native-image') {
|
||||||
core.warning(
|
core.warning(
|
||||||
|
|||||||
22
src/main.ts
22
src/main.ts
@@ -43,6 +43,13 @@ async function run(): Promise<void> {
|
|||||||
distribution.length > 0 || graalVMVersion.length == 0
|
distribution.length > 0 || graalVMVersion.length == 0
|
||||||
let graalVMHome
|
let graalVMHome
|
||||||
if (isGraalVMforJDK17OrLater) {
|
if (isGraalVMforJDK17OrLater) {
|
||||||
|
if (
|
||||||
|
enableCheckForUpdates &&
|
||||||
|
(distribution === c.DISTRIBUTION_GRAALVM ||
|
||||||
|
distribution === c.DISTRIBUTION_GRAALVM_COMMUNITY)
|
||||||
|
) {
|
||||||
|
checkForUpdates(graalVMVersion, javaVersion)
|
||||||
|
}
|
||||||
switch (distribution) {
|
switch (distribution) {
|
||||||
case c.DISTRIBUTION_GRAALVM:
|
case c.DISTRIBUTION_GRAALVM:
|
||||||
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||||
@@ -51,13 +58,7 @@ async function run(): Promise<void> {
|
|||||||
graalVMHome = await graalvm.setUpGraalVMJDKCE(javaVersion)
|
graalVMHome = await graalvm.setUpGraalVMJDKCE(javaVersion)
|
||||||
break
|
break
|
||||||
case c.DISTRIBUTION_MANDREL:
|
case c.DISTRIBUTION_MANDREL:
|
||||||
if (graalVMVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
graalVMHome = await setUpMandrel(graalVMVersion, javaVersion)
|
||||||
graalVMHome = await setUpMandrel(graalVMVersion, javaVersion)
|
|
||||||
} else {
|
|
||||||
throw new Error(
|
|
||||||
`Mandrel requires the 'version' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
case '':
|
case '':
|
||||||
if (javaVersion === c.VERSION_DEV) {
|
if (javaVersion === c.VERSION_DEV) {
|
||||||
@@ -76,11 +77,13 @@ async function run(): Promise<void> {
|
|||||||
throw new Error(`Unsupported distribution: ${distribution}`)
|
throw new Error(`Unsupported distribution: ${distribution}`)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
const coercedJavaVersion = semver.coerce(javaVersion)
|
||||||
switch (graalVMVersion) {
|
switch (graalVMVersion) {
|
||||||
case c.VERSION_LATEST:
|
case c.VERSION_LATEST:
|
||||||
if (
|
if (
|
||||||
javaVersion.startsWith('17') ||
|
javaVersion.startsWith('17') ||
|
||||||
(semver.valid(javaVersion) && semver.gte(javaVersion, '20.0.0'))
|
(coercedJavaVersion !== null &&
|
||||||
|
semver.gte(coercedJavaVersion, '20.0.0'))
|
||||||
) {
|
) {
|
||||||
core.info(
|
core.info(
|
||||||
`This build is using the new Oracle GraalVM. To select a specific distribution, use the 'distribution' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
`This build is using the new Oracle GraalVM. To select a specific distribution, use the 'distribution' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
||||||
@@ -99,7 +102,6 @@ async function run(): Promise<void> {
|
|||||||
'Downloading GraalVM EE dev builds is not supported'
|
'Downloading GraalVM EE dev builds is not supported'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const coercedJavaVersion = semver.coerce(javaVersion)
|
|
||||||
if (
|
if (
|
||||||
coercedJavaVersion !== null &&
|
coercedJavaVersion !== null &&
|
||||||
!semver.gte(coercedJavaVersion, '21.0.0')
|
!semver.gte(coercedJavaVersion, '21.0.0')
|
||||||
@@ -117,7 +119,7 @@ async function run(): Promise<void> {
|
|||||||
graalVMHome = await setUpMandrel(graalVMVersion, javaVersion)
|
graalVMHome = await setUpMandrel(graalVMVersion, javaVersion)
|
||||||
} else {
|
} else {
|
||||||
if (enableCheckForUpdates) {
|
if (enableCheckForUpdates) {
|
||||||
await checkForUpdates(graalVMVersion, javaVersion)
|
checkForUpdates(graalVMVersion, javaVersion)
|
||||||
}
|
}
|
||||||
graalVMHome = await graalvm.setUpGraalVMRelease(
|
graalVMHome = await graalvm.setUpGraalVMRelease(
|
||||||
gdsToken,
|
gdsToken,
|
||||||
|
|||||||
139
src/mandrel.ts
139
src/mandrel.ts
@@ -1,27 +1,33 @@
|
|||||||
import * as c from './constants'
|
import * as c from './constants'
|
||||||
|
import * as httpClient from '@actions/http-client'
|
||||||
import {downloadExtractAndCacheJDK, getLatestRelease} from './utils'
|
import {downloadExtractAndCacheJDK, getLatestRelease} from './utils'
|
||||||
import {downloadTool} from '@actions/tool-cache'
|
import {downloadTool} from '@actions/tool-cache'
|
||||||
|
import {basename} from 'path'
|
||||||
|
|
||||||
const MANDREL_REPO = 'mandrel'
|
export const MANDREL_REPO = 'mandrel'
|
||||||
const MANDREL_TAG_PREFIX = c.MANDREL_NAMESPACE
|
export const MANDREL_TAG_PREFIX = c.MANDREL_NAMESPACE
|
||||||
const MANDREL_DL_BASE = 'https://github.com/graalvm/mandrel/releases/download'
|
const MANDREL_DL_BASE = 'https://github.com/graalvm/mandrel/releases/download'
|
||||||
|
const DISCO_API_BASE = 'https://api.foojay.io/disco/v3.0/packages/jdks'
|
||||||
|
|
||||||
|
interface JdkData {
|
||||||
|
message: string
|
||||||
|
result: any
|
||||||
|
}
|
||||||
|
|
||||||
export async function setUpMandrel(
|
export async function setUpMandrel(
|
||||||
graalvmVersion: string,
|
mandrelVersion: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const mandrelVersion = graalvmVersion.substring(
|
const version = stripMandrelNamespace(mandrelVersion)
|
||||||
c.MANDREL_NAMESPACE.length,
|
|
||||||
graalvmVersion.length
|
|
||||||
)
|
|
||||||
|
|
||||||
let mandrelHome
|
let mandrelHome
|
||||||
switch (mandrelVersion) {
|
switch (version) {
|
||||||
|
case '':
|
||||||
|
// fetch latest if no version is specified
|
||||||
case 'latest':
|
case 'latest':
|
||||||
mandrelHome = await setUpMandrelLatest(javaVersion)
|
mandrelHome = await setUpMandrelLatest(javaVersion)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
mandrelHome = await setUpMandrelRelease(mandrelVersion, javaVersion)
|
mandrelHome = await setUpMandrelRelease(version, javaVersion)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,32 +35,110 @@ export async function setUpMandrel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function setUpMandrelLatest(javaVersion: string): Promise<string> {
|
async function setUpMandrelLatest(javaVersion: string): Promise<string> {
|
||||||
const latestRelease = await getLatestRelease(MANDREL_REPO)
|
const latest_release_url = await getLatestMandrelReleaseUrl(javaVersion)
|
||||||
const tag_name = latestRelease.tag_name
|
const version_tag = getTagFromURI(latest_release_url)
|
||||||
if (tag_name.startsWith(MANDREL_TAG_PREFIX)) {
|
const version = stripMandrelNamespace(version_tag)
|
||||||
const latestVersion = tag_name.substring(
|
|
||||||
MANDREL_TAG_PREFIX.length,
|
const toolName = determineToolName(javaVersion)
|
||||||
tag_name.length
|
return downloadExtractAndCacheJDK(
|
||||||
)
|
async () => downloadTool(latest_release_url),
|
||||||
return setUpMandrelRelease(latestVersion, javaVersion)
|
toolName,
|
||||||
|
version
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Download URIs are of the form https://github.com/graalvm/mandrel/releases/download/<tag>/<archive-name>
|
||||||
|
function getTagFromURI(uri: string): string {
|
||||||
|
const parts = uri.split('/')
|
||||||
|
try {
|
||||||
|
return parts[parts.length - 2]
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Failed to extract tag from URI ${uri}: ${error}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getLatestMandrelReleaseUrl(
|
||||||
|
javaVersion: string
|
||||||
|
): Promise<string> {
|
||||||
|
const url = `${DISCO_API_BASE}?jdk_version=${javaVersion}&distribution=${c.DISTRIBUTION_MANDREL}&architecture=${c.JDK_ARCH}&operating_system=${c.JDK_PLATFORM}&latest=per_distro`
|
||||||
|
const _http = new httpClient.HttpClient()
|
||||||
|
const response = await _http.getJson<JdkData>(url)
|
||||||
|
if (response.statusCode !== 200) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to fetch latest Mandrel release for Java ${javaVersion} from DISCO API: ${response.result}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const result = response.result?.result[0]
|
||||||
|
try {
|
||||||
|
const pkg_info_uri = result.links.pkg_info_uri
|
||||||
|
return await getLatestMandrelReleaseUrlHelper(
|
||||||
|
_http,
|
||||||
|
javaVersion,
|
||||||
|
pkg_info_uri
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to get latest Mandrel release for Java ${javaVersion} from DISCO API: ${error}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getLatestMandrelReleaseUrlHelper(
|
||||||
|
_http: httpClient.HttpClient,
|
||||||
|
java_version: string,
|
||||||
|
pkg_info_uri: string
|
||||||
|
): Promise<string> {
|
||||||
|
const response = await _http.getJson<JdkData>(pkg_info_uri)
|
||||||
|
if (response.statusCode !== 200) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to fetch package info of latest Mandrel release for Java ${java_version} from DISCO API: ${response.result}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const result = response.result?.result[0]
|
||||||
|
try {
|
||||||
|
return result.direct_download_uri
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to get download URI of latest Mandrel release for Java ${java_version} from DISCO API: ${error}`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
throw new Error(`Could not find latest Mandrel release: ${tag_name}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setUpMandrelRelease(
|
async function setUpMandrelRelease(
|
||||||
version: string,
|
version: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const identifier = determineMandrelIdentifier(version, javaVersion)
|
|
||||||
const downloadUrl = `${MANDREL_DL_BASE}/${MANDREL_TAG_PREFIX}${version}/${identifier}${c.GRAALVM_FILE_EXTENSION}`
|
|
||||||
const toolName = determineToolName(javaVersion)
|
const toolName = determineToolName(javaVersion)
|
||||||
return downloadExtractAndCacheJDK(
|
return downloadExtractAndCacheJDK(
|
||||||
async () => downloadTool(downloadUrl),
|
async () => downloadMandrelJDK(version, javaVersion),
|
||||||
toolName,
|
toolName,
|
||||||
version
|
version
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function downloadMandrelJDK(
|
||||||
|
version: string,
|
||||||
|
javaVersion: string
|
||||||
|
): Promise<string> {
|
||||||
|
const identifier = determineMandrelIdentifier(version, javaVersion)
|
||||||
|
const downloadUrl = `${MANDREL_DL_BASE}/${MANDREL_TAG_PREFIX}${version}/${identifier}${c.GRAALVM_FILE_EXTENSION}`
|
||||||
|
try {
|
||||||
|
return await downloadTool(downloadUrl)
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof Error && error.message.includes('404')) {
|
||||||
|
// Not Found
|
||||||
|
throw new Error(
|
||||||
|
`Failed to download ${basename(
|
||||||
|
downloadUrl
|
||||||
|
)}. Are you sure version: '${version}' and java-version: '${javaVersion}' are correct?`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
`Failed to download ${basename(downloadUrl)} (error: ${error}).`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function determineMandrelIdentifier(
|
function determineMandrelIdentifier(
|
||||||
version: string,
|
version: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
@@ -65,3 +149,14 @@ function determineMandrelIdentifier(
|
|||||||
function determineToolName(javaVersion: string): string {
|
function determineToolName(javaVersion: string): string {
|
||||||
return `mandrel-java${javaVersion}-${c.GRAALVM_PLATFORM}`
|
return `mandrel-java${javaVersion}-${c.GRAALVM_PLATFORM}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function stripMandrelNamespace(graalVMVersion: string) {
|
||||||
|
if (graalVMVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||||
|
return graalVMVersion.substring(
|
||||||
|
c.MANDREL_NAMESPACE.length,
|
||||||
|
graalVMVersion.length
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return graalVMVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
46
src/utils.ts
46
src/utils.ts
@@ -2,6 +2,7 @@ import * as c from './constants'
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import * as httpClient from '@actions/http-client'
|
import * as httpClient from '@actions/http-client'
|
||||||
|
import * as semver from 'semver'
|
||||||
import * as tc from '@actions/tool-cache'
|
import * as tc from '@actions/tool-cache'
|
||||||
import {ExecOptions, exec as e} from '@actions/exec'
|
import {ExecOptions, exec as e} from '@actions/exec'
|
||||||
import {readFileSync, readdirSync} from 'fs'
|
import {readFileSync, readdirSync} from 'fs'
|
||||||
@@ -33,6 +34,25 @@ export async function exec(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getLatestPrerelease(
|
||||||
|
repo: string
|
||||||
|
): Promise<c.ReleasesResponse['data'][number]> {
|
||||||
|
const githubToken = getGitHubToken()
|
||||||
|
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
||||||
|
const octokit = new GitHubDotCom(options)
|
||||||
|
const releases: c.ReleasesResponse['data'] = (
|
||||||
|
await octokit.request('GET /repos/{owner}/{repo}/releases', {
|
||||||
|
owner: c.GRAALVM_GH_USER,
|
||||||
|
repo
|
||||||
|
})
|
||||||
|
).data
|
||||||
|
const firstPrerelease = releases.find(r => r.prerelease)
|
||||||
|
if (!firstPrerelease) {
|
||||||
|
throw new Error(`Unable to find latest prerelease in ${repo}`)
|
||||||
|
}
|
||||||
|
return firstPrerelease
|
||||||
|
}
|
||||||
|
|
||||||
export async function getLatestRelease(
|
export async function getLatestRelease(
|
||||||
repo: string
|
repo: string
|
||||||
): Promise<c.LatestReleaseResponse['data']> {
|
): Promise<c.LatestReleaseResponse['data']> {
|
||||||
@@ -135,17 +155,25 @@ function findJavaHomeInSubfolder(searchPath: string): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This helper turns GraalVM version numbers (e.g., `22.0.0.2`) into valid
|
|
||||||
* semver.org versions (e.g., `22.0.0-2`), which is needed because
|
|
||||||
* @actions/tool-cache uses `semver` to validate versions.
|
|
||||||
*/
|
|
||||||
export function toSemVer(version: string): string {
|
export function toSemVer(version: string): string {
|
||||||
const parts = version.split('.')
|
const parts = version.split('.')
|
||||||
const major = parts[0]
|
if (parts.length === 4) {
|
||||||
const minor = parts.length > 1 ? parts[1] : '0'
|
/**
|
||||||
const patch = parts.length > 2 ? parts.slice(2).join('-') : '0'
|
* Turn legacy GraalVM version numbers (e.g., `22.0.0.2`) into valid
|
||||||
return `${major}.${minor}.${patch}`
|
* semver.org versions (e.g., `22.0.0-2`).
|
||||||
|
*/
|
||||||
|
return `${parts[0]}.${parts[1]}.${parts.slice(2).join('-')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const versionParts = version.split('-', 2)
|
||||||
|
const suffix = versionParts.length === 2 ? '-' + versionParts[1] : ''
|
||||||
|
const validVersion = semver.valid(semver.coerce(versionParts[0]) + suffix)
|
||||||
|
if (!validVersion) {
|
||||||
|
throw new Error(
|
||||||
|
`Unable to convert '${version}' to semantic version. ${c.ERROR_HINT}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return validVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isPREvent(): boolean {
|
export function isPREvent(): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user