Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2911b2304b | ||
|
|
00a7ff5258 | ||
|
|
010c924385 | ||
|
|
bafd5b75bd | ||
|
|
e92be2ccca | ||
|
|
809512d83d | ||
|
|
2f25c0caae | ||
|
|
ee8b81f45c | ||
|
|
3e1010f34c | ||
|
|
fb9f5a0734 | ||
|
|
6c07077221 | ||
|
|
3d5584d4fc | ||
|
|
a19f51dc38 | ||
|
|
30261a858e | ||
|
|
6670574f7f | ||
|
|
d9e910f637 | ||
|
|
5302a697e3 | ||
|
|
049aa7c191 | ||
|
|
df4b80eebe | ||
|
|
3d7ab58c1d | ||
|
|
d3f9e14fc3 | ||
|
|
b03aef7455 | ||
|
|
5393c3d809 | ||
|
|
e878075a91 | ||
|
|
9a425fb910 | ||
|
|
7652cc43b3 | ||
|
|
a2b35c9a1c | ||
|
|
791f27b2b8 | ||
|
|
f6947ecb49 | ||
|
|
cb063c121c | ||
|
|
076347913e | ||
|
|
d72e3dbf5f | ||
|
|
22551b2bec | ||
|
|
bf3e45bce6 | ||
|
|
1588b03f82 | ||
|
|
6df9f698c6 | ||
|
|
2408275e34 | ||
|
|
a638430bc0 | ||
|
|
3bd233e767 | ||
|
|
c99915cc1a | ||
|
|
a0f131ece5 | ||
|
|
a1b47fdf04 | ||
|
|
129a551a10 | ||
|
|
b8dc5fccfb | ||
|
|
1c219f5b27 | ||
|
|
2a93b69fdf | ||
|
|
0b782b6b90 | ||
|
|
d5b07dd118 | ||
|
|
40dc6ae006 | ||
|
|
cde0daed27 | ||
|
|
22b65d7de0 | ||
|
|
c2fd2d6d8e | ||
|
|
2b3d0bde8f | ||
|
|
6c7d417a1e | ||
|
|
8dd4f51a5e | ||
|
|
2fb264a6b0 |
6
.github/workflows/check-dist.yml
vendored
6
.github/workflows/check-dist.yml
vendored
@@ -26,10 +26,10 @@ jobs:
|
||||
steps:
|
||||
- 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
|
||||
|
||||
88
.github/workflows/test.yml
vendored
88
.github/workflows/test.yml
vendored
@@ -25,10 +25,22 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
java-version: ['21', '17', '20', 'dev']
|
||||
java-version: ['22', '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: '23-ea'
|
||||
distribution: 'graalvm'
|
||||
os: ubuntu-latest
|
||||
- java-version: '21'
|
||||
distribution: ''
|
||||
os: ubuntu-latest
|
||||
@@ -39,6 +51,9 @@ jobs:
|
||||
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
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run setup-graalvm action
|
||||
@@ -47,6 +62,7 @@ jobs:
|
||||
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"
|
||||
@@ -67,7 +83,7 @@ jobs:
|
||||
java --version
|
||||
native-image --version
|
||||
test-ce: # make sure the action works on a clean machine without building
|
||||
needs: test
|
||||
needs: test
|
||||
name: CE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@@ -86,8 +102,12 @@ jobs:
|
||||
java-version: '17'
|
||||
components: 'native-image'
|
||||
os: ubuntu-20.04
|
||||
- version: '21.2.0'
|
||||
java-version: '8' # for JDK 8 notification
|
||||
components: 'native-image'
|
||||
os: ubuntu-latest
|
||||
- version: '22.3.1'
|
||||
java-version: '11' # for JDK11 notification
|
||||
java-version: '11' # for JDK 11 notification
|
||||
components: 'native-image'
|
||||
os: macos-11
|
||||
- version: '22.3.1'
|
||||
@@ -116,8 +136,8 @@ jobs:
|
||||
[[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23
|
||||
fi
|
||||
echo "JAVA_HOME: $JAVA_HOME"
|
||||
java --version
|
||||
java --version | grep "GraalVM" || exit 34
|
||||
java -version
|
||||
java -version 2>&1 | grep "GraalVM" || exit 34
|
||||
native-image --version
|
||||
if [[ "${{ matrix.java-version }}" != "dev" ]]; then
|
||||
gu list
|
||||
@@ -127,7 +147,7 @@ jobs:
|
||||
run: |
|
||||
echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
||||
echo "JAVA_HOME: $env:JAVA_HOME"
|
||||
java --version
|
||||
java -version
|
||||
native-image --version
|
||||
gu.cmd remove native-image
|
||||
if: runner.os == 'Windows'
|
||||
@@ -185,7 +205,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
version: ['mandrel-22.2.0.0-Final', 'mandrel-latest']
|
||||
version: ['mandrel-22.2.0.0-Final', '23.0.1.2-Final', 'mandrel-latest']
|
||||
java-version: ['17']
|
||||
distribution: ['mandrel']
|
||||
os: [windows-latest, ubuntu-latest]
|
||||
@@ -194,10 +214,10 @@ jobs:
|
||||
java-version: '17'
|
||||
distribution: '' # test empty distribution for backward compatibility
|
||||
os: ubuntu-latest
|
||||
exclude: # temporarily disable Mandrel latest builds on Windows due to unavailability
|
||||
- version: 'mandrel-latest'
|
||||
java-version: '17'
|
||||
os: windows-latest
|
||||
- version: '' # test with no version
|
||||
java-version: '21'
|
||||
distribution: 'mandrel'
|
||||
os: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run setup-graalvm action
|
||||
@@ -223,6 +243,48 @@ jobs:
|
||||
java --version
|
||||
native-image --version
|
||||
if: runner.os == 'Windows'
|
||||
test-liberica:
|
||||
needs: test
|
||||
name: Liberica (${{ matrix.java-version }}, '${{ matrix.java-package }}', ${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
java-version: ['17', '21.0.2']
|
||||
java-package: ['', 'jdk', 'jdk+fx']
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
distribution: liberica
|
||||
java-version: ${{ matrix.java-version }}
|
||||
java-package: ${{ matrix.java-package }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Check environment
|
||||
run: |
|
||||
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
||||
[[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12
|
||||
echo "JAVA_HOME: $JAVA_HOME"
|
||||
java --version
|
||||
java --version | fgrep -qw ${{ matrix.java-version }} || exit 23
|
||||
native-image --version
|
||||
native-image --version | fgrep -qw ${{ matrix.java-version }} || exit 24
|
||||
if: runner.os != 'Windows'
|
||||
- name: Check Windows environment
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
||||
echo "JAVA_HOME: $env:JAVA_HOME"
|
||||
java --version
|
||||
if (!(java --version | findstr \<${{ matrix.java-version }}\>)) {
|
||||
exit 23
|
||||
}
|
||||
native-image --version
|
||||
if (!(native-image --version | findstr \<${{ matrix.java-version }}\>)) {
|
||||
exit 24
|
||||
}
|
||||
if: runner.os == 'Windows'
|
||||
test-native-image-windows:
|
||||
name: native-image on windows-latest
|
||||
runs-on: windows-latest
|
||||
@@ -301,7 +363,7 @@ jobs:
|
||||
- name: Run setup-graalvm action
|
||||
uses: ./
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '17.0.8'
|
||||
distribution: 'graalvm'
|
||||
components: 'espresso,llvm-toolchain,native-image,nodejs,python,ruby,wasm'
|
||||
set-java-home: 'false'
|
||||
|
||||
94
README.md
94
README.md
@@ -1,11 +1,11 @@
|
||||
# GitHub Action for GraalVM [](https://github.com/graalvm/setup-graalvm/actions/workflows/test.yml)
|
||||
This GitHub action sets up [Oracle GraalVM][graalvm-medium], GraalVM [Community Edition (CE)][repo], [Enterprise Edition (EE)][graalvm-ee], or [Mandrel][mandrel], as well as [Native Image][native-image] and GraalVM components such as [Truffle languages][truffle-languages].
|
||||
This GitHub action sets up [Oracle GraalVM][graalvm-medium], GraalVM [Community Edition (CE)][repo], [Enterprise Edition (EE)][graalvm-ee], [Mandrel][mandrel], or [Liberica Native Image Kit][liberica] as well as [Native Image][native-image] and GraalVM components such as [Truffle languages][truffle-languages].
|
||||
|
||||
## Key Features
|
||||
|
||||
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, [Mandrel][mandrel], and [Liberica Native Image Kit][liberica] (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: '23-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,42 @@ 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.3'`, `'17.0.11'`</li><li>early access (EA) builds: `'23-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><li>Liberica: `'liberica'`</li></ul> |
|
||||
| `java-package` | `'jdk'` | The package type (`'jdk'` or `'jdk+fx'`). Currently applies to Liberica only. |
|
||||
| `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]. |
|
||||
@@ -176,7 +198,7 @@ jobs:
|
||||
| `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` (e.g., `mandrel-21.3.0.0-Final`) for a specific [Mandrel release][mandrel-releases],<br>`mandrel-latest` for [latest Mandrel stable release][mandrel-stable]. |
|
||||
| `version` | `''` | `X.Y.Z` (e.g., `22.3.0`) for a specific [GraalVM release][releases] up to `22.3.2`<br>`mandrel-X.Y.Z.W` or `X.Y.Z.W-Final` (e.g., `mandrel-21.3.0.0-Final` or `21.3.0.0-Final`) for a specific [Mandrel release][mandrel-releases],<br>`mandrel-latest` or `latest` for the latest Mandrel stable release. |
|
||||
| `gds-token` | `''` | Download token for the GraalVM Download Service. If a non-empty token is provided, the action will set up GraalVM Enterprise Edition (see [GraalVM EE template](#template-for-graalvm-enterprise-edition)). |
|
||||
|
||||
**) Make sure that Native Image is used only once per build job. Otherwise, the report is only generated for the last Native Image build.*
|
||||
@@ -191,6 +213,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
|
||||
@@ -200,6 +223,7 @@ Only pull requests from committers that can be verified as having signed the OCA
|
||||
[graalvm-dl]: https://www.oracle.com/java/technologies/downloads/
|
||||
[graalvm-medium]: https://medium.com/graalvm/a-new-graalvm-release-and-new-free-license-4aab483692f5
|
||||
[graalvm-ee]: https://www.oracle.com/downloads/graalvm-downloads.html
|
||||
[liberica]: https://bell-sw.com/liberica-native-image-kit/
|
||||
[mandrel]: https://github.com/graalvm/mandrel
|
||||
[mandrel-releases]: https://github.com/graalvm/mandrel/releases
|
||||
[mandrel-stable]: https://github.com/graalvm/mandrel/releases/latest
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ test('errors when downloading artifacts', async () => {
|
||||
await expect(
|
||||
downloadGraalVMEELegacy('invalid', '22.1.0', '11')
|
||||
).rejects.toThrow(
|
||||
'The provided "gds-token" was rejected (reason: "Invalid download token", opc-request-id: /'
|
||||
'The provided "gds-token" was rejected (reason: "Invalid download token", opc-request-id: '
|
||||
)
|
||||
await expect(
|
||||
downloadGraalVMEELegacy('invalid', '1.0.0', '11')
|
||||
|
||||
@@ -2,8 +2,12 @@ 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 {GRAALVM_RELEASES_REPO} from '../src/constants'
|
||||
import {
|
||||
findGraalVMVersion,
|
||||
findHighestJavaVersion,
|
||||
findLatestEABuildDownloadUrl
|
||||
} from '../src/graalvm'
|
||||
import {GRAALVM_GH_USER, GRAALVM_RELEASES_REPO} from '../src/constants'
|
||||
|
||||
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
|
||||
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
|
||||
@@ -49,6 +53,7 @@ test('find version/javaVersion', async () => {
|
||||
expect(error.message).toContain('Unable to find the latest Java version for')
|
||||
|
||||
const latestRelease = await getTaggedRelease(
|
||||
GRAALVM_GH_USER,
|
||||
GRAALVM_RELEASES_REPO,
|
||||
'vm-22.3.1'
|
||||
)
|
||||
@@ -79,3 +84,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')
|
||||
})
|
||||
|
||||
138
__tests__/liberica.test.ts
Normal file
138
__tests__/liberica.test.ts
Normal file
@@ -0,0 +1,138 @@
|
||||
import * as liberica from '../src/liberica'
|
||||
import * as c from '../src/constants'
|
||||
import * as path from 'path'
|
||||
import * as semver from 'semver'
|
||||
import {expect, test} from '@jest/globals'
|
||||
|
||||
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
|
||||
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
|
||||
|
||||
test('find latest JDK version', async () => {
|
||||
// Make sure the action can find the latest Java version for known major versions
|
||||
await expectLatestToBe('11', atLeast('11.0.22+12'))
|
||||
await expectLatestToBe('11.0.22', upToBuild('11.0.22+12'))
|
||||
await expectLatestToBe('11.0.22+12', exactly('11.0.22+12'))
|
||||
|
||||
await expectLatestToBe('17', atLeast('17.0.10+13'))
|
||||
await expectLatestToBe('17.0.10', upToBuild('17.0.10+13'))
|
||||
await expectLatestToBe('17.0.10+13', exactly('17.0.10+13'))
|
||||
|
||||
await expectLatestToBe('21', atLeast('21.0.2+14'))
|
||||
await expectLatestToBe('21.0.2', upToBuild('21.0.2+14'))
|
||||
await expectLatestToBe('21.0.2+14', exactly('21.0.2+14'))
|
||||
|
||||
// Outdated major version
|
||||
await expectLatestToFail('20')
|
||||
|
||||
// Outdated CPU versions
|
||||
await expectLatestToFail('11.0.2') // should not resolve to 11.0.22
|
||||
await expectLatestToFail('17.0.1') // should not resolve to 17.0.10
|
||||
await expectLatestToFail('17.0.7+11')
|
||||
await expectLatestToFail('21.0.0+8')
|
||||
await expectLatestToFail('21.0.1')
|
||||
|
||||
// Incorrect build number
|
||||
await expectLatestToFail('17.0.10+10')
|
||||
}, 30000)
|
||||
|
||||
test('find asset URL', async () => {
|
||||
await expectURL('11.0.22+12', '', 'bellsoft-liberica-vm-openjdk11.0.22')
|
||||
await expectURL('17.0.10+13', 'jdk', 'bellsoft-liberica-vm-openjdk17.0.10')
|
||||
|
||||
if (!c.IS_LINUX) {
|
||||
// This check can fail on Linux because there's no `jdk+fx` package for aarch64 and/or musl
|
||||
await expectURL(
|
||||
'21.0.2+14',
|
||||
'jdk+fx',
|
||||
'bellsoft-liberica-vm-full-openjdk21.0.2'
|
||||
)
|
||||
}
|
||||
}, 10000)
|
||||
|
||||
type verifier = (
|
||||
version: string,
|
||||
major: number,
|
||||
minor: number,
|
||||
patch: number
|
||||
) => void
|
||||
|
||||
function atLeast(expectedMinVersion: string): verifier {
|
||||
const expectedMajor = semver.major(expectedMinVersion)
|
||||
return function (
|
||||
version: string,
|
||||
major: number,
|
||||
minor: number,
|
||||
patch: number
|
||||
) {
|
||||
expect(major).toBe(expectedMajor)
|
||||
if (semver.compareBuild(version, expectedMinVersion) < 0) {
|
||||
throw new Error(`Version ${version} is older than ${expectedMinVersion}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function upToBuild(expectedMinVersion: string): verifier {
|
||||
const expectedMinor = semver.minor(expectedMinVersion)
|
||||
const expectedPatch = semver.patch(expectedMinVersion)
|
||||
const atLeastVerifier = atLeast(expectedMinVersion)
|
||||
return function (
|
||||
version: string,
|
||||
major: number,
|
||||
minor: number,
|
||||
patch: number
|
||||
) {
|
||||
atLeastVerifier(version, major, minor, patch)
|
||||
expect(minor).toBe(expectedMinor)
|
||||
expect(patch).toBe(expectedPatch)
|
||||
}
|
||||
}
|
||||
|
||||
function exactly(expectedVersion: string): verifier {
|
||||
return function (
|
||||
version: string,
|
||||
major: number,
|
||||
minor: number,
|
||||
patch: number
|
||||
) {
|
||||
if (semver.compareBuild(version, expectedVersion) != 0) {
|
||||
throw new Error(`Expected version ${expectedVersion} but got ${version}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function expectLatestToBe(pattern: string, verify: verifier) {
|
||||
const result = await liberica.findLatestLibericaJavaVersion(pattern)
|
||||
expect(semver.valid(result)).toBeDefined()
|
||||
const major = semver.major(result)
|
||||
const minor = semver.minor(result)
|
||||
const patch = semver.patch(result)
|
||||
verify(result, major, minor, patch)
|
||||
}
|
||||
|
||||
async function expectLatestToFail(pattern: string) {
|
||||
try {
|
||||
const result = await liberica.findLatestLibericaJavaVersion(pattern)
|
||||
throw new Error(
|
||||
`findLatest(${pattern}) should have failed but returned ${result}`
|
||||
)
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
throw new Error(`Unexpected non-Error: ${err}`)
|
||||
}
|
||||
expect(err.message).toContain(
|
||||
`Unable to find the latest version for JDK${pattern}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
async function expectURL(
|
||||
javaVersion: string,
|
||||
javaPackage: string,
|
||||
expectedPrefix: string
|
||||
) {
|
||||
const url = await liberica.findLibericaURL(javaVersion, javaPackage)
|
||||
expect(url).toBeDefined()
|
||||
const parts = url.split('/')
|
||||
const file = parts[parts.length - 1]
|
||||
expect(file.startsWith(expectedPrefix)).toBe(true)
|
||||
}
|
||||
75
__tests__/mandrel.test.ts
Normal file
75
__tests__/mandrel.test.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import * as path from 'path'
|
||||
import * as mandrel from '../src/mandrel'
|
||||
import {expect, test} from '@jest/globals'
|
||||
import {getLatestRelease} from '../src/utils'
|
||||
|
||||
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
|
||||
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
|
||||
|
||||
test('request invalid version/javaVersion combination', async () => {
|
||||
for (var combination of [
|
||||
['mandrel-23.1.1.0-Final', '17'],
|
||||
['mandrel-23.0.2.1-Final', '21']
|
||||
]) {
|
||||
let error = new Error('unexpected')
|
||||
try {
|
||||
await mandrel.setUpMandrel(combination[0], combination[1])
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
fail(`Unexpected non-Error: ${err}`)
|
||||
}
|
||||
error = err
|
||||
}
|
||||
|
||||
expect(error).not.toBeUndefined()
|
||||
expect(error.message).toContain('Failed to download')
|
||||
expect(error.message).toContain('Are you sure version')
|
||||
}
|
||||
})
|
||||
test('request invalid version', async () => {
|
||||
for (var combination of [
|
||||
['mandrel-23.1.1.0', '21'],
|
||||
['mandrel-23.0.2.1', '17']
|
||||
]) {
|
||||
let error = new Error('unexpected')
|
||||
try {
|
||||
await mandrel.setUpMandrel(combination[0], combination[1])
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
fail(`Unexpected non-Error: ${err}`)
|
||||
}
|
||||
error = err
|
||||
}
|
||||
|
||||
expect(error).not.toBeUndefined()
|
||||
expect(error.message).toContain('Failed to download')
|
||||
expect(error.message).toContain('Are you sure version')
|
||||
}
|
||||
})
|
||||
|
||||
test('find latest', async () => {
|
||||
// Make sure the action can find the latest Mandrel release
|
||||
const latestRelease = await getLatestRelease(mandrel.MANDREL_REPO)
|
||||
const tag_name = latestRelease.tag_name
|
||||
expect(tag_name).toContain(mandrel.MANDREL_TAG_PREFIX)
|
||||
})
|
||||
|
||||
test('get known latest Mandrel for specific JDK', async () => {
|
||||
// Test deprecated versions that won't get updates anymore
|
||||
for (var combination of [
|
||||
['11', '22.2.0.0-Final'],
|
||||
['20', '23.0.1.2-Final']
|
||||
]) {
|
||||
const latest = await mandrel.getLatestMandrelReleaseUrl(combination[0])
|
||||
expect(latest).toContain(`mandrel-java${combination[0]}`)
|
||||
expect(latest).toContain(combination[1])
|
||||
}
|
||||
})
|
||||
|
||||
test('get latest Mandrel for specific JDK', async () => {
|
||||
// Test supported versions
|
||||
for (var javaVersion of ['17', '21']) {
|
||||
const latest = await mandrel.getLatestMandrelReleaseUrl(javaVersion)
|
||||
expect(latest).toContain(`mandrel-java${javaVersion}`)
|
||||
}
|
||||
})
|
||||
36
__tests__/msvc.test.ts
Normal file
36
__tests__/msvc.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import * as path from 'path'
|
||||
import {expect, test} from '@jest/globals'
|
||||
import {needsWindowsEnvironmentSetup} from '../src/msvc'
|
||||
import {VERSION_DEV, VERSION_LATEST} from '../src/constants'
|
||||
|
||||
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
|
||||
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
|
||||
|
||||
test('decide whether Window env must be set up for GraalVM for JDK', async () => {
|
||||
for (var javaVersion of [
|
||||
'17',
|
||||
'17.0.8',
|
||||
'17.0',
|
||||
'21',
|
||||
'22',
|
||||
'22-ea',
|
||||
'23-ea',
|
||||
VERSION_DEV
|
||||
]) {
|
||||
expect(needsWindowsEnvironmentSetup(javaVersion, '', true)).toBe(false)
|
||||
}
|
||||
})
|
||||
|
||||
test('decide whether Window env must be set up for legacy GraalVM', async () => {
|
||||
for (var combination of [
|
||||
['7', '22.3.0'],
|
||||
['17', '22.3'],
|
||||
['7', '22.3'],
|
||||
['7', VERSION_DEV],
|
||||
['17', VERSION_LATEST]
|
||||
]) {
|
||||
expect(
|
||||
needsWindowsEnvironmentSetup(combination[0], combination[1], false)
|
||||
).toBe(combination[1] !== VERSION_DEV)
|
||||
}
|
||||
})
|
||||
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')
|
||||
}
|
||||
})
|
||||
@@ -8,6 +8,10 @@ inputs:
|
||||
java-version:
|
||||
required: true
|
||||
description: 'Java version. See examples of supported syntax in the README file.'
|
||||
java-package:
|
||||
description: 'The package type (jdk or jdk+fx). Currently applies to Liberica only.'
|
||||
required: false
|
||||
default: 'jdk'
|
||||
distribution:
|
||||
description: 'GraalVM distribution. See the list of available distributions in the README file.'
|
||||
required: false
|
||||
@@ -54,7 +58,7 @@ outputs:
|
||||
cache-hit:
|
||||
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||
runs:
|
||||
using: 'node16'
|
||||
using: 'node20'
|
||||
main: 'dist/main/index.js'
|
||||
post: 'dist/cleanup/index.js'
|
||||
post-if: 'success()'
|
||||
|
||||
37620
dist/cleanup/index.js
generated
vendored
37620
dist/cleanup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
37500
dist/main/index.js
generated
vendored
37500
dist/main/index.js
generated
vendored
File diff suppressed because one or more lines are too long
10051
package-lock.json
generated
10051
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.4",
|
||||
"version": "1.2.2",
|
||||
"private": true,
|
||||
"description": "GitHub Action for GraalVM",
|
||||
"main": "lib/main.js",
|
||||
@@ -27,33 +27,37 @@
|
||||
"author": "GraalVM Community",
|
||||
"license": "UPL",
|
||||
"dependencies": {
|
||||
"@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.5.2",
|
||||
"uuid": "^8.3.2"
|
||||
"@actions/cache": "^3.2.4",
|
||||
"@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.1",
|
||||
"@actions/io": "^1.1.3",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@octokit/core": "^5.1.0",
|
||||
"@octokit/types": "^12.6.0",
|
||||
"semver": "^7.6.0",
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.11.28",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
||||
"@typescript-eslint/parser": "^7.2.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-github": "^4.10.2",
|
||||
"eslint-plugin-jest": "^27.9.0",
|
||||
"eslint-plugin-jsonc": "^2.14.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"jest": "^29.7.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "2.5.1",
|
||||
"ts-jest": "^29.1.0",
|
||||
"typescript": "^5.0.4"
|
||||
"prettier": "^3.2.5",
|
||||
"prettier-eslint": "^16.3.0",
|
||||
"ts-jest": "^29.1.2",
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as otypes from '@octokit/types'
|
||||
export const INPUT_VERSION = 'version'
|
||||
export const INPUT_GDS_TOKEN = 'gds-token'
|
||||
export const INPUT_JAVA_VERSION = 'java-version'
|
||||
export const INPUT_JAVA_PACKAGE = 'java-package'
|
||||
export const INPUT_DISTRIBUTION = 'distribution'
|
||||
export const INPUT_COMPONENTS = 'components'
|
||||
export const INPUT_GITHUB_TOKEN = 'github-token'
|
||||
@@ -15,9 +16,12 @@ 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'
|
||||
export const DISTRIBUTION_LIBERICA = 'liberica'
|
||||
|
||||
export const VERSION_DEV = 'dev'
|
||||
export const VERSION_LATEST = 'latest'
|
||||
@@ -40,6 +44,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 +56,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': {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as core from '@actions/core'
|
||||
|
||||
export async function checkForUpdates(
|
||||
export function checkForUpdates(
|
||||
graalVMVersion: string,
|
||||
javaVersion: string
|
||||
): Promise<void> {
|
||||
): void {
|
||||
if (javaVersion === '20') {
|
||||
core.notice(
|
||||
'A new GraalVM release is available! Please consider upgrading to GraalVM for JDK 21: https://medium.com/p/ee01177dd12d'
|
||||
'A new GraalVM release is available! Please consider upgrading to GraalVM for JDK 21: https://medium.com/graalvm/graalvm-for-jdk-21-is-here-ee01177dd12d'
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ import * as c from '../constants'
|
||||
import * as core from '@actions/core'
|
||||
import * as fs from 'fs'
|
||||
import * as github from '@actions/github'
|
||||
import * as semver from 'semver'
|
||||
import {join} from 'path'
|
||||
import {tmpdir} from 'os'
|
||||
import {createPRComment, isPREvent, toSemVer} from '../utils'
|
||||
import {gte} from 'semver'
|
||||
|
||||
const BUILD_OUTPUT_JSON_PATH = join(tmpdir(), 'native-image-build-output.json')
|
||||
const BYTES_TO_KiB = 1024
|
||||
@@ -19,6 +19,7 @@ const NATIVE_IMAGE_CONFIG_FILE = join(
|
||||
tmpdir(),
|
||||
'native-image-options.properties'
|
||||
)
|
||||
const NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS'
|
||||
const NATIVE_IMAGE_CONFIG_FILE_ENV = 'NATIVE_IMAGE_CONFIG_FILE'
|
||||
|
||||
interface AnalysisResult {
|
||||
@@ -91,6 +92,7 @@ interface BuildOutput {
|
||||
|
||||
export async function setUpNativeImageBuildReports(
|
||||
isGraalVMforJDK17OrLater: boolean,
|
||||
javaVersionOrDev: string,
|
||||
graalVMVersion: string
|
||||
): Promise<void> {
|
||||
const isRequired = areJobReportsEnabled() || arePRReportsEnabled()
|
||||
@@ -102,7 +104,7 @@ export async function setUpNativeImageBuildReports(
|
||||
graalVMVersion === c.VERSION_LATEST ||
|
||||
graalVMVersion === c.VERSION_DEV ||
|
||||
(!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) &&
|
||||
gte(toSemVer(graalVMVersion), '22.2.0'))
|
||||
semver.gte(toSemVer(graalVMVersion), '22.2.0'))
|
||||
if (!isSupported) {
|
||||
core.warning(
|
||||
`Build reports for PRs and job summaries are only available in GraalVM 22.2.0 or later. This build job uses GraalVM ${graalVMVersion}.`
|
||||
@@ -110,6 +112,7 @@ export async function setUpNativeImageBuildReports(
|
||||
return
|
||||
}
|
||||
setNativeImageOption(
|
||||
javaVersionOrDev,
|
||||
`-H:BuildOutputJSONFile=${BUILD_OUTPUT_JSON_PATH.replace(/\\/g, '\\\\')}`
|
||||
) // Escape backslashes for Windows
|
||||
}
|
||||
@@ -144,6 +147,34 @@ function arePRReportsEnabled(): boolean {
|
||||
return isPREvent() && core.getInput(INPUT_NI_PR_REPORTS) === 'true'
|
||||
}
|
||||
|
||||
function setNativeImageOption(
|
||||
javaVersionOrDev: string,
|
||||
optionValue: string
|
||||
): void {
|
||||
const coercedJavaVersionOrDev = semver.coerce(javaVersionOrDev)
|
||||
if (
|
||||
(coercedJavaVersionOrDev &&
|
||||
semver.gte(coercedJavaVersionOrDev, '22.0.0')) ||
|
||||
javaVersionOrDev === c.VERSION_DEV ||
|
||||
javaVersionOrDev.endsWith('-ea')
|
||||
) {
|
||||
/* NATIVE_IMAGE_OPTIONS was introduced in GraalVM for JDK 22 (so were EA builds). */
|
||||
let newOptionValue = optionValue
|
||||
const existingOptions = process.env[NATIVE_IMAGE_OPTIONS_ENV]
|
||||
if (existingOptions) {
|
||||
newOptionValue = `${existingOptions} ${newOptionValue}`
|
||||
}
|
||||
core.exportVariable(NATIVE_IMAGE_OPTIONS_ENV, newOptionValue)
|
||||
} else {
|
||||
const optionsFile = getNativeImageOptionsFile()
|
||||
if (fs.existsSync(optionsFile)) {
|
||||
fs.appendFileSync(optionsFile, ` ${optionValue}`)
|
||||
} else {
|
||||
fs.writeFileSync(optionsFile, `NativeImageArgs = ${optionValue}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getNativeImageOptionsFile(): string {
|
||||
let optionsFile = process.env[NATIVE_IMAGE_CONFIG_FILE_ENV]
|
||||
if (optionsFile === undefined) {
|
||||
@@ -153,15 +184,6 @@ function getNativeImageOptionsFile(): string {
|
||||
return optionsFile
|
||||
}
|
||||
|
||||
function setNativeImageOption(value: string): void {
|
||||
const optionsFile = getNativeImageOptionsFile()
|
||||
if (fs.existsSync(optionsFile)) {
|
||||
fs.appendFileSync(optionsFile, ` ${value}`)
|
||||
} else {
|
||||
fs.writeFileSync(optionsFile, `NativeImageArgs = ${value}`)
|
||||
}
|
||||
}
|
||||
|
||||
function createReport(data: BuildOutput): string {
|
||||
const context = github.context
|
||||
const info = data.general_info
|
||||
@@ -369,8 +391,8 @@ function createReport(data: BuildOutput): string {
|
||||
details.total_bytes
|
||||
)}</td>
|
||||
<td align="left">${objectCount}${bytesToHuman(
|
||||
details.image_heap.resources.bytes
|
||||
)} for ${details.image_heap.resources.count.toLocaleString()} resources</td>
|
||||
details.image_heap.resources.bytes
|
||||
)} for ${details.image_heap.resources.count.toLocaleString()} resources</td>
|
||||
</tr>${debugInfoLine}
|
||||
<tr>
|
||||
<td align="left"><a href="${DOCS_BASE}#glossary-other-data" target="_blank">Other data</a></td>
|
||||
@@ -404,16 +426,16 @@ function createReport(data: BuildOutput): string {
|
||||
<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>
|
||||
|
||||
@@ -6,8 +6,7 @@ import * as io from '@actions/io'
|
||||
import * as path from 'path'
|
||||
import * as stream from 'stream'
|
||||
import * as util from 'util'
|
||||
import {IHeaders} from '@actions/http-client/interfaces'
|
||||
import {IncomingHttpHeaders} from 'http'
|
||||
import {IncomingHttpHeaders, OutgoingHttpHeaders} from 'http'
|
||||
import {RetryHelper} from '@actions/tool-cache/lib/retry-helper'
|
||||
import {calculateSHA256} from './utils'
|
||||
import {ok} from 'assert'
|
||||
@@ -32,7 +31,7 @@ export async function downloadGraalVMEELegacy(
|
||||
version: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const userAgent = `GraalVMGitHubAction/1.1.4 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`
|
||||
const userAgent = `GraalVMGitHubAction/1.2.2 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`
|
||||
const baseArtifact = await fetchArtifact(
|
||||
userAgent,
|
||||
'isBase:True',
|
||||
@@ -132,7 +131,7 @@ class HTTPError extends Error {
|
||||
async function downloadTool(
|
||||
url: string,
|
||||
userAgent: string,
|
||||
headers?: IHeaders
|
||||
headers?: OutgoingHttpHeaders
|
||||
): Promise<string> {
|
||||
const dest = path.join(getTempDirectory(), uuidv4())
|
||||
await io.mkdirP(path.dirname(dest))
|
||||
@@ -169,7 +168,7 @@ async function downloadToolAttempt(
|
||||
url: string,
|
||||
userAgent: string,
|
||||
dest: string,
|
||||
headers?: IHeaders
|
||||
headers?: OutgoingHttpHeaders
|
||||
): Promise<string> {
|
||||
if (fs.existsSync(dest)) {
|
||||
throw new Error(`Destination file path ${dest} already exists`)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import * as c from './constants'
|
||||
import * as semver from 'semver'
|
||||
import {
|
||||
downloadAndExtractJDK,
|
||||
downloadExtractAndCacheJDK,
|
||||
getContents,
|
||||
getLatestRelease,
|
||||
getMatchingTags,
|
||||
getTaggedRelease
|
||||
@@ -9,10 +11,11 @@ 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-'
|
||||
@@ -25,19 +28,91 @@ export async function setUpGraalVMJDK(
|
||||
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||
return setUpGraalVMJDKDevBuild()
|
||||
}
|
||||
const javaVersion = javaVersionOrDev
|
||||
let javaVersion = javaVersionOrDev
|
||||
const toolName = determineToolName(javaVersion, false)
|
||||
let downloadName = toolName
|
||||
let downloadUrl: string
|
||||
if (javaVersion.includes('.')) {
|
||||
const majorJavaVersion = javaVersion.split('.')[0]
|
||||
downloadUrl = `${GRAALVM_DL_BASE}/${majorJavaVersion}/archive/${toolName}${c.GRAALVM_FILE_EXTENSION}`
|
||||
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}`
|
||||
)
|
||||
}
|
||||
} 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> {
|
||||
@@ -63,6 +138,8 @@ export async function findLatestGraalVMJDKCEJavaVersion(
|
||||
majorJavaVersion: string
|
||||
): Promise<string> {
|
||||
const matchingRefs = await getMatchingTags(
|
||||
c.GRAALVM_GH_USER,
|
||||
c.GRAALVM_RELEASES_REPO,
|
||||
`${GRAALVM_JDK_TAG_PREFIX}${majorJavaVersion}`
|
||||
)
|
||||
const lowestNonExistingVersion = '0.0.1'
|
||||
@@ -71,8 +148,8 @@ export async function findLatestGraalVMJDKCEJavaVersion(
|
||||
for (const matchingRef of matchingRefs) {
|
||||
const currentVersion = matchingRef.ref.substring(versionNumberStartIndex)
|
||||
if (
|
||||
semverValid(currentVersion) &&
|
||||
semverGt(currentVersion, highestVersion)
|
||||
semver.valid(currentVersion) &&
|
||||
semver.gt(currentVersion, highestVersion)
|
||||
) {
|
||||
highestVersion = currentVersion
|
||||
}
|
||||
@@ -169,6 +246,7 @@ export async function setUpGraalVMLatest_22_X(
|
||||
return setUpGraalVMRelease(gdsToken, lockedVersion, javaVersion)
|
||||
}
|
||||
const latestRelease = await getTaggedRelease(
|
||||
c.GRAALVM_GH_USER,
|
||||
c.GRAALVM_RELEASES_REPO,
|
||||
GRAALVM_TAG_PREFIX + lockedVersion
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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'
|
||||
import {gte as semverGte, valid as semverValid} from 'semver'
|
||||
|
||||
const BASE_FLAGS = ['--non-interactive', 'install', '--no-progress']
|
||||
const COMPONENT_TO_POST_INSTALL_HOOK = new Map<string, Map<string, string>>([
|
||||
@@ -34,10 +34,11 @@ export async function setUpGUComponents(
|
||||
if (components.length == 0) {
|
||||
return // nothing to do
|
||||
}
|
||||
const coercedJavaVersion = semver.coerce(javaVersion)
|
||||
if (
|
||||
graalVMVersion === c.VERSION_DEV ||
|
||||
javaVersion === c.VERSION_DEV ||
|
||||
(semverValid(javaVersion) && semverGte(javaVersion, '21.0.0'))
|
||||
(coercedJavaVersion != null && semver.gte(coercedJavaVersion, '21.0.0'))
|
||||
) {
|
||||
if (components.length == 1 && components[0] === 'native-image') {
|
||||
core.warning(
|
||||
|
||||
119
src/liberica.ts
Normal file
119
src/liberica.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
import * as c from './constants'
|
||||
import * as semver from 'semver'
|
||||
import {
|
||||
downloadExtractAndCacheJDK,
|
||||
getTaggedRelease,
|
||||
getMatchingTags
|
||||
} from './utils'
|
||||
import {downloadTool} from '@actions/tool-cache'
|
||||
import {spawnSync} from 'child_process'
|
||||
|
||||
const LIBERICA_GH_USER = 'bell-sw'
|
||||
const LIBERICA_RELEASES_REPO = 'LibericaNIK'
|
||||
const LIBERICA_JDK_TAG_PREFIX = 'jdk-'
|
||||
const LIBERICA_VM_PREFIX = 'bellsoft-liberica-vm-'
|
||||
|
||||
export async function setUpLiberica(
|
||||
javaVersion: string,
|
||||
javaPackage: string
|
||||
): Promise<string> {
|
||||
const resolvedJavaVersion = await findLatestLibericaJavaVersion(javaVersion)
|
||||
const downloadUrl = await findLibericaURL(resolvedJavaVersion, javaPackage)
|
||||
const toolName = determineToolName(javaVersion, javaPackage)
|
||||
return downloadExtractAndCacheJDK(
|
||||
async () => downloadTool(downloadUrl),
|
||||
toolName,
|
||||
javaVersion
|
||||
)
|
||||
}
|
||||
|
||||
export async function findLatestLibericaJavaVersion(
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const matchingRefs = await getMatchingTags(
|
||||
LIBERICA_GH_USER,
|
||||
LIBERICA_RELEASES_REPO,
|
||||
`${LIBERICA_JDK_TAG_PREFIX}${javaVersion}`
|
||||
)
|
||||
const noMatch = '0.0.1'
|
||||
let bestMatch = noMatch
|
||||
const prefixLength = `refs/tags/${LIBERICA_JDK_TAG_PREFIX}`.length
|
||||
const patternLength = javaVersion.length
|
||||
for (const matchingRef of matchingRefs) {
|
||||
const version = matchingRef.ref.substring(prefixLength)
|
||||
if (
|
||||
semver.valid(version) &&
|
||||
// pattern '17.0.1' should match '17.0.1+12' but not '17.0.10'
|
||||
(version.length <= patternLength ||
|
||||
!isDigit(version.charAt(patternLength))) &&
|
||||
semver.compareBuild(version, bestMatch) == 1
|
||||
) {
|
||||
bestMatch = version
|
||||
}
|
||||
}
|
||||
if (bestMatch === noMatch) {
|
||||
throw new Error(
|
||||
`Unable to find the latest version for JDK${javaVersion}. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`
|
||||
)
|
||||
}
|
||||
return bestMatch
|
||||
}
|
||||
|
||||
export async function findLibericaURL(
|
||||
javaVersion: string,
|
||||
javaPackage: string
|
||||
): Promise<string> {
|
||||
const release = await getTaggedRelease(
|
||||
LIBERICA_GH_USER,
|
||||
LIBERICA_RELEASES_REPO,
|
||||
LIBERICA_JDK_TAG_PREFIX + javaVersion
|
||||
)
|
||||
const platform = determinePlatformPart()
|
||||
const assetPrefix = `${LIBERICA_VM_PREFIX}${determineVariantPart(
|
||||
javaPackage
|
||||
)}openjdk${javaVersion}`
|
||||
const assetSuffix = `-${platform}${c.GRAALVM_FILE_EXTENSION}`
|
||||
for (const asset of release.assets) {
|
||||
if (
|
||||
asset.name.startsWith(assetPrefix) &&
|
||||
asset.name.endsWith(assetSuffix)
|
||||
) {
|
||||
return asset.browser_download_url
|
||||
}
|
||||
}
|
||||
throw new Error(
|
||||
`Unable to find asset for java-version: ${javaVersion}, java-package: ${javaPackage}, platform: ${platform}. ${c.ERROR_REQUEST}`
|
||||
)
|
||||
}
|
||||
|
||||
function determineToolName(javaVersion: string, javaPackage: string) {
|
||||
const variant = determineVariantPart(javaPackage)
|
||||
const platform = determinePlatformPart()
|
||||
return `${LIBERICA_VM_PREFIX}${variant}${platform}`
|
||||
}
|
||||
|
||||
function determineVariantPart(javaPackage: string) {
|
||||
return javaPackage !== null && javaPackage.includes('+fx') ? 'full-' : ''
|
||||
}
|
||||
|
||||
function determinePlatformPart() {
|
||||
if (isMuslBasedLinux()) {
|
||||
return `linux-${c.JDK_ARCH}-musl`
|
||||
} else {
|
||||
return `${c.JDK_PLATFORM}-${c.GRAALVM_ARCH}`
|
||||
}
|
||||
}
|
||||
|
||||
function isMuslBasedLinux() {
|
||||
if (c.IS_LINUX) {
|
||||
const output = spawnSync('ldd', ['--version']).stderr.toString('utf8')
|
||||
if (output.includes('musl')) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function isDigit(c: string) {
|
||||
return c.charAt(0) >= '0' && c.charAt(0) <= '9'
|
||||
}
|
||||
52
src/main.ts
52
src/main.ts
@@ -3,19 +3,22 @@ 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'
|
||||
import {setUpMandrel} from './mandrel'
|
||||
import {setUpLiberica} from './liberica'
|
||||
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 javaPackage = core.getInput(c.INPUT_JAVA_PACKAGE)
|
||||
const distribution = core.getInput(c.INPUT_DISTRIBUTION)
|
||||
const graalVMVersion = core.getInput(c.INPUT_VERSION)
|
||||
const gdsToken = core.getInput(c.INPUT_GDS_TOKEN)
|
||||
@@ -29,9 +32,15 @@ async function run(): Promise<void> {
|
||||
const enableCheckForUpdates =
|
||||
core.getInput(c.INPUT_CHECK_FOR_UPDATES) === 'true'
|
||||
const enableNativeImageMusl = core.getInput(c.INPUT_NI_MUSL) === 'true'
|
||||
const isGraalVMforJDK17OrLater =
|
||||
distribution.length > 0 || graalVMVersion.length == 0
|
||||
|
||||
if (c.IS_WINDOWS) {
|
||||
setUpWindowsEnvironment(graalVMVersion)
|
||||
setUpWindowsEnvironment(
|
||||
javaVersion,
|
||||
graalVMVersion,
|
||||
isGraalVMforJDK17OrLater
|
||||
)
|
||||
}
|
||||
await setUpDependencies(components)
|
||||
if (enableNativeImageMusl) {
|
||||
@@ -39,10 +48,15 @@ async function run(): Promise<void> {
|
||||
}
|
||||
|
||||
// Download GraalVM JDK
|
||||
const isGraalVMforJDK17OrLater =
|
||||
distribution.length > 0 || graalVMVersion.length == 0
|
||||
let graalVMHome
|
||||
if (isGraalVMforJDK17OrLater) {
|
||||
if (
|
||||
enableCheckForUpdates &&
|
||||
(distribution === c.DISTRIBUTION_GRAALVM ||
|
||||
distribution === c.DISTRIBUTION_GRAALVM_COMMUNITY)
|
||||
) {
|
||||
checkForUpdates(graalVMVersion, javaVersion)
|
||||
}
|
||||
switch (distribution) {
|
||||
case c.DISTRIBUTION_GRAALVM:
|
||||
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||
@@ -51,13 +65,10 @@ async function run(): Promise<void> {
|
||||
graalVMHome = await graalvm.setUpGraalVMJDKCE(javaVersion)
|
||||
break
|
||||
case c.DISTRIBUTION_MANDREL:
|
||||
if (graalVMVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||
graalVMHome = await setUpMandrel(graalVMVersion, javaVersion)
|
||||
} else {
|
||||
throw new Error(
|
||||
`Mandrel requires the 'version' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
||||
)
|
||||
}
|
||||
graalVMHome = await setUpMandrel(graalVMVersion, javaVersion)
|
||||
break
|
||||
case c.DISTRIBUTION_LIBERICA:
|
||||
graalVMHome = await setUpLiberica(javaVersion, javaPackage)
|
||||
break
|
||||
case '':
|
||||
if (javaVersion === c.VERSION_DEV) {
|
||||
@@ -76,11 +87,13 @@ async function run(): Promise<void> {
|
||||
throw new Error(`Unsupported distribution: ${distribution}`)
|
||||
}
|
||||
} else {
|
||||
const coercedJavaVersion = semver.coerce(javaVersion)
|
||||
switch (graalVMVersion) {
|
||||
case c.VERSION_LATEST:
|
||||
if (
|
||||
javaVersion.startsWith('17') ||
|
||||
(semver.valid(javaVersion) && semver.gte(javaVersion, '20.0.0'))
|
||||
(coercedJavaVersion !== null &&
|
||||
semver.gte(coercedJavaVersion, '20.0.0'))
|
||||
) {
|
||||
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).`
|
||||
@@ -99,7 +112,6 @@ async function run(): Promise<void> {
|
||||
'Downloading GraalVM EE dev builds is not supported'
|
||||
)
|
||||
}
|
||||
const coercedJavaVersion = semver.coerce(javaVersion)
|
||||
if (
|
||||
coercedJavaVersion !== null &&
|
||||
!semver.gte(coercedJavaVersion, '21.0.0')
|
||||
@@ -117,7 +129,7 @@ async function run(): Promise<void> {
|
||||
graalVMHome = await setUpMandrel(graalVMVersion, javaVersion)
|
||||
} else {
|
||||
if (enableCheckForUpdates) {
|
||||
await checkForUpdates(graalVMVersion, javaVersion)
|
||||
checkForUpdates(graalVMVersion, javaVersion)
|
||||
}
|
||||
graalVMHome = await graalvm.setUpGraalVMRelease(
|
||||
gdsToken,
|
||||
@@ -148,7 +160,17 @@ async function run(): Promise<void> {
|
||||
if (cache && isCacheAvailable()) {
|
||||
await restore(cache)
|
||||
}
|
||||
setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion)
|
||||
setUpNativeImageBuildReports(
|
||||
isGraalVMforJDK17OrLater,
|
||||
javaVersion,
|
||||
graalVMVersion
|
||||
)
|
||||
|
||||
core.startGroup(`Successfully set up '${basename(graalVMHome)}'`)
|
||||
await exec(join(graalVMHome, 'bin', `java${c.EXECUTABLE_SUFFIX}`), [
|
||||
javaVersion.startsWith('8') ? '-version' : '--version'
|
||||
])
|
||||
core.endGroup()
|
||||
} catch (error) {
|
||||
if (error instanceof Error) core.setFailed(error.message)
|
||||
}
|
||||
|
||||
139
src/mandrel.ts
139
src/mandrel.ts
@@ -1,27 +1,33 @@
|
||||
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'
|
||||
|
||||
const MANDREL_REPO = 'mandrel'
|
||||
const MANDREL_TAG_PREFIX = c.MANDREL_NAMESPACE
|
||||
export const MANDREL_REPO = 'mandrel'
|
||||
export 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(
|
||||
graalvmVersion: string,
|
||||
mandrelVersion: string,
|
||||
javaVersion: string
|
||||
): Promise<string> {
|
||||
const mandrelVersion = graalvmVersion.substring(
|
||||
c.MANDREL_NAMESPACE.length,
|
||||
graalvmVersion.length
|
||||
)
|
||||
|
||||
const version = stripMandrelNamespace(mandrelVersion)
|
||||
let mandrelHome
|
||||
switch (mandrelVersion) {
|
||||
switch (version) {
|
||||
case '':
|
||||
// fetch latest if no version is specified
|
||||
case 'latest':
|
||||
mandrelHome = await setUpMandrelLatest(javaVersion)
|
||||
break
|
||||
default:
|
||||
mandrelHome = await setUpMandrelRelease(mandrelVersion, javaVersion)
|
||||
mandrelHome = await setUpMandrelRelease(version, javaVersion)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -29,32 +35,110 @@ export async function setUpMandrel(
|
||||
}
|
||||
|
||||
async function setUpMandrelLatest(javaVersion: string): Promise<string> {
|
||||
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)
|
||||
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}`
|
||||
)
|
||||
}
|
||||
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 () => downloadTool(downloadUrl),
|
||||
async () => downloadMandrelJDK(version, javaVersion),
|
||||
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
|
||||
@@ -65,3 +149,14 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
30
src/msvc.ts
30
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,9 +28,32 @@ function findVcvarsallPath(): string {
|
||||
throw new Error('Failed to find vcvarsall.bat')
|
||||
}
|
||||
|
||||
export function setUpWindowsEnvironment(graalVMVersion: string): void {
|
||||
if (graalVMVersion === VERSION_DEV) {
|
||||
return // no longer required in dev builds
|
||||
export function needsWindowsEnvironmentSetup(
|
||||
javaVersion: string,
|
||||
graalVMVersion: string,
|
||||
isGraalVMforJDK17OrLater: boolean
|
||||
): boolean {
|
||||
if (javaVersion === VERSION_DEV || graalVMVersion === VERSION_DEV) {
|
||||
return false // no longer required in dev builds
|
||||
} else if (isGraalVMforJDK17OrLater) {
|
||||
return false // no longer required in GraalVM for JDK 17 and later.
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
export function setUpWindowsEnvironment(
|
||||
javaVersion: string,
|
||||
graalVMVersion: string,
|
||||
isGraalVMforJDK17OrLater: boolean
|
||||
): void {
|
||||
if (
|
||||
!needsWindowsEnvironmentSetup(
|
||||
javaVersion,
|
||||
graalVMVersion,
|
||||
isGraalVMforJDK17OrLater
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
core.startGroup('Updating Windows environment...')
|
||||
|
||||
52
src/utils.ts
52
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,7 +48,24 @@ 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(
|
||||
owner: string,
|
||||
repo: string,
|
||||
tag: string
|
||||
): Promise<c.LatestReleaseResponse['data']> {
|
||||
@@ -56,7 +74,7 @@ export async function getTaggedRelease(
|
||||
const octokit = new GitHubDotCom(options)
|
||||
return (
|
||||
await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
owner,
|
||||
repo,
|
||||
tag
|
||||
})
|
||||
@@ -64,6 +82,8 @@ export async function getTaggedRelease(
|
||||
}
|
||||
|
||||
export async function getMatchingTags(
|
||||
owner: string,
|
||||
repo: string,
|
||||
tagPrefix: string
|
||||
): Promise<c.MatchingRefsResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
@@ -73,8 +93,8 @@ export async function getMatchingTags(
|
||||
await octokit.request(
|
||||
'GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}',
|
||||
{
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo: c.GRAALVM_RELEASES_REPO,
|
||||
owner,
|
||||
repo,
|
||||
tagPrefix
|
||||
}
|
||||
)
|
||||
@@ -135,17 +155,25 @@ function findJavaHomeInSubfolder(searchPath: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper turns GraalVM version numbers (e.g., `22.0.0.2`) into valid
|
||||
* semver.org versions (e.g., `22.0.0-2`), which is needed because
|
||||
* @actions/tool-cache uses `semver` to validate versions.
|
||||
*/
|
||||
export function toSemVer(version: string): string {
|
||||
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