Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52b9a9b316 | ||
|
|
435d2b356f | ||
|
|
6bd874f0ca | ||
|
|
be3e4f6272 | ||
|
|
fc45baf59f | ||
|
|
17d64df2bb |
8
.github/workflows/check-dist.yml
vendored
8
.github/workflows/check-dist.yml
vendored
@@ -24,12 +24,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set Node.js 20.x
|
||||
uses: actions/setup-node@v4
|
||||
- name: Set Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20.x
|
||||
node-version: 16.x
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
|
||||
101
.github/workflows/test.yml
vendored
101
.github/workflows/test.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
build: # make sure build/ci work properly
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- run: |
|
||||
npm install
|
||||
- run: |
|
||||
@@ -25,44 +25,17 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
java-version: ['21', '17', '20', 'dev']
|
||||
java-version: ['17', '20', 'dev']
|
||||
distribution: ['graalvm', 'graalvm-community']
|
||||
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
|
||||
- java-version: 'dev'
|
||||
distribution: ''
|
||||
os: windows-latest
|
||||
- java-version: '21'
|
||||
distribution: 'graalvm-community'
|
||||
os: ubuntu-latest
|
||||
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
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
java-version: ${{ matrix.java-version }}
|
||||
distribution: ${{ matrix.distribution }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
components: ${{ matrix.components }}
|
||||
- name: Check environment
|
||||
run: |
|
||||
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
||||
@@ -115,7 +88,7 @@ jobs:
|
||||
components: 'native-image'
|
||||
os: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
@@ -126,7 +99,7 @@ jobs:
|
||||
- name: Check environment
|
||||
run: |
|
||||
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
||||
if [[ "${{ matrix.version }}" == "dev" ]] && [[ "${{ matrix.java-version }}" == "dev" ]]; then
|
||||
if [[ "${{ matrix.version }}" == "dev" ]]; then
|
||||
[[ "$GRAALVM_HOME" == *"$RUNNER_TEMP"* ]] || exit 12
|
||||
else
|
||||
[[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23
|
||||
@@ -135,9 +108,7 @@ jobs:
|
||||
java --version
|
||||
java --version | grep "GraalVM" || exit 34
|
||||
native-image --version
|
||||
if [[ "${{ matrix.java-version }}" != "dev" ]]; then
|
||||
gu list
|
||||
fi
|
||||
gu list
|
||||
if: runner.os != 'Windows'
|
||||
- name: Check Windows environment
|
||||
run: |
|
||||
@@ -155,20 +126,20 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
version: ['latest']
|
||||
java-version: ['17']
|
||||
java-version: ['19']
|
||||
components: ['native-image']
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
include:
|
||||
- version: '22.3.3'
|
||||
- version: '22.3.0'
|
||||
java-version: '11'
|
||||
components: 'native-image'
|
||||
os: ubuntu-latest
|
||||
- version: '22.3.3'
|
||||
- version: '22.3.0'
|
||||
java-version: '17'
|
||||
components: 'native-image'
|
||||
os: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
@@ -183,7 +154,7 @@ jobs:
|
||||
[[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12
|
||||
echo "JAVA_HOME: $JAVA_HOME"
|
||||
java --version
|
||||
java --version | grep -e "GraalVM EE" -e "Oracle GraalVM" || exit 23
|
||||
java --version | grep "GraalVM EE" || exit 23
|
||||
native-image --version
|
||||
gu list
|
||||
if: runner.os != 'Windows'
|
||||
@@ -201,26 +172,19 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
version: ['mandrel-22.2.0.0-Final', '23.0.1.2-Final', 'mandrel-latest']
|
||||
version: ['mandrel-22.2.0.0-Final', 'mandrel-latest']
|
||||
java-version: ['17']
|
||||
distribution: ['mandrel']
|
||||
os: [windows-latest, ubuntu-latest]
|
||||
include:
|
||||
exclude: # temporarily disable Mandrel latest builds on Windows due to unavailability
|
||||
- version: 'mandrel-latest'
|
||||
java-version: '17'
|
||||
distribution: '' # test empty distribution for backward compatibility
|
||||
os: ubuntu-latest
|
||||
- version: '' # test with no version
|
||||
java-version: '21'
|
||||
distribution: 'mandrel'
|
||||
os: ubuntu-latest
|
||||
os: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
version: ${{ matrix.version }}
|
||||
distribution: ${{ matrix.distribution }}
|
||||
java-version: ${{ matrix.java-version }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Check environment
|
||||
@@ -229,7 +193,6 @@ jobs:
|
||||
[[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12
|
||||
echo "JAVA_HOME: $JAVA_HOME"
|
||||
java --version
|
||||
java --version | grep "Temurin" || exit 23
|
||||
native-image --version
|
||||
if: runner.os != 'Windows'
|
||||
- name: Check Windows environment
|
||||
@@ -246,7 +209,7 @@ jobs:
|
||||
contents: read
|
||||
pull-requests: write # for `native-image-pr-reports` option
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
@@ -268,7 +231,7 @@ jobs:
|
||||
contents: read
|
||||
pull-requests: write # for `native-image-pr-reports` option
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
@@ -290,7 +253,7 @@ jobs:
|
||||
contents: read
|
||||
pull-requests: write # for `native-image-pr-reports` option
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
@@ -313,11 +276,11 @@ jobs:
|
||||
contents: read
|
||||
pull-requests: write # for `native-image-pr-reports` option
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
java-version: '17.0.8'
|
||||
java-version: '17'
|
||||
distribution: 'graalvm'
|
||||
components: 'espresso,llvm-toolchain,native-image,nodejs,python,ruby,wasm'
|
||||
set-java-home: 'false'
|
||||
@@ -348,16 +311,16 @@ jobs:
|
||||
javac HelloWorld.java
|
||||
native-image -g HelloWorld
|
||||
./helloworld
|
||||
# - name: Build Ruby-FFI with TruffleRuby
|
||||
# run: |
|
||||
# [[ $(which bundle) == *"graalvm"* ]] || exit 57
|
||||
# git clone --depth 1 https://github.com/ffi/ffi.git
|
||||
# pushd ffi > /dev/null
|
||||
# # https://github.com/ffi/ffi/blob/447845cb3030194c79700c86fb388a12e6f81386/.github/workflows/ci.yml#L58-L62
|
||||
# bundle install
|
||||
# bundle exec rake libffi
|
||||
# bundle exec rake compile
|
||||
# bundle exec rake test
|
||||
# popd > /dev/null
|
||||
- name: Build Ruby-FFI with TruffleRuby
|
||||
run: |
|
||||
[[ $(which bundle) == *"graalvm"* ]] || exit 57
|
||||
git clone --depth 1 https://github.com/ffi/ffi.git
|
||||
pushd ffi > /dev/null
|
||||
# https://github.com/ffi/ffi/blob/447845cb3030194c79700c86fb388a12e6f81386/.github/workflows/ci.yml#L58-L62
|
||||
bundle install
|
||||
bundle exec rake libffi
|
||||
bundle exec rake compile
|
||||
bundle exec rake test
|
||||
popd > /dev/null
|
||||
- name: Remove components
|
||||
run: gu remove espresso llvm-toolchain nodejs python ruby wasm
|
||||
|
||||
100
README.md
100
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], [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))
|
||||
- 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))
|
||||
- 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,6 +15,34 @@ 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 new [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
|
||||
@@ -26,11 +54,11 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '21' # See 'Options' section below for all supported versions
|
||||
distribution: 'graalvm' # See 'Options' section below for all available distributions
|
||||
java-version: '17.0.7'
|
||||
distribution: 'graalvm' # See 'Options' for all available distributions
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Example step
|
||||
run: |
|
||||
@@ -57,11 +85,11 @@ jobs:
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '21'
|
||||
java-version: '17.0.7'
|
||||
distribution: 'graalvm'
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
native-image-job-reports: 'true'
|
||||
@@ -80,26 +108,6 @@ 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>
|
||||
|
||||
@@ -110,7 +118,7 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
version: '22.3.2' # GraalVM version
|
||||
@@ -138,7 +146,7 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
version: '22.3.0'
|
||||
@@ -154,41 +162,12 @@ 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 | 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> |
|
||||
| `java-version`<br>*(required)* | n/a | `'17.0.7'` or `'20.0.1'` 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). |
|
||||
| `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]. |
|
||||
@@ -197,7 +176,7 @@ can be replaced with:
|
||||
| `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]. |
|
||||
| `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.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. |
|
||||
| `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]. |
|
||||
| `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.*
|
||||
@@ -212,7 +191,6 @@ 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.toThrow(
|
||||
return expect(restore('ant')).rejects.toThrowError(
|
||||
'unknown package manager specified: ant'
|
||||
)
|
||||
})
|
||||
|
||||
describe('for maven', () => {
|
||||
it('throws error if no pom.xml found', async () => {
|
||||
await expect(restore('maven')).rejects.toThrow(
|
||||
await expect(restore('maven')).rejects.toThrowError(
|
||||
`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).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found')
|
||||
expect(spyCacheRestore).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith('maven cache is not found')
|
||||
})
|
||||
})
|
||||
describe('for gradle', () => {
|
||||
it('throws error if no build.gradle found', async () => {
|
||||
await expect(restore('gradle')).rejects.toThrow(
|
||||
await expect(restore('gradle')).rejects.toThrowError(
|
||||
`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).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found')
|
||||
expect(spyCacheRestore).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith('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).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found')
|
||||
expect(spyCacheRestore).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith('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).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found')
|
||||
expect(spyCacheRestore).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith('gradle cache is not found')
|
||||
})
|
||||
describe('for sbt', () => {
|
||||
it('throws error if no build.sbt found', async () => {
|
||||
await expect(restore('sbt')).rejects.toThrow(
|
||||
await expect(restore('sbt')).rejects.toThrowError(
|
||||
`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).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith('sbt cache is not found')
|
||||
expect(spyCacheRestore).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith('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.toThrow(
|
||||
return expect(save('ant')).rejects.toThrowError(
|
||||
'unknown package manager specified: ant'
|
||||
)
|
||||
})
|
||||
@@ -201,10 +201,10 @@ describe('dependency cache', () => {
|
||||
createStateForMissingBuildFile()
|
||||
|
||||
await save('maven')
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith(
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith(
|
||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||
)
|
||||
})
|
||||
@@ -225,26 +225,24 @@ describe('dependency cache', () => {
|
||||
it('uploads cache even if no pom.xml found', async () => {
|
||||
createStateForMissingBuildFile()
|
||||
await save('maven')
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
})
|
||||
it('does not upload cache if no restore run before', async () => {
|
||||
createFile(join(workspace, 'pom.xml'))
|
||||
|
||||
await save('maven')
|
||||
expect(spyCacheSave).not.toHaveBeenCalled()
|
||||
expect(spyWarning).toHaveBeenCalledWith(
|
||||
'Error retrieving key from state.'
|
||||
)
|
||||
expect(spyCacheSave).not.toBeCalled()
|
||||
expect(spyWarning).toBeCalledWith('Error retrieving key from state.')
|
||||
})
|
||||
it('uploads cache', async () => {
|
||||
createFile(join(workspace, 'pom.xml'))
|
||||
createStateForSuccessfulRestore()
|
||||
|
||||
await save('maven')
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith(
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith(
|
||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||
)
|
||||
})
|
||||
@@ -254,26 +252,24 @@ describe('dependency cache', () => {
|
||||
createStateForMissingBuildFile()
|
||||
|
||||
await save('gradle')
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
})
|
||||
it('does not upload cache if no restore run before', async () => {
|
||||
createFile(join(workspace, 'build.gradle'))
|
||||
|
||||
await save('gradle')
|
||||
expect(spyCacheSave).not.toHaveBeenCalled()
|
||||
expect(spyWarning).toHaveBeenCalledWith(
|
||||
'Error retrieving key from state.'
|
||||
)
|
||||
expect(spyCacheSave).not.toBeCalled()
|
||||
expect(spyWarning).toBeCalledWith('Error retrieving key from state.')
|
||||
})
|
||||
it('uploads cache based on build.gradle', async () => {
|
||||
createFile(join(workspace, 'build.gradle'))
|
||||
createStateForSuccessfulRestore()
|
||||
|
||||
await save('gradle')
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith(
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith(
|
||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||
)
|
||||
})
|
||||
@@ -282,9 +278,9 @@ describe('dependency cache', () => {
|
||||
createStateForSuccessfulRestore()
|
||||
|
||||
await save('gradle')
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith(
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith(
|
||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||
)
|
||||
})
|
||||
@@ -294,9 +290,9 @@ describe('dependency cache', () => {
|
||||
createStateForSuccessfulRestore()
|
||||
|
||||
await save('gradle')
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith(
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith(
|
||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||
)
|
||||
})
|
||||
@@ -305,26 +301,24 @@ describe('dependency cache', () => {
|
||||
it('uploads cache even if no build.sbt found', async () => {
|
||||
createStateForMissingBuildFile()
|
||||
await save('sbt')
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
})
|
||||
it('does not upload cache if no restore run before', async () => {
|
||||
createFile(join(workspace, 'build.sbt'))
|
||||
|
||||
await save('sbt')
|
||||
expect(spyCacheSave).not.toHaveBeenCalled()
|
||||
expect(spyWarning).toHaveBeenCalledWith(
|
||||
'Error retrieving key from state.'
|
||||
)
|
||||
expect(spyCacheSave).not.toBeCalled()
|
||||
expect(spyWarning).toBeCalledWith('Error retrieving key from state.')
|
||||
})
|
||||
it('uploads cache', async () => {
|
||||
createFile(join(workspace, 'build.sbt'))
|
||||
createStateForSuccessfulRestore()
|
||||
|
||||
await save('sbt')
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyInfo).toHaveBeenCalledWith(
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
expect(spyInfo).toBeCalledWith(
|
||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||
)
|
||||
})
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
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>>
|
||||
@@ -61,8 +62,8 @@ describe('cleanup', () => {
|
||||
return name === 'cache' ? 'gradle' : ''
|
||||
})
|
||||
await cleanup()
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyWarning).not.toHaveBeenCalled()
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
expect(spyWarning).not.toBeCalled()
|
||||
})
|
||||
|
||||
it('does not fail even though the save process throws error', async () => {
|
||||
@@ -73,7 +74,7 @@ describe('cleanup', () => {
|
||||
return name === 'cache' ? 'gradle' : ''
|
||||
})
|
||||
await cleanup()
|
||||
expect(spyCacheSave).toHaveBeenCalled()
|
||||
expect(spyCacheSave).toBeCalled()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@ 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,
|
||||
findLatestEABuildDownloadUrl
|
||||
} from '../src/graalvm'
|
||||
import {findGraalVMVersion, findHighestJavaVersion} from '../src/graalvm'
|
||||
import {GRAALVM_RELEASES_REPO} from '../src/constants'
|
||||
|
||||
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
|
||||
@@ -83,21 +79,3 @@ 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')
|
||||
})
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
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}`)
|
||||
}
|
||||
})
|
||||
@@ -1,34 +0,0 @@
|
||||
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:
|
||||
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||
runs:
|
||||
using: 'node20'
|
||||
using: 'node16'
|
||||
main: 'dist/main/index.js'
|
||||
post: 'dist/cleanup/index.js'
|
||||
post-if: 'success()'
|
||||
|
||||
34884
dist/cleanup/index.js
generated
vendored
34884
dist/cleanup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
34720
dist/main/index.js
generated
vendored
34720
dist/main/index.js
generated
vendored
File diff suppressed because one or more lines are too long
9607
package-lock.json
generated
9607
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",
|
||||
"version": "1.1.8",
|
||||
"version": "1.1.0",
|
||||
"private": true,
|
||||
"description": "GitHub Action for GraalVM",
|
||||
"main": "lib/main.js",
|
||||
@@ -27,37 +27,33 @@
|
||||
"author": "GraalVM Community",
|
||||
"license": "UPL",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^3.2.3",
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@actions/glob": "^0.4.0",
|
||||
"@actions/http-client": "^2.2.0",
|
||||
"@actions/io": "^1.1.3",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@octokit/core": "^5.1.0",
|
||||
"@octokit/types": "^12.0.0",
|
||||
"semver": "^7.5.4",
|
||||
"uuid": "^9.0.1"
|
||||
"@actions/cache": "^3.0.4",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.1.0",
|
||||
"@actions/github": "^5.1.1",
|
||||
"@actions/glob": "^0.3.0",
|
||||
"@actions/http-client": "^1.0.11",
|
||||
"@actions/io": "^1.1.1",
|
||||
"@actions/tool-cache": "^1.7.1",
|
||||
"@octokit/core": "^3.5.1",
|
||||
"@octokit/types": "^6.34.0",
|
||||
"semver": "^7.3.8",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.11",
|
||||
"@types/node": "^20.11.10",
|
||||
"@types/semver": "^7.5.6",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
||||
"@typescript-eslint/parser": "^6.19.1",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-plugin-github": "^4.10.1",
|
||||
"eslint-plugin-jest": "^27.6.3",
|
||||
"eslint-plugin-jsonc": "^2.13.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"jest": "^29.7.0",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/node": "^18.15.11",
|
||||
"@types/semver": "^7.3.13",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"@typescript-eslint/parser": "^5.8.1",
|
||||
"@vercel/ncc": "^0.33.4",
|
||||
"eslint": "^8.6.0",
|
||||
"eslint-plugin-github": "^4.3.5",
|
||||
"eslint-plugin-jest": "^25.3.4",
|
||||
"jest": "^29.5.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "^3.2.4",
|
||||
"prettier-eslint": "^16.3.0",
|
||||
"ts-jest": "^29.1.2",
|
||||
"typescript": "^5.3.3"
|
||||
"prettier": "2.5.1",
|
||||
"ts-jest": "^29.1.0",
|
||||
"typescript": "^5.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ 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'
|
||||
@@ -42,9 +40,6 @@ 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.'
|
||||
|
||||
@@ -54,25 +49,6 @@ 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': {
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
import * as core from '@actions/core'
|
||||
import {getTaggedRelease, toSemVer} from '../utils'
|
||||
import {lt, major, minor, valid} from 'semver'
|
||||
import {findGraalVMVersion} from '../graalvm'
|
||||
import {GRAALVM_RELEASES_REPO} from '../constants'
|
||||
|
||||
export function checkForUpdates(
|
||||
export async function checkForUpdates(
|
||||
graalVMVersion: string,
|
||||
javaVersion: string
|
||||
): void {
|
||||
if (javaVersion === '20') {
|
||||
core.notice(
|
||||
'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
|
||||
}
|
||||
): Promise<void> {
|
||||
if (
|
||||
graalVMVersion.length > 0 &&
|
||||
(javaVersion === '17' || javaVersion === '19')
|
||||
) {
|
||||
const recommendedJDK = javaVersion === '17' ? '17' : '21'
|
||||
const recommendedJDK = javaVersion === '17' ? '17' : '20'
|
||||
core.notice(
|
||||
`A new GraalVM release is available! Please consider upgrading to GraalVM for JDK ${recommendedJDK}. Instructions: https://github.com/graalvm/setup-graalvm#migrating-from-graalvm-223-or-earlier-to-the-new-graalvm-for-jdk-17-and-later`
|
||||
)
|
||||
@@ -27,5 +25,23 @@ export function checkForUpdates(
|
||||
)
|
||||
return
|
||||
}
|
||||
// TODO: add support for JDK-specific update checks (e.g., 17.0.X)
|
||||
|
||||
const latestRelease = await getTaggedRelease(
|
||||
GRAALVM_RELEASES_REPO,
|
||||
'vm-22.3.1'
|
||||
)
|
||||
const latestGraalVMVersion = findGraalVMVersion(latestRelease)
|
||||
const selectedVersion = toSemVer(graalVMVersion)
|
||||
const latestVersion = toSemVer(latestGraalVMVersion)
|
||||
if (
|
||||
valid(selectedVersion) &&
|
||||
valid(latestVersion) &&
|
||||
lt(selectedVersion, latestVersion)
|
||||
) {
|
||||
core.notice(
|
||||
`A new GraalVM release is available! Please consider upgrading to GraalVM ${latestGraalVMVersion}. Release notes: https://www.graalvm.org/release-notes/${major(
|
||||
latestVersion
|
||||
)}_${minor(latestVersion)}/`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,18 +33,11 @@ interface BuildOutput {
|
||||
name: string
|
||||
graalvm_version: string
|
||||
java_version: string | null
|
||||
vendor_version?: string
|
||||
c_compiler: string | null
|
||||
garbage_collector: string
|
||||
graal_compiler?: {
|
||||
optimization_level: string
|
||||
march: string
|
||||
pgo?: string[]
|
||||
}
|
||||
}
|
||||
analysis_results: {
|
||||
classes: AnalysisResult
|
||||
types?: AnalysisResult
|
||||
fields: AnalysisResult
|
||||
methods: AnalysisResult
|
||||
}
|
||||
@@ -56,9 +49,6 @@ interface BuildOutput {
|
||||
}
|
||||
image_heap: {
|
||||
bytes: number
|
||||
objects?: {
|
||||
count: number
|
||||
}
|
||||
resources: {
|
||||
count: number
|
||||
bytes: number
|
||||
@@ -85,12 +75,10 @@ interface BuildOutput {
|
||||
system_total: number
|
||||
peak_rss_bytes: number
|
||||
}
|
||||
total_secs?: number
|
||||
}
|
||||
}
|
||||
|
||||
export async function setUpNativeImageBuildReports(
|
||||
isGraalVMforJDK17OrLater: boolean,
|
||||
graalVMVersion: string
|
||||
): Promise<void> {
|
||||
const isRequired = areJobReportsEnabled() || arePRReportsEnabled()
|
||||
@@ -98,9 +86,9 @@ export async function setUpNativeImageBuildReports(
|
||||
return
|
||||
}
|
||||
const isSupported =
|
||||
isGraalVMforJDK17OrLater ||
|
||||
graalVMVersion === c.VERSION_LATEST ||
|
||||
graalVMVersion === c.VERSION_DEV ||
|
||||
graalVMVersion.length === 0 ||
|
||||
(!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) &&
|
||||
gte(toSemVer(graalVMVersion), '22.2.0'))
|
||||
if (!isSupported) {
|
||||
@@ -166,12 +154,7 @@ function createReport(data: BuildOutput): string {
|
||||
const context = github.context
|
||||
const info = data.general_info
|
||||
const analysis = data.analysis_results
|
||||
const analysisTypes = analysis.types ? analysis.types : analysis.classes
|
||||
const details = data.image_details
|
||||
let objectCount = ''
|
||||
if (details.image_heap.objects) {
|
||||
objectCount = `${details.image_heap.objects.count.toLocaleString()} objects, `
|
||||
}
|
||||
const debugInfoBytes = details.debug_info ? details.debug_info.bytes : 0
|
||||
const otherBytes =
|
||||
details.total_bytes -
|
||||
@@ -188,59 +171,12 @@ function createReport(data: BuildOutput): string {
|
||||
<td align="left"></td>
|
||||
</tr>`
|
||||
}
|
||||
let versionLine
|
||||
if (info.vendor_version) {
|
||||
versionLine = `
|
||||
<tr>
|
||||
<td><a href="${DOCS_BASE}#glossary-java-info" target="_blank">Java version</a></td>
|
||||
<td>${info.java_version}</td>
|
||||
<td><a href="${DOCS_BASE}#glossary-java-info" target="_blank">Vendor version</a></td>
|
||||
<td>${info.vendor_version}</td>
|
||||
</tr>`
|
||||
} else {
|
||||
versionLine = `
|
||||
<tr>
|
||||
<td><a href="${DOCS_BASE}#glossary-version-info" target="_blank">GraalVM version</a></td>
|
||||
<td>${info.graalvm_version}</td>
|
||||
<td><a href="${DOCS_BASE}#glossary-java-version-info" target="_blank">Java version</a></td>
|
||||
<td>${info.java_version}</td>
|
||||
</tr>`
|
||||
}
|
||||
let graalLine
|
||||
if (info.graal_compiler) {
|
||||
let pgoSuffix = ''
|
||||
const isOracleGraalVM =
|
||||
info.vendor_version && info.vendor_version.includes('Oracle GraalVM')
|
||||
if (isOracleGraalVM) {
|
||||
const pgo = info.graal_compiler.pgo
|
||||
const pgoText = pgo ? pgo.join('+') : 'off'
|
||||
pgoSuffix = `, <a href="${DOCS_BASE}#recommendation-pgo" target="_blank">PGO</a>: ${pgoText}`
|
||||
}
|
||||
graalLine = `
|
||||
<tr>
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-graal-compiler" target="_blank">Graal compiler</a></td>
|
||||
<td colspan="3">
|
||||
optimization level: ${info.graal_compiler.optimization_level},
|
||||
target machine: ${info.graal_compiler.march}${pgoSuffix}
|
||||
</td>
|
||||
</tr>`
|
||||
}
|
||||
|
||||
const resources = data.resource_usage
|
||||
|
||||
let totalTime = ''
|
||||
let gcTotalTimeRatio = ''
|
||||
if (resources.total_secs) {
|
||||
totalTime = ` in ${secondsToHuman(resources.total_secs)}`
|
||||
gcTotalTimeRatio = ` (${toPercent(
|
||||
resources.garbage_collection.total_secs,
|
||||
resources.total_secs
|
||||
)} of total time)`
|
||||
}
|
||||
|
||||
return `## GraalVM Native Image Build Report
|
||||
|
||||
\`${info.name}\` generated${totalTime} as part of the '${
|
||||
\`${info.name}\` generated as part of the '${
|
||||
context.job
|
||||
}' job in run <a href="${context.serverUrl}/${context.repo.owner}/${
|
||||
context.repo.repo
|
||||
@@ -248,14 +184,18 @@ function createReport(data: BuildOutput): string {
|
||||
|
||||
#### Environment
|
||||
|
||||
<table>${versionLine}${graalLine}
|
||||
<table>
|
||||
<tr>
|
||||
<td><a href="${DOCS_BASE}#glossary-version-info" target="_blank">GraalVM version</a></td>
|
||||
<td>${info.graalvm_version}</td>
|
||||
<td><a href="${DOCS_BASE}#glossary-ccompiler" target="_blank">C compiler</a></td>
|
||||
<td colspan="3">${info.c_compiler}</td>
|
||||
<td>${info.c_compiler}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="${DOCS_BASE}#glossary-java-version-info" target="_blank">Java version</a></td>
|
||||
<td>${info.java_version}</td>
|
||||
<td><a href="${DOCS_BASE}#glossary-gc" target="_blank">Garbage collector</a></td>
|
||||
<td colspan="3">${info.garbage_collector}</td>
|
||||
<td>${info.garbage_collector}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -276,17 +216,17 @@ function createReport(data: BuildOutput): string {
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-reachability" target="_blank">Reachable</a></td>
|
||||
<td align="right">${analysisTypes.reachable.toLocaleString()}</td>
|
||||
<td align="right">${analysis.classes.reachable}</td>
|
||||
<td align="right">${toPercent(
|
||||
analysisTypes.reachable,
|
||||
analysisTypes.total
|
||||
analysis.classes.reachable,
|
||||
analysis.classes.total
|
||||
)}</td>
|
||||
<td align="right">${analysis.fields.reachable.toLocaleString()}</td>
|
||||
<td align="right">${analysis.fields.reachable}</td>
|
||||
<td align="right">${toPercent(
|
||||
analysis.fields.reachable,
|
||||
analysis.fields.total
|
||||
)}</td>
|
||||
<td align="right">${analysis.methods.reachable.toLocaleString()}</td>
|
||||
<td align="right">${analysis.methods.reachable}</td>
|
||||
<td align="right">${toPercent(
|
||||
analysis.methods.reachable,
|
||||
analysis.methods.total
|
||||
@@ -294,17 +234,17 @@ function createReport(data: BuildOutput): string {
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-reflection-registrations" target="_blank">Reflection</a></td>
|
||||
<td align="right">${analysisTypes.reflection.toLocaleString()}</td>
|
||||
<td align="right">${analysis.classes.reflection}</td>
|
||||
<td align="right">${toPercent(
|
||||
analysisTypes.reflection,
|
||||
analysisTypes.total
|
||||
analysis.classes.reflection,
|
||||
analysis.classes.total
|
||||
)}</td>
|
||||
<td align="right">${analysis.fields.reflection.toLocaleString()}</td>
|
||||
<td align="right">${analysis.fields.reflection}</td>
|
||||
<td align="right">${toPercent(
|
||||
analysis.fields.reflection,
|
||||
analysis.fields.total
|
||||
)}</td>
|
||||
<td align="right">${analysis.methods.reflection.toLocaleString()}</td>
|
||||
<td align="right">${analysis.methods.reflection}</td>
|
||||
<td align="right">${toPercent(
|
||||
analysis.methods.reflection,
|
||||
analysis.methods.total
|
||||
@@ -312,17 +252,17 @@ function createReport(data: BuildOutput): string {
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-jni-access-registrations" target="_blank">JNI</a></td>
|
||||
<td align="right">${analysisTypes.jni.toLocaleString()}</td>
|
||||
<td align="right">${analysis.classes.jni}</td>
|
||||
<td align="right">${toPercent(
|
||||
analysisTypes.jni,
|
||||
analysisTypes.total
|
||||
analysis.classes.jni,
|
||||
analysis.classes.total
|
||||
)}</td>
|
||||
<td align="right">${analysis.fields.jni.toLocaleString()}</td>
|
||||
<td align="right">${analysis.fields.jni}</td>
|
||||
<td align="right">${toPercent(
|
||||
analysis.fields.jni,
|
||||
analysis.fields.total
|
||||
)}</td>
|
||||
<td align="right">${analysis.methods.jni.toLocaleString()}</td>
|
||||
<td align="right">${analysis.methods.jni}</td>
|
||||
<td align="right">${toPercent(
|
||||
analysis.methods.jni,
|
||||
analysis.methods.total
|
||||
@@ -330,11 +270,11 @@ function createReport(data: BuildOutput): string {
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-reachability" target="_blank">Loaded</a></td>
|
||||
<td align="right">${analysisTypes.total.toLocaleString()}</td>
|
||||
<td align="right">${analysis.classes.total}</td>
|
||||
<td align="right">100.000%</td>
|
||||
<td align="right">${analysis.fields.total.toLocaleString()}</td>
|
||||
<td align="right">${analysis.fields.total}</td>
|
||||
<td align="right">100.000%</td>
|
||||
<td align="right">${analysis.methods.total.toLocaleString()}</td>
|
||||
<td align="right">${analysis.methods.total}</td>
|
||||
<td align="right">100.000%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -359,7 +299,9 @@ function createReport(data: BuildOutput): string {
|
||||
details.code_area.bytes,
|
||||
details.total_bytes
|
||||
)}</td>
|
||||
<td align="left">${details.code_area.compilation_units.toLocaleString()} compilation units</td>
|
||||
<td align="left">${
|
||||
details.code_area.compilation_units
|
||||
} compilation units</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-image-heap" target="_blank">Image heap</a></td>
|
||||
@@ -368,9 +310,9 @@ function createReport(data: BuildOutput): string {
|
||||
details.image_heap.bytes,
|
||||
details.total_bytes
|
||||
)}</td>
|
||||
<td align="left">${objectCount}${bytesToHuman(
|
||||
<td align="left">${bytesToHuman(
|
||||
details.image_heap.resources.bytes
|
||||
)} for ${details.image_heap.resources.count.toLocaleString()} resources</td>
|
||||
)} for ${details.image_heap.resources.count} resources</td>
|
||||
</tr>${debugInfoLine}
|
||||
<tr>
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-other-data" target="_blank">Other data</a></td>
|
||||
@@ -397,23 +339,23 @@ function createReport(data: BuildOutput): string {
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-garbage-collections" target="_blank">Garbage collection</a></td>
|
||||
<td align="left">${resources.garbage_collection.total_secs.toFixed(
|
||||
2
|
||||
)}s${gcTotalTimeRatio} in ${resources.garbage_collection.count} GCs</td>
|
||||
)}s in ${resources.garbage_collection.count} GCs</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-peak-rss" target="_blank">Peak RSS</a></td>
|
||||
<td align="left">${bytesToHuman(
|
||||
resources.memory.peak_rss_bytes
|
||||
)} (${toPercent(
|
||||
resources.memory.peak_rss_bytes,
|
||||
resources.memory.system_total
|
||||
)} of ${bytesToHuman(resources.memory.system_total)} system memory)</td>
|
||||
resources.memory.peak_rss_bytes,
|
||||
resources.memory.system_total
|
||||
)} of ${bytesToHuman(resources.memory.system_total)} system memory)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<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(
|
||||
resources.cpu.load,
|
||||
resources.cpu.total_cores
|
||||
)} of ${resources.cpu.total_cores} CPU cores)</td>
|
||||
resources.cpu.load,
|
||||
resources.cpu.total_cores
|
||||
)} of ${resources.cpu.total_cores} CPU cores)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -436,11 +378,3 @@ function bytesToHuman(bytes: number): string {
|
||||
return `${(bytes / BYTES_TO_GiB).toFixed(2)}GB`
|
||||
}
|
||||
}
|
||||
|
||||
function secondsToHuman(seconds: number): string {
|
||||
if (seconds < 60) {
|
||||
return `${seconds.toFixed(1)}s`
|
||||
} else {
|
||||
return `${Math.trunc(seconds / 60)}m ${Math.trunc(seconds % 60)}s`
|
||||
}
|
||||
}
|
||||
|
||||
15
src/gds.ts
15
src/gds.ts
@@ -6,7 +6,8 @@ import * as io from '@actions/io'
|
||||
import * as path from 'path'
|
||||
import * as stream from 'stream'
|
||||
import * as util from 'util'
|
||||
import {IncomingHttpHeaders, OutgoingHttpHeaders} from 'http'
|
||||
import {IHeaders} from '@actions/http-client/interfaces'
|
||||
import {IncomingHttpHeaders} from 'http'
|
||||
import {RetryHelper} from '@actions/tool-cache/lib/retry-helper'
|
||||
import {calculateSHA256} from './utils'
|
||||
import {ok} from 'assert'
|
||||
@@ -31,7 +32,7 @@ export async function downloadGraalVMEELegacy(
|
||||
version: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const userAgent = `GraalVMGitHubAction/1.1.8 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`
|
||||
const userAgent = `GraalVMGitHubAction/1.1.0 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`
|
||||
const baseArtifact = await fetchArtifact(
|
||||
userAgent,
|
||||
'isBase:True',
|
||||
@@ -69,11 +70,7 @@ export async function fetchArtifact(
|
||||
await response.readBody()
|
||||
) as GDSArtifactsResponse
|
||||
if (artifactResponse.items.length !== 1) {
|
||||
throw new Error(
|
||||
artifactResponse.items.length > 1
|
||||
? `Found more than one GDS artifact. ${c.ERROR_HINT}`
|
||||
: `Unable to find GDS artifact. Are you sure version: '${version}' is correct?`
|
||||
)
|
||||
throw new Error(`Found more than one GDS artifact`)
|
||||
}
|
||||
return artifactResponse.items[0]
|
||||
}
|
||||
@@ -131,7 +128,7 @@ class HTTPError extends Error {
|
||||
async function downloadTool(
|
||||
url: string,
|
||||
userAgent: string,
|
||||
headers?: OutgoingHttpHeaders
|
||||
headers?: IHeaders
|
||||
): Promise<string> {
|
||||
const dest = path.join(getTempDirectory(), uuidv4())
|
||||
await io.mkdirP(path.dirname(dest))
|
||||
@@ -168,7 +165,7 @@ async function downloadToolAttempt(
|
||||
url: string,
|
||||
userAgent: string,
|
||||
dest: string,
|
||||
headers?: OutgoingHttpHeaders
|
||||
headers?: IHeaders
|
||||
): Promise<string> {
|
||||
if (fs.existsSync(dest)) {
|
||||
throw new Error(`Destination file path ${dest} already exists`)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import * as c from './constants'
|
||||
import * as semver from 'semver'
|
||||
import {
|
||||
downloadAndExtractJDK,
|
||||
downloadExtractAndCacheJDK,
|
||||
getContents,
|
||||
getLatestRelease,
|
||||
getMatchingTags,
|
||||
getTaggedRelease
|
||||
@@ -11,11 +9,10 @@ import {
|
||||
import {downloadGraalVMEELegacy} from './gds'
|
||||
import {downloadTool} from '@actions/tool-cache'
|
||||
import {basename} from 'path'
|
||||
import {gt as semverGt, valid as semverValid} from 'semver'
|
||||
|
||||
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-'
|
||||
@@ -28,91 +25,19 @@ export async function setUpGraalVMJDK(
|
||||
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||
return setUpGraalVMJDKDevBuild()
|
||||
}
|
||||
let javaVersion = javaVersionOrDev
|
||||
const javaVersion = javaVersionOrDev
|
||||
const toolName = determineToolName(javaVersion, false)
|
||||
let downloadName = toolName
|
||||
let downloadUrl: string
|
||||
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
|
||||
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}`
|
||||
)
|
||||
}
|
||||
if (javaVersion.includes('.')) {
|
||||
const majorJavaVersion = javaVersion.split('.')[0]
|
||||
downloadUrl = `${GRAALVM_DL_BASE}/${majorJavaVersion}/archive/${toolName}${c.GRAALVM_FILE_EXTENSION}`
|
||||
} else {
|
||||
downloadUrl = `${GRAALVM_DL_BASE}/${javaVersion}/latest/${downloadName}${c.GRAALVM_FILE_EXTENSION}`
|
||||
downloadUrl = `${GRAALVM_DL_BASE}/${javaVersion}/latest/${toolName}${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> {
|
||||
@@ -146,8 +71,8 @@ export async function findLatestGraalVMJDKCEJavaVersion(
|
||||
for (const matchingRef of matchingRefs) {
|
||||
const currentVersion = matchingRef.ref.substring(versionNumberStartIndex)
|
||||
if (
|
||||
semver.valid(currentVersion) &&
|
||||
semver.gt(currentVersion, highestVersion)
|
||||
semverValid(currentVersion) &&
|
||||
semverGt(currentVersion, highestVersion)
|
||||
) {
|
||||
highestVersion = currentVersion
|
||||
}
|
||||
@@ -235,11 +160,11 @@ export function findHighestJavaVersion(
|
||||
|
||||
// Support for GraalVM 22.X releases and earlier
|
||||
|
||||
export async function setUpGraalVMLatest_22_X(
|
||||
export async function setUpGraalVMLatest(
|
||||
gdsToken: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const lockedVersion = javaVersion === '19' ? '22.3.1' : '22.3.3'
|
||||
const lockedVersion = '22.3.1'
|
||||
if (gdsToken.length > 0) {
|
||||
return setUpGraalVMRelease(gdsToken, lockedVersion, javaVersion)
|
||||
}
|
||||
|
||||
39
src/gu.ts
39
src/gu.ts
@@ -1,6 +1,3 @@
|
||||
import * as c from './constants'
|
||||
import * as core from '@actions/core'
|
||||
import * as semver from 'semver'
|
||||
import {GRAALVM_PLATFORM} from './constants'
|
||||
import {exec} from './utils'
|
||||
import {join} from 'path'
|
||||
@@ -25,42 +22,6 @@ const COMPONENT_TO_POST_INSTALL_HOOK = new Map<string, Map<string, string>>([
|
||||
])
|
||||
|
||||
export async function setUpGUComponents(
|
||||
javaVersion: string,
|
||||
graalVMVersion: string,
|
||||
graalVMHome: string,
|
||||
components: string[],
|
||||
gdsToken: string
|
||||
): Promise<void> {
|
||||
if (components.length == 0) {
|
||||
return // nothing to do
|
||||
}
|
||||
const coercedJavaVersion = semver.coerce(javaVersion)
|
||||
if (
|
||||
graalVMVersion === c.VERSION_DEV ||
|
||||
javaVersion === c.VERSION_DEV ||
|
||||
(coercedJavaVersion != null && semver.gte(coercedJavaVersion, '21.0.0'))
|
||||
) {
|
||||
if (components.length == 1 && components[0] === 'native-image') {
|
||||
core.warning(
|
||||
`Please remove "components: 'native-image'" from your workflow file. It is automatically included since GraalVM for JDK 17: https://github.com/oracle/graal/pull/5995`
|
||||
)
|
||||
} else {
|
||||
core.warning(
|
||||
`Unable to install component(s): '${components.join(
|
||||
','
|
||||
)}'. The latest GraalVM dev builds and the upcoming GraalVM for JDK 21 no longer include the GraalVM Updater: https://github.com/oracle/graal/issues/6855`
|
||||
)
|
||||
}
|
||||
} else if (graalVMVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||
core.warning(
|
||||
`Mandrel does not support GraalVM component(s): '${components.join(',')}'`
|
||||
)
|
||||
} else {
|
||||
await installGUComponents(gdsToken, graalVMHome, components)
|
||||
}
|
||||
}
|
||||
|
||||
async function installGUComponents(
|
||||
gdsToken: string,
|
||||
graalVMHome: string,
|
||||
components: string[]
|
||||
|
||||
81
src/main.ts
81
src/main.ts
@@ -1,9 +1,9 @@
|
||||
import * as c from './constants'
|
||||
import * as core from '@actions/core'
|
||||
import * as graalvm from './graalvm'
|
||||
import * as semver from 'semver'
|
||||
import {gte as semverGte, valid as semverValid} from 'semver'
|
||||
import {isFeatureAvailable as isCacheAvailable} from '@actions/cache'
|
||||
import {basename, join} from 'path'
|
||||
import {join} from 'path'
|
||||
import {restore} from './features/cache'
|
||||
import {setUpDependencies} from './dependencies'
|
||||
import {setUpGUComponents} from './gu'
|
||||
@@ -12,13 +12,12 @@ 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 {
|
||||
const javaVersion = core.getInput(c.INPUT_JAVA_VERSION, {required: true})
|
||||
const distribution = core.getInput(c.INPUT_DISTRIBUTION)
|
||||
const graalVMVersion = core.getInput(c.INPUT_VERSION)
|
||||
const graalvmVersion = core.getInput(c.INPUT_VERSION)
|
||||
const gdsToken = core.getInput(c.INPUT_GDS_TOKEN)
|
||||
const componentsString: string = core.getInput(c.INPUT_COMPONENTS)
|
||||
const components: string[] =
|
||||
@@ -32,25 +31,16 @@ async function run(): Promise<void> {
|
||||
const enableNativeImageMusl = core.getInput(c.INPUT_NI_MUSL) === 'true'
|
||||
|
||||
if (c.IS_WINDOWS) {
|
||||
setUpWindowsEnvironment(javaVersion, graalVMVersion)
|
||||
setUpWindowsEnvironment(graalvmVersion)
|
||||
}
|
||||
await setUpDependencies(components)
|
||||
if (enableNativeImageMusl) {
|
||||
await setUpNativeImageMusl()
|
||||
}
|
||||
|
||||
// Download GraalVM JDK
|
||||
const isGraalVMforJDK17OrLater =
|
||||
distribution.length > 0 || graalVMVersion.length == 0
|
||||
// Download or build GraalVM
|
||||
let graalVMHome
|
||||
if (isGraalVMforJDK17OrLater) {
|
||||
if (
|
||||
enableCheckForUpdates &&
|
||||
(distribution === c.DISTRIBUTION_GRAALVM ||
|
||||
distribution === c.DISTRIBUTION_GRAALVM_COMMUNITY)
|
||||
) {
|
||||
checkForUpdates(graalVMVersion, javaVersion)
|
||||
}
|
||||
if (distribution.length > 0 || graalvmVersion.length == 0) {
|
||||
switch (distribution) {
|
||||
case c.DISTRIBUTION_GRAALVM:
|
||||
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||
@@ -59,8 +49,9 @@ async function run(): Promise<void> {
|
||||
graalVMHome = await graalvm.setUpGraalVMJDKCE(javaVersion)
|
||||
break
|
||||
case c.DISTRIBUTION_MANDREL:
|
||||
graalVMHome = await setUpMandrel(graalVMVersion, javaVersion)
|
||||
break
|
||||
throw new Error(
|
||||
`Mandrel requires the 'version' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
||||
)
|
||||
case '':
|
||||
if (javaVersion === c.VERSION_DEV) {
|
||||
core.info(
|
||||
@@ -73,25 +64,22 @@ async function run(): Promise<void> {
|
||||
)
|
||||
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported distribution: ${distribution}`)
|
||||
}
|
||||
} else {
|
||||
const coercedJavaVersion = semver.coerce(javaVersion)
|
||||
switch (graalVMVersion) {
|
||||
switch (graalvmVersion) {
|
||||
case c.VERSION_LATEST:
|
||||
if (
|
||||
javaVersion.startsWith('17') ||
|
||||
(coercedJavaVersion !== null &&
|
||||
semver.gte(coercedJavaVersion, '20.0.0'))
|
||||
(semverValid(javaVersion) && semverGte(javaVersion, '20'))
|
||||
) {
|
||||
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).`
|
||||
)
|
||||
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||
} else {
|
||||
graalVMHome = await graalvm.setUpGraalVMLatest_22_X(
|
||||
graalVMHome = await graalvm.setUpGraalVMLatest(
|
||||
gdsToken,
|
||||
javaVersion
|
||||
)
|
||||
@@ -103,28 +91,18 @@ async function run(): Promise<void> {
|
||||
'Downloading GraalVM EE dev builds is not supported'
|
||||
)
|
||||
}
|
||||
if (
|
||||
coercedJavaVersion !== null &&
|
||||
!semver.gte(coercedJavaVersion, '21.0.0')
|
||||
) {
|
||||
core.warning(
|
||||
`GraalVM dev builds are only available for JDK 21. This build is now using a stable release of GraalVM for JDK ${javaVersion}.`
|
||||
)
|
||||
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||
} else {
|
||||
graalVMHome = await graalvm.setUpGraalVMJDKDevBuild()
|
||||
}
|
||||
graalVMHome = await graalvm.setUpGraalVMJDKDevBuild()
|
||||
break
|
||||
default:
|
||||
if (graalVMVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||
graalVMHome = await setUpMandrel(graalVMVersion, javaVersion)
|
||||
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||
graalVMHome = await setUpMandrel(graalvmVersion, javaVersion)
|
||||
} else {
|
||||
if (enableCheckForUpdates) {
|
||||
checkForUpdates(graalVMVersion, javaVersion)
|
||||
await checkForUpdates(graalvmVersion, javaVersion)
|
||||
}
|
||||
graalVMHome = await graalvm.setUpGraalVMRelease(
|
||||
gdsToken,
|
||||
graalVMVersion,
|
||||
graalvmVersion,
|
||||
javaVersion
|
||||
)
|
||||
}
|
||||
@@ -140,24 +118,21 @@ async function run(): Promise<void> {
|
||||
core.exportVariable('JAVA_HOME', graalVMHome)
|
||||
}
|
||||
|
||||
await setUpGUComponents(
|
||||
javaVersion,
|
||||
graalVMVersion,
|
||||
graalVMHome,
|
||||
components,
|
||||
gdsToken
|
||||
)
|
||||
// Set up GraalVM components (if any)
|
||||
if (components.length > 0) {
|
||||
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||
core.warning(
|
||||
`Mandrel does not support GraalVM components: ${componentsString}`
|
||||
)
|
||||
} else {
|
||||
await setUpGUComponents(gdsToken, graalVMHome, components)
|
||||
}
|
||||
}
|
||||
|
||||
if (cache && isCacheAvailable()) {
|
||||
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()
|
||||
setUpNativeImageBuildReports(graalvmVersion)
|
||||
} catch (error) {
|
||||
if (error instanceof Error) core.setFailed(error.message)
|
||||
}
|
||||
|
||||
137
src/mandrel.ts
137
src/mandrel.ts
@@ -1,33 +1,27 @@
|
||||
import * as c from './constants'
|
||||
import * as httpClient from '@actions/http-client'
|
||||
import {downloadExtractAndCacheJDK, getLatestRelease} from './utils'
|
||||
import {downloadTool} from '@actions/tool-cache'
|
||||
import {basename} from 'path'
|
||||
|
||||
export const MANDREL_REPO = 'mandrel'
|
||||
export const MANDREL_TAG_PREFIX = c.MANDREL_NAMESPACE
|
||||
const MANDREL_REPO = 'mandrel'
|
||||
const MANDREL_TAG_PREFIX = c.MANDREL_NAMESPACE
|
||||
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(
|
||||
mandrelVersion: string,
|
||||
graalvmVersion: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const version = stripMandrelNamespace(mandrelVersion)
|
||||
const mandrelVersion = graalvmVersion.substring(
|
||||
c.MANDREL_NAMESPACE.length,
|
||||
graalvmVersion.length
|
||||
)
|
||||
|
||||
let mandrelHome
|
||||
switch (version) {
|
||||
case '':
|
||||
// fetch latest if no version is specified
|
||||
switch (mandrelVersion) {
|
||||
case 'latest':
|
||||
mandrelHome = await setUpMandrelLatest(javaVersion)
|
||||
break
|
||||
default:
|
||||
mandrelHome = await setUpMandrelRelease(version, javaVersion)
|
||||
mandrelHome = await setUpMandrelRelease(mandrelVersion, javaVersion)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -35,110 +29,32 @@ export async function setUpMandrel(
|
||||
}
|
||||
|
||||
async function setUpMandrelLatest(javaVersion: string): Promise<string> {
|
||||
const latest_release_url = await getLatestMandrelReleaseUrl(javaVersion)
|
||||
const version_tag = getTagFromURI(latest_release_url)
|
||||
const version = stripMandrelNamespace(version_tag)
|
||||
|
||||
const toolName = determineToolName(javaVersion)
|
||||
return downloadExtractAndCacheJDK(
|
||||
async () => downloadTool(latest_release_url),
|
||||
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}`
|
||||
const latestRelease = await getLatestRelease(MANDREL_REPO)
|
||||
const tag_name = latestRelease.tag_name
|
||||
if (tag_name.startsWith(MANDREL_TAG_PREFIX)) {
|
||||
const latestVersion = tag_name.substring(
|
||||
MANDREL_TAG_PREFIX.length,
|
||||
tag_name.length
|
||||
)
|
||||
return setUpMandrelRelease(latestVersion, javaVersion)
|
||||
}
|
||||
throw new Error(`Could not find latest Mandrel release: ${tag_name}`)
|
||||
}
|
||||
|
||||
async function setUpMandrelRelease(
|
||||
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}`
|
||||
const toolName = determineToolName(javaVersion)
|
||||
return downloadExtractAndCacheJDK(
|
||||
async () => downloadMandrelJDK(version, javaVersion),
|
||||
async () => downloadTool(downloadUrl),
|
||||
toolName,
|
||||
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(
|
||||
version: string,
|
||||
javaVersion: string
|
||||
@@ -149,14 +65,3 @@ function determineMandrelIdentifier(
|
||||
function determineToolName(javaVersion: string): string {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
16
src/msvc.ts
16
src/msvc.ts
@@ -1,5 +1,4 @@
|
||||
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'
|
||||
@@ -28,21 +27,10 @@ function findVcvarsallPath(): string {
|
||||
throw new Error('Failed to find vcvarsall.bat')
|
||||
}
|
||||
|
||||
export function setUpWindowsEnvironment(
|
||||
javaVersion: string,
|
||||
graalVMVersion: string
|
||||
): void {
|
||||
if (javaVersion === javaVersion || graalVMVersion === VERSION_DEV) {
|
||||
export function setUpWindowsEnvironment(graalVMVersion: string): void {
|
||||
if (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,7 +2,6 @@ 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'
|
||||
@@ -48,22 +47,6 @@ 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
|
||||
@@ -152,25 +135,17 @@ 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('.')
|
||||
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
|
||||
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}`
|
||||
}
|
||||
|
||||
export function isPREvent(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user