Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c3001733f | ||
|
|
bd9c75cac6 | ||
|
|
0fee1abbca | ||
|
|
ca91f399b9 | ||
|
|
2e2e6f1823 | ||
|
|
4a6d7d10cf | ||
|
|
10650533bf | ||
|
|
d72e3dbf5f | ||
|
|
22551b2bec | ||
|
|
bf3e45bce6 | ||
|
|
1588b03f82 | ||
|
|
6df9f698c6 | ||
|
|
2408275e34 | ||
|
|
a638430bc0 | ||
|
|
3bd233e767 | ||
|
|
c99915cc1a | ||
|
|
a0f131ece5 |
6
.github/workflows/check-dist.yml
vendored
6
.github/workflows/check-dist.yml
vendored
@@ -26,10 +26,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
- name: Set Node.js 20.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16.x
|
||||
node-version: 20.x
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
|
||||
13
.github/workflows/test.yml
vendored
13
.github/workflows/test.yml
vendored
@@ -27,9 +27,20 @@ jobs:
|
||||
matrix:
|
||||
java-version: ['21', '17', '20', 'dev']
|
||||
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:
|
||||
- java-version: 'latest-ea'
|
||||
distribution: 'graalvm'
|
||||
os: ubuntu-latest
|
||||
- java-version: '22-ea'
|
||||
distribution: 'graalvm'
|
||||
os: ubuntu-latest
|
||||
- java-version: '21'
|
||||
distribution: ''
|
||||
os: ubuntu-latest
|
||||
|
||||
88
README.md
88
README.md
@@ -5,7 +5,7 @@ This GitHub action sets up [Oracle GraalVM][graalvm-medium], GraalVM [Community
|
||||
|
||||
This action:
|
||||
|
||||
- supports Oracle GraalVM [releases][graalvm-dl], GraalVM Community Edition (CE) [releases], [dev builds][dev-builds], GraalVM Enterprise Edition (EE) [releases][graalvm-ee] (set [`gds-token`](#options)) 22.1.0 and later, and [Mandrel][mandrel] (see [Options](#options))
|
||||
- supports Oracle GraalVM [releases][graalvm-dl], [EA builds][ea-builds], GraalVM Community Edition (CE) [releases], [dev builds][dev-builds], GraalVM Enterprise Edition (EE) [releases][graalvm-ee] (set [`gds-token`](#options)) 22.1.0 and later, and [Mandrel][mandrel] (see [Options](#options))
|
||||
- exports a `$GRAALVM_HOME` environment variable
|
||||
- adds `$GRAALVM_HOME/bin` to the `$PATH` environment variable<br>(Native Image, Truffle languages, and tools can be invoked directly)
|
||||
- sets `$JAVA_HOME` to `$GRAALVM_HOME` by default<br>(can be disabled via `set-java-home: 'false'`, see [Options](#options))
|
||||
@@ -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
|
||||
@@ -57,8 +29,8 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'graalvm' # See 'Options' for all available distributions
|
||||
java-version: '21' # See 'Options' section below for all supported versions
|
||||
distribution: 'graalvm' # See 'Options' section below for all available distributions
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Example step
|
||||
run: |
|
||||
@@ -108,6 +80,26 @@ jobs:
|
||||
path: helloworld*
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary><h4>Template for Oracle GraalVM Early Access (EA) builds</h4></summary>
|
||||
|
||||
```yml
|
||||
name: Oracle GraalVM Early Access build
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '22-ea' # or 'latest-ea' for the latest Java version available
|
||||
distribution: 'graalvm'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><h4>Template for older GraalVM releases</h4></summary>
|
||||
|
||||
@@ -162,12 +154,41 @@ 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 |
|
||||
|-----------------|:--------:|-------------|
|
||||
| `java-version`<br>*(required)* | n/a | `'21'` or `'17.0.7'` for a specific Java version, `'dev'` for a dev build with the latest Java version available.<br>(`'8'`, `'11'`, `'16'`, `'19'` are supported for older GraalVM releases.) |
|
||||
| `distribution` | `''` | GraalVM distribution (`graalvm` for Oracle GraalVM, `graalvm-community` for GraalVM Community Edition, `mandrel` for Mandrel). |
|
||||
| `java-version`<br>*(required)* | n/a | Java version <ul><li>major versions: `'21'`, `'17'`, `'11'`, `'8'`</li><li>specific versions: `'21.0.2'`, `'17.0.7'`</li><li>early access (EA) builds: `'22-ea'` *(requires `distribution: 'graalvm'`)*</li><li>latest EA build: `'latest-ea'` *(requires `distribution: 'graalvm'`)*</li><li>dev builds: `'dev'`</li></ul> |
|
||||
| `distribution` | `'graalvm'` | GraalVM distribution <ul><li>Oracle GraalVM: `'graalvm'`</li><li>GraalVM Community Edition: `'graalvm-community'`</li><li>Mandrel: `'mandrel'`</li></ul> |
|
||||
| `github-token` | `'${{ github.token }}'` | Token for communication with the GitHub API. Please set this to `${{ secrets.GITHUB_TOKEN }}` (see [templates](#templates)) to allow the action to authenticate with the GitHub API, which helps reduce rate-limiting issues. |
|
||||
| `set-java-home` | `'true'` | If set to `'true'`, instructs the action to set `$JAVA_HOME` to the path of the GraalVM installation. Overrides any previous action or command that sets `$JAVA_HOME`. |
|
||||
| `cache` | `''` | Name of the build platform to cache dependencies. Turned off by default (`''`). It can also be `'maven'`, `'gradle'`, or `'sbt'` and works the same way as described in [actions/setup-java][setup-java-caching]. |
|
||||
@@ -191,6 +212,7 @@ Only pull requests from committers that can be verified as having signed the OCA
|
||||
|
||||
[dev-build]: https://github.com/graalvm/graalvm-ce-dev-builds/releases/latest
|
||||
[dev-builds]: https://github.com/graalvm/graalvm-ce-dev-builds
|
||||
[ea-builds]: https://github.com/graalvm/oracle-graalvm-ea-builds
|
||||
[gha-annotations]: https://github.com/actions/toolkit/tree/main/packages/core#annotations
|
||||
[gha-permissions]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
|
||||
[gha-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository
|
||||
|
||||
@@ -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`
|
||||
@@ -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`
|
||||
@@ -135,17 +135,17 @@ 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 () => {
|
||||
@@ -153,13 +153,13 @@ describe('dependency cache', () => {
|
||||
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`
|
||||
@@ -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')
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -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'
|
||||
)
|
||||
})
|
||||
@@ -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:.*/)
|
||||
)
|
||||
})
|
||||
@@ -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:.*/)
|
||||
)
|
||||
})
|
||||
@@ -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:.*/)
|
||||
)
|
||||
})
|
||||
@@ -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:.*/)
|
||||
)
|
||||
})
|
||||
@@ -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:.*/)
|
||||
)
|
||||
})
|
||||
@@ -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:.*/)
|
||||
)
|
||||
})
|
||||
|
||||
@@ -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>>
|
||||
@@ -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 () => {
|
||||
@@ -74,7 +73,7 @@ describe('cleanup', () => {
|
||||
return name === 'cache' ? 'gradle' : ''
|
||||
})
|
||||
await cleanup()
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -2,7 +2,11 @@ import * as path from 'path'
|
||||
import * as graalvm from '../src/graalvm'
|
||||
import {expect, test} from '@jest/globals'
|
||||
import {getTaggedRelease} from '../src/utils'
|
||||
import {findGraalVMVersion, findHighestJavaVersion} from '../src/graalvm'
|
||||
import {
|
||||
findGraalVMVersion,
|
||||
findHighestJavaVersion,
|
||||
findLatestEABuildDownloadUrl
|
||||
} from '../src/graalvm'
|
||||
import {GRAALVM_RELEASES_REPO} from '../src/constants'
|
||||
|
||||
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
|
||||
@@ -79,3 +83,21 @@ test('find version/javaVersion', async () => {
|
||||
}
|
||||
expect(error.message).toContain('Could not find highest Java version.')
|
||||
})
|
||||
|
||||
test('find version/javaVersion', async () => {
|
||||
let url22EA = await findLatestEABuildDownloadUrl('22-ea')
|
||||
expect(url22EA).not.toBe('')
|
||||
let urlLatestEA = await findLatestEABuildDownloadUrl('latest-ea')
|
||||
expect(urlLatestEA).not.toBe('')
|
||||
|
||||
let error = new Error('unexpected')
|
||||
try {
|
||||
await findLatestEABuildDownloadUrl('8-ea')
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
fail(`Unexpected non-Error: ${err}`)
|
||||
}
|
||||
error = err
|
||||
}
|
||||
expect(error.message).toContain('Unable to resolve download URL for')
|
||||
})
|
||||
|
||||
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')
|
||||
}
|
||||
})
|
||||
43
dist/cleanup/index.js
generated
vendored
43
dist/cleanup/index.js
generated
vendored
@@ -92172,7 +92172,7 @@ else {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.ERROR_HINT = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = void 0;
|
||||
exports.ERROR_HINT = exports.ERROR_REQUEST = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = void 0;
|
||||
exports.INPUT_VERSION = 'version';
|
||||
exports.INPUT_GDS_TOKEN = 'gds-token';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
@@ -92186,6 +92186,7 @@ exports.INPUT_NI_MUSL = 'native-image-musl';
|
||||
exports.IS_LINUX = process.platform === 'linux';
|
||||
exports.IS_MACOS = process.platform === 'darwin';
|
||||
exports.IS_WINDOWS = process.platform === 'win32';
|
||||
exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS ? '.exe' : '';
|
||||
exports.DISTRIBUTION_GRAALVM = 'graalvm';
|
||||
exports.DISTRIBUTION_GRAALVM_COMMUNITY = 'graalvm-community';
|
||||
exports.DISTRIBUTION_MANDREL = 'mandrel';
|
||||
@@ -92204,6 +92205,7 @@ exports.GDS_BASE = 'https://gds.oracle.com/api/20220101';
|
||||
exports.GDS_GRAALVM_PRODUCT_ID = 'D53FAE8052773FFAE0530F15000AA6C6';
|
||||
exports.ENV_GITHUB_EVENT_NAME = 'GITHUB_EVENT_NAME';
|
||||
exports.EVENT_NAME_PULL_REQUEST = 'pull_request';
|
||||
exports.ERROR_REQUEST = 'Please file an issue at: https://github.com/graalvm/setup-graalvm/issues.';
|
||||
exports.ERROR_HINT = 'If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.';
|
||||
function determineJDKArchitecture() {
|
||||
switch (process.arch) {
|
||||
@@ -92864,11 +92866,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getMatchingTags = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0;
|
||||
exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getMatchingTags = exports.getTaggedRelease = exports.getContents = exports.getLatestRelease = exports.exec = void 0;
|
||||
const c = __importStar(__nccwpck_require__(9042));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
const httpClient = __importStar(__nccwpck_require__(6255));
|
||||
const semver = __importStar(__nccwpck_require__(1383));
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
const exec_1 = __nccwpck_require__(1514);
|
||||
const fs_1 = __nccwpck_require__(7147);
|
||||
@@ -92906,6 +92909,19 @@ function getLatestRelease(repo) {
|
||||
});
|
||||
}
|
||||
exports.getLatestRelease = getLatestRelease;
|
||||
function getContents(repo, path) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
return (yield octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo,
|
||||
path
|
||||
})).data;
|
||||
});
|
||||
}
|
||||
exports.getContents = getContents;
|
||||
function getTaggedRelease(repo, tag) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const githubToken = getGitHubToken();
|
||||
@@ -92982,17 +92998,22 @@ function findJavaHomeInSubfolder(searchPath) {
|
||||
throw new Error(`Unexpected amount of directory items found: ${baseContents.length}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function toSemVer(version) {
|
||||
const parts = version.split('.');
|
||||
const major = parts[0];
|
||||
const minor = parts.length > 1 ? parts[1] : '0';
|
||||
const patch = parts.length > 2 ? parts.slice(2).join('-') : '0';
|
||||
return `${major}.${minor}.${patch}`;
|
||||
if (parts.length === 4) {
|
||||
/**
|
||||
* Turn legacy GraalVM version numbers (e.g., `22.0.0.2`) into valid
|
||||
* 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;
|
||||
}
|
||||
exports.toSemVer = toSemVer;
|
||||
function isPREvent() {
|
||||
|
||||
121
dist/main/index.js
generated
vendored
121
dist/main/index.js
generated
vendored
@@ -92738,7 +92738,7 @@ function wrappy (fn, cb) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.ERROR_HINT = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = void 0;
|
||||
exports.ERROR_HINT = exports.ERROR_REQUEST = exports.EVENT_NAME_PULL_REQUEST = exports.ENV_GITHUB_EVENT_NAME = exports.GDS_GRAALVM_PRODUCT_ID = exports.GDS_BASE = exports.MANDREL_NAMESPACE = exports.GRAALVM_RELEASES_REPO = exports.GRAALVM_PLATFORM = exports.GRAALVM_GH_USER = exports.GRAALVM_FILE_EXTENSION = exports.GRAALVM_ARCH = exports.JDK_HOME_SUFFIX = exports.JDK_PLATFORM = exports.JDK_ARCH = exports.VERSION_LATEST = exports.VERSION_DEV = exports.DISTRIBUTION_MANDREL = exports.DISTRIBUTION_GRAALVM_COMMUNITY = exports.DISTRIBUTION_GRAALVM = exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS = exports.IS_MACOS = exports.IS_LINUX = exports.INPUT_NI_MUSL = exports.INPUT_CHECK_FOR_UPDATES = exports.INPUT_CACHE = exports.INPUT_SET_JAVA_HOME = exports.INPUT_GITHUB_TOKEN = exports.INPUT_COMPONENTS = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_VERSION = exports.INPUT_GDS_TOKEN = exports.INPUT_VERSION = void 0;
|
||||
exports.INPUT_VERSION = 'version';
|
||||
exports.INPUT_GDS_TOKEN = 'gds-token';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
@@ -92752,6 +92752,7 @@ exports.INPUT_NI_MUSL = 'native-image-musl';
|
||||
exports.IS_LINUX = process.platform === 'linux';
|
||||
exports.IS_MACOS = process.platform === 'darwin';
|
||||
exports.IS_WINDOWS = process.platform === 'win32';
|
||||
exports.EXECUTABLE_SUFFIX = exports.IS_WINDOWS ? '.exe' : '';
|
||||
exports.DISTRIBUTION_GRAALVM = 'graalvm';
|
||||
exports.DISTRIBUTION_GRAALVM_COMMUNITY = 'graalvm-community';
|
||||
exports.DISTRIBUTION_MANDREL = 'mandrel';
|
||||
@@ -92770,6 +92771,7 @@ exports.GDS_BASE = 'https://gds.oracle.com/api/20220101';
|
||||
exports.GDS_GRAALVM_PRODUCT_ID = 'D53FAE8052773FFAE0530F15000AA6C6';
|
||||
exports.ENV_GITHUB_EVENT_NAME = 'GITHUB_EVENT_NAME';
|
||||
exports.EVENT_NAME_PULL_REQUEST = 'pull_request';
|
||||
exports.ERROR_REQUEST = 'Please file an issue at: https://github.com/graalvm/setup-graalvm/issues.';
|
||||
exports.ERROR_HINT = 'If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.';
|
||||
function determineJDKArchitecture() {
|
||||
switch (process.arch) {
|
||||
@@ -93659,7 +93661,7 @@ const assert_1 = __nccwpck_require__(9491);
|
||||
const uuid_1 = __nccwpck_require__(5840);
|
||||
function downloadGraalVMEELegacy(gdsToken, version, javaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const userAgent = `GraalVMGitHubAction/1.1.6 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`;
|
||||
const userAgent = `GraalVMGitHubAction/1.1.8 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`;
|
||||
const baseArtifact = yield fetchArtifact(userAgent, 'isBase:True', version, javaVersion);
|
||||
return downloadArtifact(gdsToken, userAgent, baseArtifact);
|
||||
});
|
||||
@@ -93841,7 +93843,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.setUpGraalVMRelease = exports.findGraalVMVersion = exports.setUpGraalVMLatest_22_X = exports.findHighestJavaVersion = exports.setUpGraalVMJDKDevBuild = exports.findLatestGraalVMJDKCEJavaVersion = exports.setUpGraalVMJDKCE = exports.setUpGraalVMJDK = void 0;
|
||||
exports.setUpGraalVMRelease = exports.findGraalVMVersion = exports.setUpGraalVMLatest_22_X = exports.findHighestJavaVersion = exports.setUpGraalVMJDKDevBuild = exports.findLatestGraalVMJDKCEJavaVersion = exports.setUpGraalVMJDKCE = exports.findLatestEABuildDownloadUrl = exports.setUpGraalVMJDK = void 0;
|
||||
const c = __importStar(__nccwpck_require__(9042));
|
||||
const semver = __importStar(__nccwpck_require__(1383));
|
||||
const utils_1 = __nccwpck_require__(1314);
|
||||
@@ -93850,6 +93852,8 @@ const tool_cache_1 = __nccwpck_require__(7784);
|
||||
const path_1 = __nccwpck_require__(1017);
|
||||
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 ORACLE_GRAALVM_REPO_EA_BUILDS = 'oracle-graalvm-ea-builds';
|
||||
const ORACLE_GRAALVM_REPO_EA_BUILDS_LATEST_SYMBOL = 'latest-ea';
|
||||
const GRAALVM_REPO_DEV_BUILDS = 'graalvm-ce-dev-builds';
|
||||
const GRAALVM_JDK_TAG_PREFIX = 'jdk-';
|
||||
const GRAALVM_TAG_PREFIX = 'vm-';
|
||||
@@ -93859,16 +93863,25 @@ function setUpGraalVMJDK(javaVersionOrDev) {
|
||||
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||
return setUpGraalVMJDKDevBuild();
|
||||
}
|
||||
const javaVersion = javaVersionOrDev;
|
||||
let toolName = determineToolName(javaVersion, false);
|
||||
let javaVersion = javaVersionOrDev;
|
||||
const toolName = determineToolName(javaVersion, false);
|
||||
let downloadName = toolName;
|
||||
let downloadUrl;
|
||||
if (javaVersion.includes('.')) {
|
||||
if (javaVersion.endsWith('-ea')) {
|
||||
downloadUrl = yield findLatestEABuildDownloadUrl(javaVersion);
|
||||
const filename = (0, path_1.basename)(downloadUrl);
|
||||
const resolvedVersion = semver.valid(semver.coerce(filename));
|
||||
if (!resolvedVersion) {
|
||||
throw new Error(`Unable to determine resolved version based on '${filename}'. ${c.ERROR_REQUEST}`);
|
||||
}
|
||||
javaVersion = resolvedVersion;
|
||||
}
|
||||
else if (javaVersion.includes('.')) {
|
||||
if (semver.valid(javaVersion)) {
|
||||
const majorJavaVersion = semver.major(javaVersion);
|
||||
const minorJavaVersion = semver.minor(javaVersion);
|
||||
const patchJavaVersion = semver.patch(javaVersion);
|
||||
const isGARelease = minorJavaVersion === 0 && patchJavaVersion === 0;
|
||||
let downloadName = toolName;
|
||||
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);
|
||||
@@ -93880,13 +93893,47 @@ function setUpGraalVMJDK(javaVersionOrDev) {
|
||||
}
|
||||
}
|
||||
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 = () => __awaiter(this, void 0, void 0, function* () { return downloadGraalVMJDK(downloadUrl, javaVersion); });
|
||||
return (0, utils_1.downloadExtractAndCacheJDK)(downloader, toolName, javaVersion);
|
||||
});
|
||||
}
|
||||
exports.setUpGraalVMJDK = setUpGraalVMJDK;
|
||||
function findLatestEABuildDownloadUrl(javaEaVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const filePath = `versions/${javaEaVersion}.json`;
|
||||
let response;
|
||||
try {
|
||||
response = yield (0, utils_1.getContents)(ORACLE_GRAALVM_REPO_EA_BUILDS, filePath);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Unable to resolve download URL for '${javaEaVersion}'. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`);
|
||||
}
|
||||
if (Array.isArray(response) ||
|
||||
response.type !== 'file' ||
|
||||
!response.content) {
|
||||
throw new Error(`Unexpected response when resolving download URL for '${javaEaVersion}'. ${c.ERROR_REQUEST}`);
|
||||
}
|
||||
const versionData = JSON.parse(Buffer.from(response.content, 'base64').toString('utf-8'));
|
||||
let latestVersion;
|
||||
if (javaEaVersion === ORACLE_GRAALVM_REPO_EA_BUILDS_LATEST_SYMBOL) {
|
||||
latestVersion = versionData;
|
||||
}
|
||||
else {
|
||||
latestVersion = versionData.find(v => v.latest);
|
||||
if (!latestVersion) {
|
||||
throw new Error(`Unable to find latest version for '${javaEaVersion}'. ${c.ERROR_REQUEST}`);
|
||||
}
|
||||
}
|
||||
const file = latestVersion.files.find(f => f.arch === c.JDK_ARCH && f.platform === c.GRAALVM_PLATFORM);
|
||||
if (!file || !file.filename.startsWith('graalvm-jdk-')) {
|
||||
throw new Error(`Unable to find file metadata for '${javaEaVersion}'. ${c.ERROR_REQUEST}`);
|
||||
}
|
||||
return `${latestVersion.download_base_url}${file.filename}`;
|
||||
});
|
||||
}
|
||||
exports.findLatestEABuildDownloadUrl = findLatestEABuildDownloadUrl;
|
||||
function setUpGraalVMJDKCE(javaVersionOrDev) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||
@@ -94207,6 +94254,7 @@ const check_for_updates_1 = __nccwpck_require__(6780);
|
||||
const musl_1 = __nccwpck_require__(316);
|
||||
const msvc_1 = __nccwpck_require__(1165);
|
||||
const reports_1 = __nccwpck_require__(2046);
|
||||
const exec_1 = __nccwpck_require__(1514);
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
@@ -94223,7 +94271,7 @@ function run() {
|
||||
const enableCheckForUpdates = core.getInput(c.INPUT_CHECK_FOR_UPDATES) === 'true';
|
||||
const enableNativeImageMusl = core.getInput(c.INPUT_NI_MUSL) === 'true';
|
||||
if (c.IS_WINDOWS) {
|
||||
(0, msvc_1.setUpWindowsEnvironment)(graalVMVersion);
|
||||
(0, msvc_1.setUpWindowsEnvironment)(javaVersion, graalVMVersion);
|
||||
}
|
||||
yield (0, dependencies_1.setUpDependencies)(components);
|
||||
if (enableNativeImageMusl) {
|
||||
@@ -94314,6 +94362,11 @@ function run() {
|
||||
yield (0, cache_2.restore)(cache);
|
||||
}
|
||||
(0, reports_1.setUpNativeImageBuildReports)(isGraalVMforJDK17OrLater, graalVMVersion);
|
||||
core.startGroup(`Successfully set up '${(0, path_1.basename)(graalVMHome)}'`);
|
||||
yield (0, exec_1.exec)((0, path_1.join)(graalVMHome, 'bin', `java${c.EXECUTABLE_SUFFIX}`), [
|
||||
'--version'
|
||||
]);
|
||||
core.endGroup();
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error)
|
||||
@@ -94519,6 +94572,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.setUpWindowsEnvironment = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const semver = __importStar(__nccwpck_require__(1383));
|
||||
const child_process_1 = __nccwpck_require__(2081);
|
||||
const fs_1 = __nccwpck_require__(7147);
|
||||
const constants_1 = __nccwpck_require__(9042);
|
||||
@@ -94542,10 +94596,16 @@ function findVcvarsallPath() {
|
||||
}
|
||||
throw new Error('Failed to find vcvarsall.bat');
|
||||
}
|
||||
function setUpWindowsEnvironment(graalVMVersion) {
|
||||
if (graalVMVersion === constants_1.VERSION_DEV) {
|
||||
function setUpWindowsEnvironment(javaVersion, graalVMVersion) {
|
||||
if (javaVersion === javaVersion || graalVMVersion === constants_1.VERSION_DEV) {
|
||||
return; // no longer required in dev builds
|
||||
}
|
||||
const javaVersionSemVer = semver.coerce(javaVersion);
|
||||
if (javaVersionSemVer &&
|
||||
semver.valid(javaVersionSemVer) &&
|
||||
semver.gte(javaVersionSemVer, '18.0.0')) {
|
||||
return; // no longer required in GraalVM for JDK 17 and later. JDK 17 builds from 22.3 still need this, so skip 17.X.X
|
||||
}
|
||||
core.startGroup('Updating Windows environment...');
|
||||
const vcvarsallPath = findVcvarsallPath();
|
||||
core.debug(`Calling "${vcvarsallPath}"...`);
|
||||
@@ -94621,11 +94681,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getMatchingTags = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0;
|
||||
exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getMatchingTags = exports.getTaggedRelease = exports.getContents = exports.getLatestRelease = exports.exec = void 0;
|
||||
const c = __importStar(__nccwpck_require__(9042));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
const httpClient = __importStar(__nccwpck_require__(6255));
|
||||
const semver = __importStar(__nccwpck_require__(1383));
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
const exec_1 = __nccwpck_require__(1514);
|
||||
const fs_1 = __nccwpck_require__(7147);
|
||||
@@ -94663,6 +94724,19 @@ function getLatestRelease(repo) {
|
||||
});
|
||||
}
|
||||
exports.getLatestRelease = getLatestRelease;
|
||||
function getContents(repo, path) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const githubToken = getGitHubToken();
|
||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
||||
const octokit = new GitHubDotCom(options);
|
||||
return (yield octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo,
|
||||
path
|
||||
})).data;
|
||||
});
|
||||
}
|
||||
exports.getContents = getContents;
|
||||
function getTaggedRelease(repo, tag) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const githubToken = getGitHubToken();
|
||||
@@ -94739,17 +94813,22 @@ function findJavaHomeInSubfolder(searchPath) {
|
||||
throw new Error(`Unexpected amount of directory items found: ${baseContents.length}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function toSemVer(version) {
|
||||
const parts = version.split('.');
|
||||
const major = parts[0];
|
||||
const minor = parts.length > 1 ? parts[1] : '0';
|
||||
const patch = parts.length > 2 ? parts.slice(2).join('-') : '0';
|
||||
return `${major}.${minor}.${patch}`;
|
||||
if (parts.length === 4) {
|
||||
/**
|
||||
* Turn legacy GraalVM version numbers (e.g., `22.0.0.2`) into valid
|
||||
* 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;
|
||||
}
|
||||
exports.toSemVer = toSemVer;
|
||||
function isPREvent() {
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "setup-graalvm",
|
||||
"version": "1.1.6",
|
||||
"version": "1.1.8",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "setup-graalvm",
|
||||
"version": "1.1.6",
|
||||
"version": "1.1.8",
|
||||
"license": "UPL",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^3.2.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-graalvm",
|
||||
"version": "1.1.6",
|
||||
"version": "1.1.8",
|
||||
"private": true,
|
||||
"description": "GitHub Action for GraalVM",
|
||||
"main": "lib/main.js",
|
||||
|
||||
@@ -15,6 +15,8 @@ export const IS_LINUX = process.platform === 'linux'
|
||||
export const IS_MACOS = process.platform === 'darwin'
|
||||
export const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
export const EXECUTABLE_SUFFIX = IS_WINDOWS ? '.exe' : ''
|
||||
|
||||
export const DISTRIBUTION_GRAALVM = 'graalvm'
|
||||
export const DISTRIBUTION_GRAALVM_COMMUNITY = 'graalvm-community'
|
||||
export const DISTRIBUTION_MANDREL = 'mandrel'
|
||||
@@ -40,6 +42,9 @@ export const GDS_GRAALVM_PRODUCT_ID = 'D53FAE8052773FFAE0530F15000AA6C6'
|
||||
export const ENV_GITHUB_EVENT_NAME = 'GITHUB_EVENT_NAME'
|
||||
export const EVENT_NAME_PULL_REQUEST = 'pull_request'
|
||||
|
||||
export const ERROR_REQUEST =
|
||||
'Please file an issue at: https://github.com/graalvm/setup-graalvm/issues.'
|
||||
|
||||
export const ERROR_HINT =
|
||||
'If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.'
|
||||
|
||||
@@ -49,6 +54,25 @@ export type LatestReleaseResponse =
|
||||
export type MatchingRefsResponse =
|
||||
otypes.Endpoints['GET /repos/{owner}/{repo}/git/matching-refs/{ref}']['response']
|
||||
|
||||
export type ReleasesResponse =
|
||||
otypes.Endpoints['GET /repos/{owner}/{repo}/releases']['response']
|
||||
|
||||
export type ContentsResponse =
|
||||
otypes.Endpoints['GET /repos/{owner}/{repo}/contents/{path}']['response']
|
||||
|
||||
export interface OracleGraalVMEAFile {
|
||||
filename: string
|
||||
arch: 'aarch64' | 'x64'
|
||||
platform: 'darwin' | 'linux' | 'windows'
|
||||
}
|
||||
|
||||
export interface OracleGraalVMEAVersion {
|
||||
version: string
|
||||
latest?: boolean
|
||||
download_base_url: string
|
||||
files: OracleGraalVMEAFile[]
|
||||
}
|
||||
|
||||
function determineJDKArchitecture(): string {
|
||||
switch (process.arch) {
|
||||
case 'x64': {
|
||||
|
||||
@@ -31,7 +31,7 @@ export async function downloadGraalVMEELegacy(
|
||||
version: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const userAgent = `GraalVMGitHubAction/1.1.6 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`
|
||||
const userAgent = `GraalVMGitHubAction/1.1.8 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`
|
||||
const baseArtifact = await fetchArtifact(
|
||||
userAgent,
|
||||
'isBase:True',
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as semver from 'semver'
|
||||
import {
|
||||
downloadAndExtractJDK,
|
||||
downloadExtractAndCacheJDK,
|
||||
getContents,
|
||||
getLatestRelease,
|
||||
getMatchingTags,
|
||||
getTaggedRelease
|
||||
@@ -13,6 +14,8 @@ import {basename} from 'path'
|
||||
|
||||
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 ORACLE_GRAALVM_REPO_EA_BUILDS = 'oracle-graalvm-ea-builds'
|
||||
const ORACLE_GRAALVM_REPO_EA_BUILDS_LATEST_SYMBOL = 'latest-ea'
|
||||
const GRAALVM_REPO_DEV_BUILDS = 'graalvm-ce-dev-builds'
|
||||
const GRAALVM_JDK_TAG_PREFIX = 'jdk-'
|
||||
const GRAALVM_TAG_PREFIX = 'vm-'
|
||||
@@ -25,16 +28,26 @@ export async function setUpGraalVMJDK(
|
||||
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||
return setUpGraalVMJDKDevBuild()
|
||||
}
|
||||
const javaVersion = javaVersionOrDev
|
||||
let toolName = determineToolName(javaVersion, false)
|
||||
let javaVersion = javaVersionOrDev
|
||||
const toolName = determineToolName(javaVersion, false)
|
||||
let downloadName = toolName
|
||||
let downloadUrl: string
|
||||
if (javaVersion.includes('.')) {
|
||||
if (javaVersion.endsWith('-ea')) {
|
||||
downloadUrl = await findLatestEABuildDownloadUrl(javaVersion)
|
||||
const filename = basename(downloadUrl)
|
||||
const resolvedVersion = semver.valid(semver.coerce(filename))
|
||||
if (!resolvedVersion) {
|
||||
throw new Error(
|
||||
`Unable to determine resolved version based on '${filename}'. ${c.ERROR_REQUEST}`
|
||||
)
|
||||
}
|
||||
javaVersion = resolvedVersion
|
||||
} else if (javaVersion.includes('.')) {
|
||||
if (semver.valid(javaVersion)) {
|
||||
const majorJavaVersion = semver.major(javaVersion)
|
||||
const minorJavaVersion = semver.minor(javaVersion)
|
||||
const patchJavaVersion = semver.patch(javaVersion)
|
||||
const isGARelease = minorJavaVersion === 0 && patchJavaVersion === 0
|
||||
let downloadName = toolName
|
||||
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)
|
||||
@@ -46,12 +59,60 @@ export async function setUpGraalVMJDK(
|
||||
)
|
||||
}
|
||||
} 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)
|
||||
return downloadExtractAndCacheJDK(downloader, toolName, javaVersion)
|
||||
}
|
||||
|
||||
export async function findLatestEABuildDownloadUrl(
|
||||
javaEaVersion: string
|
||||
): Promise<string> {
|
||||
const filePath = `versions/${javaEaVersion}.json`
|
||||
let response
|
||||
try {
|
||||
response = await getContents(ORACLE_GRAALVM_REPO_EA_BUILDS, filePath)
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Unable to resolve download URL for '${javaEaVersion}'. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`
|
||||
)
|
||||
}
|
||||
if (
|
||||
Array.isArray(response) ||
|
||||
response.type !== 'file' ||
|
||||
!response.content
|
||||
) {
|
||||
throw new Error(
|
||||
`Unexpected response when resolving download URL for '${javaEaVersion}'. ${c.ERROR_REQUEST}`
|
||||
)
|
||||
}
|
||||
const versionData = JSON.parse(
|
||||
Buffer.from(response.content, 'base64').toString('utf-8')
|
||||
)
|
||||
let latestVersion
|
||||
if (javaEaVersion === ORACLE_GRAALVM_REPO_EA_BUILDS_LATEST_SYMBOL) {
|
||||
latestVersion = versionData as c.OracleGraalVMEAVersion
|
||||
} else {
|
||||
latestVersion = (versionData as c.OracleGraalVMEAVersion[]).find(
|
||||
v => v.latest
|
||||
)
|
||||
if (!latestVersion) {
|
||||
throw new Error(
|
||||
`Unable to find latest version for '${javaEaVersion}'. ${c.ERROR_REQUEST}`
|
||||
)
|
||||
}
|
||||
}
|
||||
const file = latestVersion.files.find(
|
||||
f => f.arch === c.JDK_ARCH && f.platform === c.GRAALVM_PLATFORM
|
||||
)
|
||||
if (!file || !file.filename.startsWith('graalvm-jdk-')) {
|
||||
throw new Error(
|
||||
`Unable to find file metadata for '${javaEaVersion}'. ${c.ERROR_REQUEST}`
|
||||
)
|
||||
}
|
||||
return `${latestVersion.download_base_url}${file.filename}`
|
||||
}
|
||||
|
||||
export async function setUpGraalVMJDKCE(
|
||||
javaVersionOrDev: string
|
||||
): Promise<string> {
|
||||
|
||||
11
src/main.ts
11
src/main.ts
@@ -3,7 +3,7 @@ import * as core from '@actions/core'
|
||||
import * as graalvm from './graalvm'
|
||||
import * as semver from 'semver'
|
||||
import {isFeatureAvailable as isCacheAvailable} from '@actions/cache'
|
||||
import {join} from 'path'
|
||||
import {basename, join} from 'path'
|
||||
import {restore} from './features/cache'
|
||||
import {setUpDependencies} from './dependencies'
|
||||
import {setUpGUComponents} from './gu'
|
||||
@@ -12,6 +12,7 @@ import {checkForUpdates} from './features/check-for-updates'
|
||||
import {setUpNativeImageMusl} from './features/musl'
|
||||
import {setUpWindowsEnvironment} from './msvc'
|
||||
import {setUpNativeImageBuildReports} from './features/reports'
|
||||
import {exec} from '@actions/exec'
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
@@ -31,7 +32,7 @@ async function run(): Promise<void> {
|
||||
const enableNativeImageMusl = core.getInput(c.INPUT_NI_MUSL) === 'true'
|
||||
|
||||
if (c.IS_WINDOWS) {
|
||||
setUpWindowsEnvironment(graalVMVersion)
|
||||
setUpWindowsEnvironment(javaVersion, graalVMVersion)
|
||||
}
|
||||
await setUpDependencies(components)
|
||||
if (enableNativeImageMusl) {
|
||||
@@ -151,6 +152,12 @@ async function run(): Promise<void> {
|
||||
await restore(cache)
|
||||
}
|
||||
setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion)
|
||||
|
||||
core.startGroup(`Successfully set up '${basename(graalVMHome)}'`)
|
||||
await exec(join(graalVMHome, 'bin', `java${c.EXECUTABLE_SUFFIX}`), [
|
||||
'--version'
|
||||
])
|
||||
core.endGroup()
|
||||
} catch (error) {
|
||||
if (error instanceof Error) core.setFailed(error.message)
|
||||
}
|
||||
|
||||
16
src/msvc.ts
16
src/msvc.ts
@@ -1,4 +1,5 @@
|
||||
import * as core from '@actions/core'
|
||||
import * as semver from 'semver'
|
||||
import {execSync} from 'child_process'
|
||||
import {existsSync} from 'fs'
|
||||
import {VERSION_DEV} from './constants'
|
||||
@@ -27,10 +28,21 @@ function findVcvarsallPath(): string {
|
||||
throw new Error('Failed to find vcvarsall.bat')
|
||||
}
|
||||
|
||||
export function setUpWindowsEnvironment(graalVMVersion: string): void {
|
||||
if (graalVMVersion === VERSION_DEV) {
|
||||
export function setUpWindowsEnvironment(
|
||||
javaVersion: string,
|
||||
graalVMVersion: string
|
||||
): void {
|
||||
if (javaVersion === javaVersion || graalVMVersion === VERSION_DEV) {
|
||||
return // no longer required in dev builds
|
||||
}
|
||||
const javaVersionSemVer = semver.coerce(javaVersion)
|
||||
if (
|
||||
javaVersionSemVer &&
|
||||
semver.valid(javaVersionSemVer) &&
|
||||
semver.gte(javaVersionSemVer, '18.0.0')
|
||||
) {
|
||||
return // no longer required in GraalVM for JDK 17 and later. JDK 17 builds from 22.3 still need this, so skip 17.X.X
|
||||
}
|
||||
|
||||
core.startGroup('Updating Windows environment...')
|
||||
|
||||
|
||||
43
src/utils.ts
43
src/utils.ts
@@ -2,6 +2,7 @@ import * as c from './constants'
|
||||
import * as core from '@actions/core'
|
||||
import * as github from '@actions/github'
|
||||
import * as httpClient from '@actions/http-client'
|
||||
import * as semver from 'semver'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import {ExecOptions, exec as e} from '@actions/exec'
|
||||
import {readFileSync, readdirSync} from 'fs'
|
||||
@@ -47,6 +48,22 @@ export async function getLatestRelease(
|
||||
).data
|
||||
}
|
||||
|
||||
export async function getContents(
|
||||
repo: string,
|
||||
path: string
|
||||
): Promise<c.ContentsResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
||||
const octokit = new GitHubDotCom(options)
|
||||
return (
|
||||
await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo,
|
||||
path
|
||||
})
|
||||
).data
|
||||
}
|
||||
|
||||
export async function getTaggedRelease(
|
||||
repo: string,
|
||||
tag: string
|
||||
@@ -135,17 +152,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 {
|
||||
const parts = version.split('.')
|
||||
const major = parts[0]
|
||||
const minor = parts.length > 1 ? parts[1] : '0'
|
||||
const patch = parts.length > 2 ? parts.slice(2).join('-') : '0'
|
||||
return `${major}.${minor}.${patch}`
|
||||
if (parts.length === 4) {
|
||||
/**
|
||||
* Turn legacy GraalVM version numbers (e.g., `22.0.0.2`) into valid
|
||||
* 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 {
|
||||
|
||||
Reference in New Issue
Block a user