Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52b9a9b316 | ||
|
|
435d2b356f | ||
|
|
6bd874f0ca | ||
|
|
be3e4f6272 | ||
|
|
fc45baf59f | ||
|
|
17d64df2bb | ||
|
|
78f22073df | ||
|
|
b11d36630f | ||
|
|
babc303d7e | ||
|
|
5f2753d6bc | ||
|
|
6acd592e3e | ||
|
|
cf001e2d43 | ||
|
|
90a2c32c8b | ||
|
|
4297237826 | ||
|
|
c85a448ca4 | ||
|
|
c8fdb59e88 | ||
|
|
40947ba8ce | ||
|
|
4356481765 | ||
|
|
8b27096bbf | ||
|
|
93d8fee7fa | ||
|
|
76d605752b | ||
|
|
b53bc17dd7 | ||
|
|
d01f5f519f | ||
|
|
4aba115fa5 | ||
|
|
7c84ab1ba7 |
356
.github/workflows/test.yml
vendored
356
.github/workflows/test.yml
vendored
@@ -12,133 +12,197 @@ permissions:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# build: # make sure build/ci work properly
|
build: # make sure build/ci work properly
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
steps:
|
||||||
# - uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
# - run: |
|
- run: |
|
||||||
# npm install
|
npm install
|
||||||
# - run: |
|
- run: |
|
||||||
# npm run all
|
npm run all
|
||||||
# test-ce: # make sure the action works on a clean machine without building
|
test:
|
||||||
# name: CE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
name: GraalVM
|
||||||
# runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
# strategy:
|
strategy:
|
||||||
# matrix:
|
matrix:
|
||||||
# version: [latest, dev]
|
java-version: ['17', '20', 'dev']
|
||||||
# java-version: ['17', '19']
|
distribution: ['graalvm', 'graalvm-community']
|
||||||
# components: ['native-image']
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
# os: [macos-latest, windows-latest, ubuntu-latest]
|
steps:
|
||||||
# include:
|
- uses: actions/checkout@v3
|
||||||
# - version: '22.2.0' # for update notifications
|
- name: Run setup-graalvm action
|
||||||
# java-version: '17'
|
uses: ./
|
||||||
# components: 'native-image'
|
with:
|
||||||
# os: ubuntu-18.04
|
java-version: ${{ matrix.java-version }}
|
||||||
# - version: '22.3.0'
|
distribution: ${{ matrix.distribution }}
|
||||||
# java-version: '11' # for JDK11 notification
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# components: 'native-image'
|
- name: Check environment
|
||||||
# os: macos-11
|
run: |
|
||||||
# - version: '22.3.0'
|
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
||||||
# java-version: '17'
|
if [[ "${{ matrix.java-version }}" == "dev" ]]; then
|
||||||
# components: 'native-image'
|
[[ "$GRAALVM_HOME" == *"$RUNNER_TEMP"* ]] || exit 12
|
||||||
# os: windows-2022
|
else
|
||||||
# steps:
|
[[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23
|
||||||
# - uses: actions/checkout@v3
|
fi
|
||||||
# - name: Run setup-graalvm action
|
echo "JAVA_HOME: $JAVA_HOME"
|
||||||
# uses: ./
|
java --version
|
||||||
# with:
|
java --version | grep "GraalVM" || exit 34
|
||||||
# version: ${{ matrix.version }}
|
native-image --version
|
||||||
# java-version: ${{ matrix.java-version }}
|
if: runner.os != 'Windows'
|
||||||
# components: ${{ matrix.components }}
|
- name: Check Windows environment
|
||||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
run: |
|
||||||
# - name: Check environment
|
echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
||||||
# run: |
|
echo "JAVA_HOME: $env:JAVA_HOME"
|
||||||
# echo "GRAALVM_HOME: $GRAALVM_HOME"
|
java --version
|
||||||
# if [[ "${{ matrix.version }}" == "dev" ]]; then
|
native-image --version
|
||||||
# [[ "$GRAALVM_HOME" == *"$RUNNER_TEMP"* ]] || exit 12
|
test-ce: # make sure the action works on a clean machine without building
|
||||||
# else
|
needs: test
|
||||||
# [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23
|
name: CE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
||||||
# fi
|
runs-on: ${{ matrix.os }}
|
||||||
# echo "JAVA_HOME: $JAVA_HOME"
|
strategy:
|
||||||
# java --version
|
matrix:
|
||||||
# java --version | grep "GraalVM CE" || exit 34
|
version: ['latest', 'dev']
|
||||||
# native-image --version
|
java-version: ['17', '20']
|
||||||
# if: runner.os != 'Windows'
|
components: ['native-image']
|
||||||
# - name: Check Windows environment
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
# run: |
|
exclude:
|
||||||
# echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
- version: 'latest'
|
||||||
# echo "JAVA_HOME: $env:JAVA_HOME"
|
java-version: '20'
|
||||||
# java --version
|
- version: 'dev'
|
||||||
# native-image --version
|
java-version: '19'
|
||||||
# if: runner.os == 'Windows'
|
include:
|
||||||
# test-ee:
|
- version: '22.2.0' # for update notifications
|
||||||
# name: EE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
java-version: '17'
|
||||||
# if: github.event_name != 'pull_request'
|
components: 'native-image'
|
||||||
# runs-on: ${{ matrix.os }}
|
os: ubuntu-20.04
|
||||||
# strategy:
|
- version: '22.3.1'
|
||||||
# matrix:
|
java-version: '11' # for JDK11 notification
|
||||||
# version: ['22.3.0', 'latest']
|
components: 'native-image'
|
||||||
# java-version: ['11', '17', '19']
|
os: macos-11
|
||||||
# components: ['native-image']
|
- version: '22.3.1'
|
||||||
# os: [macos-latest, windows-latest, ubuntu-latest]
|
java-version: '17'
|
||||||
# steps:
|
components: 'native-image'
|
||||||
# - uses: actions/checkout@v3
|
os: windows-2022
|
||||||
# - name: Run setup-graalvm action
|
- version: 'dev'
|
||||||
# uses: ./
|
java-version: 'dev'
|
||||||
# with:
|
components: 'native-image'
|
||||||
# version: ${{ matrix.version }}
|
os: ubuntu-latest
|
||||||
# gds-token: ${{ secrets.GDS_TOKEN }}
|
steps:
|
||||||
# java-version: ${{ matrix.java-version }}
|
- uses: actions/checkout@v3
|
||||||
# components: ${{ matrix.components }}
|
- name: Run setup-graalvm action
|
||||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
uses: ./
|
||||||
# - name: Check environment
|
with:
|
||||||
# run: |
|
version: ${{ matrix.version }}
|
||||||
# echo "GRAALVM_HOME: $GRAALVM_HOME"
|
java-version: ${{ matrix.java-version }}
|
||||||
# [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12
|
components: ${{ matrix.components }}
|
||||||
# echo "JAVA_HOME: $JAVA_HOME"
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# java --version
|
- name: Check environment
|
||||||
# java --version | grep "GraalVM EE" || exit 23
|
run: |
|
||||||
# native-image --version
|
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
||||||
# if: runner.os != 'Windows'
|
if [[ "${{ matrix.version }}" == "dev" ]]; then
|
||||||
# - name: Check Windows environment
|
[[ "$GRAALVM_HOME" == *"$RUNNER_TEMP"* ]] || exit 12
|
||||||
# run: |
|
else
|
||||||
# echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
[[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 23
|
||||||
# echo "JAVA_HOME: $env:JAVA_HOME"
|
fi
|
||||||
# java --version
|
echo "JAVA_HOME: $JAVA_HOME"
|
||||||
# native-image --version
|
java --version
|
||||||
# if: runner.os == 'Windows'
|
java --version | grep "GraalVM" || exit 34
|
||||||
# test-mandrel:
|
native-image --version
|
||||||
# name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
gu list
|
||||||
# runs-on: ${{ matrix.os }}
|
if: runner.os != 'Windows'
|
||||||
# strategy:
|
- name: Check Windows environment
|
||||||
# matrix:
|
run: |
|
||||||
# version: ['mandrel-22.2.0.0-Final', 'mandrel-latest']
|
echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
||||||
# java-version: ['17']
|
echo "JAVA_HOME: $env:JAVA_HOME"
|
||||||
# os: [windows-latest, ubuntu-latest]
|
java --version
|
||||||
# steps:
|
native-image --version
|
||||||
# - uses: actions/checkout@v3
|
gu.cmd remove native-image
|
||||||
# - name: Run setup-graalvm action
|
if: runner.os == 'Windows'
|
||||||
# uses: ./
|
test-ee:
|
||||||
# with:
|
needs: test
|
||||||
# version: ${{ matrix.version }}
|
name: EE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
||||||
# java-version: ${{ matrix.java-version }}
|
if: github.event_name != 'pull_request'
|
||||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
runs-on: ${{ matrix.os }}
|
||||||
# - name: Check environment
|
strategy:
|
||||||
# run: |
|
matrix:
|
||||||
# echo "GRAALVM_HOME: $GRAALVM_HOME"
|
version: ['latest']
|
||||||
# [[ "$GRAALVM_HOME" == *"$RUNNER_TOOL_CACHE"* ]] || exit 12
|
java-version: ['19']
|
||||||
# echo "JAVA_HOME: $JAVA_HOME"
|
components: ['native-image']
|
||||||
# java --version
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
# native-image --version
|
include:
|
||||||
# if: runner.os != 'Windows'
|
- version: '22.3.0'
|
||||||
# - name: Check Windows environment
|
java-version: '11'
|
||||||
# run: |
|
components: 'native-image'
|
||||||
# echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
os: ubuntu-latest
|
||||||
# echo "JAVA_HOME: $env:JAVA_HOME"
|
- version: '22.3.0'
|
||||||
# java --version
|
java-version: '17'
|
||||||
# native-image --version
|
components: 'native-image'
|
||||||
# if: runner.os == 'Windows'
|
os: ubuntu-latest
|
||||||
test-native-image-msvc:
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Run setup-graalvm action
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
gds-token: ${{ secrets.GDS_TOKEN }}
|
||||||
|
java-version: ${{ matrix.java-version }}
|
||||||
|
components: ${{ matrix.components }}
|
||||||
|
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 | grep "GraalVM EE" || exit 23
|
||||||
|
native-image --version
|
||||||
|
gu list
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
- name: Check Windows environment
|
||||||
|
run: |
|
||||||
|
echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
||||||
|
echo "JAVA_HOME: $env:JAVA_HOME"
|
||||||
|
java --version
|
||||||
|
native-image --version
|
||||||
|
gu.cmd remove native-image
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
test-mandrel:
|
||||||
|
needs: test
|
||||||
|
name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: ['mandrel-22.2.0.0-Final', 'mandrel-latest']
|
||||||
|
java-version: ['17']
|
||||||
|
os: [windows-latest, ubuntu-latest]
|
||||||
|
exclude: # temporarily disable Mandrel latest builds on Windows due to unavailability
|
||||||
|
- version: 'mandrel-latest'
|
||||||
|
java-version: '17'
|
||||||
|
os: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Run setup-graalvm action
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
java-version: ${{ matrix.java-version }}
|
||||||
|
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
|
||||||
|
native-image --version
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
- name: Check Windows environment
|
||||||
|
run: |
|
||||||
|
echo "GRAALVM_HOME: $env:GRAALVM_HOME"
|
||||||
|
echo "JAVA_HOME: $env:JAVA_HOME"
|
||||||
|
java --version
|
||||||
|
native-image --version
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
test-native-image-windows:
|
||||||
name: native-image on windows-latest
|
name: native-image on windows-latest
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
permissions:
|
permissions:
|
||||||
@@ -149,9 +213,30 @@ jobs:
|
|||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 'latest'
|
java-version: 'dev'
|
||||||
|
distribution: 'graalvm-community'
|
||||||
|
native-image-job-reports: 'true'
|
||||||
|
native-image-pr-reports: 'true'
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Build HelloWorld executable with GraalVM Native Image on Windows
|
||||||
|
run: |
|
||||||
|
echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java
|
||||||
|
javac HelloWorld.java
|
||||||
|
native-image HelloWorld
|
||||||
|
./helloworld
|
||||||
|
test-native-image-windows-msvc:
|
||||||
|
name: native-image on windows-2022
|
||||||
|
runs-on: windows-2022
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write # for `native-image-pr-reports` option
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Run setup-graalvm action
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
components: 'native-image'
|
distribution: 'graalvm'
|
||||||
native-image-job-reports: 'true'
|
native-image-job-reports: 'true'
|
||||||
native-image-pr-reports: 'true'
|
native-image-pr-reports: 'true'
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -172,9 +257,8 @@ jobs:
|
|||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 'latest'
|
java-version: 'dev'
|
||||||
java-version: '19'
|
distribution: 'graalvm-community'
|
||||||
components: 'native-image'
|
|
||||||
native-image-musl: 'true'
|
native-image-musl: 'true'
|
||||||
native-image-job-reports: 'true'
|
native-image-job-reports: 'true'
|
||||||
native-image-pr-reports: 'true'
|
native-image-pr-reports: 'true'
|
||||||
@@ -196,9 +280,9 @@ jobs:
|
|||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 'dev'
|
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
components: 'espresso,llvm-toolchain,native-image,nodejs,python,R,ruby,wasm'
|
distribution: 'graalvm'
|
||||||
|
components: 'espresso,llvm-toolchain,native-image,nodejs,python,ruby,wasm'
|
||||||
set-java-home: 'false'
|
set-java-home: 'false'
|
||||||
native-image-job-reports: 'true'
|
native-image-job-reports: 'true'
|
||||||
native-image-pr-reports: 'true'
|
native-image-pr-reports: 'true'
|
||||||
@@ -219,8 +303,6 @@ jobs:
|
|||||||
[[ $(which node) == *"graalvm"* ]] || exit 45
|
[[ $(which node) == *"graalvm"* ]] || exit 45
|
||||||
node --version
|
node --version
|
||||||
graalpy --version
|
graalpy --version
|
||||||
[[ $(which R) == *"graalvm"* ]] || exit 56
|
|
||||||
R --version
|
|
||||||
truffleruby --version
|
truffleruby --version
|
||||||
wasm --version
|
wasm --version
|
||||||
- name: Build HelloWorld.java with GraalVM Native Image
|
- name: Build HelloWorld.java with GraalVM Native Image
|
||||||
@@ -240,3 +322,5 @@ jobs:
|
|||||||
bundle exec rake compile
|
bundle exec rake compile
|
||||||
bundle exec rake test
|
bundle exec rake test
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
- name: Remove components
|
||||||
|
run: gu remove espresso llvm-toolchain nodejs python ruby wasm
|
||||||
|
|||||||
102
README.md
102
README.md
@@ -1,18 +1,46 @@
|
|||||||
# GitHub Action for GraalVM [](https://github.com/graalvm/setup-graalvm/actions/workflows/test.yml)
|
# GitHub Action for GraalVM [](https://github.com/graalvm/setup-graalvm/actions/workflows/test.yml)
|
||||||
This GitHub action sets up GraalVM [Community Edition (CE)][repo] or [Enterprise Edition (EE)][graalvm-ee] as well as GraalVM components such as [Native Image][native-image] and [Truffle languages][truffle-languages].
|
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].
|
||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
This action:
|
This action:
|
||||||
|
|
||||||
- supports 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))
|
||||||
- has built-in support for GraalVM components and the [GraalVM Updater][gu]
|
|
||||||
- exports a `$GRAALVM_HOME` environment variable
|
- exports a `$GRAALVM_HOME` environment variable
|
||||||
- adds `$GRAALVM_HOME/bin` to the `$PATH` environment variable<br>(Truffle languages and tools can be invoked directly)
|
- 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))
|
- sets `$JAVA_HOME` to `$GRAALVM_HOME` by default<br>(can be disabled via `set-java-home: 'false'`, see [Options](#options))
|
||||||
- supports `amd64` and `aarch64` (selected automatically, `aarch64` requires a [self-hosted runner][gha-self-hosted-runners])
|
- supports `x64` and `aarch64` (selected automatically, `aarch64` requires a [self-hosted runner][gha-self-hosted-runners])
|
||||||
- sets up Windows environments with build tools using [vcvarsall.bat][vcvarsall]
|
|
||||||
- supports dependency caching for Apache Maven, Gradle, and sbt (see [`cache` option](#options))
|
- supports dependency caching for Apache Maven, Gradle, and sbt (see [`cache` option](#options))
|
||||||
|
- sets up Windows environments with build tools using [vcvarsall.bat][vcvarsall]
|
||||||
|
- 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
|
## Templates
|
||||||
@@ -20,7 +48,7 @@ This action:
|
|||||||
### Quickstart Template
|
### Quickstart Template
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
name: GraalVM Community Edition build
|
name: GraalVM build
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -29,17 +57,19 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: graalvm/setup-graalvm@v1
|
- uses: graalvm/setup-graalvm@v1
|
||||||
with:
|
with:
|
||||||
version: 'latest'
|
java-version: '17.0.7'
|
||||||
java-version: '17'
|
distribution: 'graalvm' # See 'Options' for all available distributions
|
||||||
components: 'native-image'
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Example step
|
- name: Example step
|
||||||
run: |
|
run: |
|
||||||
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
echo "GRAALVM_HOME: $GRAALVM_HOME"
|
||||||
echo "JAVA_HOME: $JAVA_HOME"
|
echo "JAVA_HOME: $JAVA_HOME"
|
||||||
java --version
|
java --version
|
||||||
gu --version
|
|
||||||
native-image --version
|
native-image --version
|
||||||
|
- name: Example step using Maven plugin # https://graalvm.github.io/native-build-tools/latest/maven-plugin.html
|
||||||
|
run: mvn -Pnative package
|
||||||
|
- name: Example step using Gradle plugin # https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html
|
||||||
|
run: gradlew nativeCompile
|
||||||
```
|
```
|
||||||
|
|
||||||
### Building a HelloWorld with GraalVM Native Image on Different Platforms
|
### Building a HelloWorld with GraalVM Native Image on Different Platforms
|
||||||
@@ -59,9 +89,8 @@ jobs:
|
|||||||
|
|
||||||
- uses: graalvm/setup-graalvm@v1
|
- uses: graalvm/setup-graalvm@v1
|
||||||
with:
|
with:
|
||||||
version: '22.3.0'
|
java-version: '17.0.7'
|
||||||
java-version: '17'
|
distribution: 'graalvm'
|
||||||
components: 'native-image'
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
native-image-job-reports: 'true'
|
native-image-job-reports: 'true'
|
||||||
|
|
||||||
@@ -79,7 +108,29 @@ jobs:
|
|||||||
path: helloworld*
|
path: helloworld*
|
||||||
```
|
```
|
||||||
|
|
||||||
### Basic GraalVM Enterprise Edition Template
|
<details>
|
||||||
|
<summary><h4>Template for older GraalVM releases</h4></summary>
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: GraalVM build
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: graalvm/setup-graalvm@v1
|
||||||
|
with:
|
||||||
|
version: '22.3.2' # GraalVM version
|
||||||
|
java-version: '17'
|
||||||
|
components: 'native-image'
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><h4>Template for GraalVM Enterprise Edition</h4></summary>
|
||||||
|
|
||||||
#### Prerequisites
|
#### Prerequisites
|
||||||
|
|
||||||
@@ -109,22 +160,24 @@ jobs:
|
|||||||
native-image --version
|
native-image --version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
| Name | Default | Description |
|
| Name | Default | Description |
|
||||||
|-----------------|:--------:|-------------|
|
|-----------------|:--------:|-------------|
|
||||||
| `version`<br>*(required)* | n/a | `X.Y.Z` (e.g., `22.3.0`) for a specific [GraalVM release][releases]<br>`latest` for [latest stable release][stable],<br>`dev` for [latest dev build][dev-build],<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]. |
|
| `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.) |
|
||||||
| `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](#basic-graalvm-enterprise-edition-template)). |
|
| `distribution` | `''` | GraalVM distribution (`graalvm` for Oracle GraalVM, `graalvm-community` for GraalVM Community Edition, `mandrel` for Mandrel). |
|
||||||
| `java-version`<br>*(required)* | n/a | `'17'` or `'19'` for a specific Java version.<br>(`'8'`, `'11'`, `'16'` are supported for older GraalVM releases.) |
|
| `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. |
|
||||||
| `components` | `''` | Comma-spearated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
|
|
||||||
| `github-token` | `''` | Token for communication with the GitHub API. Please set to `${{ secrets.GITHUB_TOKEN }}` (see [templates](#templates)) to allow the action to authenticate with the GitHub API, which helps to 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`. |
|
| `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. It can be `'maven'`, `'gradle'`, or `'sbt'` and works the same way as described in [actions/setup-java][setup-java-caching]. |
|
| `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]. |
|
||||||
| `check-for-updates` | `'true'` | [Annotate jobs][gha-annotations] with update notifications, for example, when a new GraalVM release is available. |
|
| `check-for-updates` | `'true'` | [Annotate jobs][gha-annotations] with update notifications, for example when a new GraalVM release is available. |
|
||||||
| `native-image-musl` | `'false'` | If set to `'true'`, sets up [musl] to build [static binaries][native-image-static] with GraalVM Native Image *(Linux only)*. [Example usage][native-image-musl-build] (be sure to replace `uses: ./` with `uses: graalvm/setup-graalvm@v1`). |
|
| `native-image-musl` | `'false'` | If set to `'true'`, sets up [musl] to build [static binaries][native-image-static] with GraalVM Native Image *(Linux only)*. [Example usage][native-image-musl-build] (be sure to replace `uses: ./` with `uses: graalvm/setup-graalvm@v1`). |
|
||||||
| `native-image-job-reports` *) | `'false'` | If set to `'true'`, post a job summary containing a Native Image build report. |
|
| `native-image-job-reports` *) | `'false'` | If set to `'true'`, post a job summary containing a Native Image build report. |
|
||||||
| `native-image-pr-reports` *) | `'false'` | If set to `'true'`, post a comment containing a Native Image build report on pull requests. Requires `write` permissions for the [`pull-requests` scope][gha-permissions]. |
|
| `native-image-pr-reports` *) | `'false'` | If set to `'true'`, post a comment containing a Native Image build report on pull requests. Requires `write` permissions for the [`pull-requests` scope][gha-permissions]. |
|
||||||
|
| `components` | `''` | Comma-separated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
|
||||||
|
| `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.*
|
**) Make sure that Native Image is used only once per build job. Otherwise, the report is only generated for the last Native Image build.*
|
||||||
|
|
||||||
@@ -143,6 +196,9 @@ Only pull requests from committers that can be verified as having signed the OCA
|
|||||||
[gha-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository
|
[gha-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository
|
||||||
[gha-self-hosted-runners]: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners
|
[gha-self-hosted-runners]: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners
|
||||||
[gu]: https://www.graalvm.org/reference-manual/graalvm-updater/
|
[gu]: https://www.graalvm.org/reference-manual/graalvm-updater/
|
||||||
|
[graalvm]: https://www.graalvm.org/
|
||||||
|
[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
|
[graalvm-ee]: https://www.oracle.com/downloads/graalvm-downloads.html
|
||||||
[mandrel]: https://github.com/graalvm/mandrel
|
[mandrel]: https://github.com/graalvm/mandrel
|
||||||
[mandrel-releases]: https://github.com/graalvm/mandrel/releases
|
[mandrel-releases]: https://github.com/graalvm/mandrel/releases
|
||||||
|
|||||||
379
__tests__/cache.test.ts
Normal file
379
__tests__/cache.test.ts
Normal file
@@ -0,0 +1,379 @@
|
|||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 GitHub, Inc. and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Forked from https://github.com/actions/setup-java/blob/5b36705a13905facb447b6812d613a06a07e371d/__tests__/cache.test.ts
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {mkdtempSync} from 'fs'
|
||||||
|
import {tmpdir} from 'os'
|
||||||
|
import {join} from 'path'
|
||||||
|
import {restore, save} from '../src/features/cache'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import * as os from 'os'
|
||||||
|
import * as core from '@actions/core'
|
||||||
|
import * as cache from '@actions/cache'
|
||||||
|
|
||||||
|
describe('dependency cache', () => {
|
||||||
|
const ORIGINAL_RUNNER_OS = process.env['RUNNER_OS']
|
||||||
|
const ORIGINAL_GITHUB_WORKSPACE = process.env['GITHUB_WORKSPACE']
|
||||||
|
const ORIGINAL_CWD = process.cwd()
|
||||||
|
let workspace: string
|
||||||
|
let spyInfo: jest.SpyInstance<void, Parameters<typeof core.info>>
|
||||||
|
let spyWarning: jest.SpyInstance<void, Parameters<typeof core.warning>>
|
||||||
|
let spyDebug: jest.SpyInstance<void, Parameters<typeof core.debug>>
|
||||||
|
let spySaveState: jest.SpyInstance<void, Parameters<typeof core.saveState>>
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
workspace = mkdtempSync(join(tmpdir(), 'setup-graalvm-cache-'))
|
||||||
|
switch (os.platform()) {
|
||||||
|
case 'darwin':
|
||||||
|
process.env['RUNNER_OS'] = 'macOS'
|
||||||
|
break
|
||||||
|
case 'win32':
|
||||||
|
process.env['RUNNER_OS'] = 'Windows'
|
||||||
|
break
|
||||||
|
case 'linux':
|
||||||
|
process.env['RUNNER_OS'] = 'Linux'
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
throw new Error(`unknown platform: ${os.platform()}`)
|
||||||
|
}
|
||||||
|
process.chdir(workspace)
|
||||||
|
// This hack is necessary because @actions/glob ignores files not in the GITHUB_WORKSPACE
|
||||||
|
// https://git.io/Jcxig
|
||||||
|
process.env['GITHUB_WORKSPACE'] = projectRoot(workspace)
|
||||||
|
})
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyInfo = jest.spyOn(core, 'info')
|
||||||
|
spyInfo.mockImplementation(() => null)
|
||||||
|
|
||||||
|
spyWarning = jest.spyOn(core, 'warning')
|
||||||
|
spyWarning.mockImplementation(() => null)
|
||||||
|
|
||||||
|
spyDebug = jest.spyOn(core, 'debug')
|
||||||
|
spyDebug.mockImplementation(() => null)
|
||||||
|
|
||||||
|
spySaveState = jest.spyOn(core, 'saveState')
|
||||||
|
spySaveState.mockImplementation(() => null)
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
process.chdir(ORIGINAL_CWD)
|
||||||
|
process.env['GITHUB_WORKSPACE'] = ORIGINAL_GITHUB_WORKSPACE
|
||||||
|
process.env['RUNNER_OS'] = ORIGINAL_RUNNER_OS
|
||||||
|
resetState()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('restore', () => {
|
||||||
|
let spyCacheRestore: jest.SpyInstance<
|
||||||
|
ReturnType<typeof cache.restoreCache>,
|
||||||
|
Parameters<typeof cache.restoreCache>
|
||||||
|
>
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyCacheRestore = jest
|
||||||
|
.spyOn(cache, 'restoreCache')
|
||||||
|
.mockImplementation((paths: string[], primaryKey: string) =>
|
||||||
|
Promise.resolve(undefined)
|
||||||
|
)
|
||||||
|
spyWarning.mockImplementation(() => null)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('throws error if unsupported package manager specified', () => {
|
||||||
|
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.toThrowError(
|
||||||
|
`No file in ${projectRoot(
|
||||||
|
workspace
|
||||||
|
)} matched to [**/pom.xml], make sure you have checked out the target repository`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
it('downloads cache', async () => {
|
||||||
|
createFile(join(workspace, 'pom.xml'))
|
||||||
|
|
||||||
|
await restore('maven')
|
||||||
|
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.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`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
it('downloads cache based on build.gradle', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle'))
|
||||||
|
|
||||||
|
await restore('gradle')
|
||||||
|
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).toBeCalled()
|
||||||
|
expect(spyWarning).not.toBeCalled()
|
||||||
|
expect(spyInfo).toBeCalledWith('gradle cache is not found')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('downloads cache based on buildSrc/Versions.kt', async () => {
|
||||||
|
createDirectory(join(workspace, 'buildSrc'))
|
||||||
|
createFile(join(workspace, 'buildSrc', 'Versions.kt'))
|
||||||
|
|
||||||
|
await restore('gradle')
|
||||||
|
expect(spyCacheRestore).toBeCalled()
|
||||||
|
expect(spyWarning).not.toBeCalled()
|
||||||
|
expect(spyInfo).toBeCalledWith('gradle cache is not found')
|
||||||
|
})
|
||||||
|
describe('for sbt', () => {
|
||||||
|
it('throws error if no build.sbt found', async () => {
|
||||||
|
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`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
it('downloads cache', async () => {
|
||||||
|
createFile(join(workspace, 'build.sbt'))
|
||||||
|
|
||||||
|
await restore('sbt')
|
||||||
|
expect(spyCacheRestore).toBeCalled()
|
||||||
|
expect(spyWarning).not.toBeCalled()
|
||||||
|
expect(spyInfo).toBeCalledWith('sbt cache is not found')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('save', () => {
|
||||||
|
let spyCacheSave: jest.SpyInstance<
|
||||||
|
ReturnType<typeof cache.saveCache>,
|
||||||
|
Parameters<typeof cache.saveCache>
|
||||||
|
>
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyCacheSave = jest
|
||||||
|
.spyOn(cache, 'saveCache')
|
||||||
|
.mockImplementation((paths: string[], key: string) =>
|
||||||
|
Promise.resolve(0)
|
||||||
|
)
|
||||||
|
spyWarning.mockImplementation(() => null)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('throws error if unsupported package manager specified', () => {
|
||||||
|
return expect(save('ant')).rejects.toThrowError(
|
||||||
|
'unknown package manager specified: ant'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('save with -1 cacheId , should not fail workflow', async () => {
|
||||||
|
spyCacheSave.mockImplementation(() => Promise.resolve(-1))
|
||||||
|
createStateForMissingBuildFile()
|
||||||
|
|
||||||
|
await save('maven')
|
||||||
|
expect(spyCacheSave).toBeCalled()
|
||||||
|
expect(spyWarning).not.toBeCalled()
|
||||||
|
expect(spyInfo).toBeCalled()
|
||||||
|
expect(spyInfo).toBeCalledWith(
|
||||||
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('saves with error from toolkit, should fail workflow', async () => {
|
||||||
|
spyCacheSave.mockImplementation(() =>
|
||||||
|
Promise.reject(new cache.ValidationError('Validation failed'))
|
||||||
|
)
|
||||||
|
createStateForMissingBuildFile()
|
||||||
|
|
||||||
|
expect.assertions(1)
|
||||||
|
await expect(save('maven')).rejects.toEqual(
|
||||||
|
new cache.ValidationError('Validation failed')
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('for maven', () => {
|
||||||
|
it('uploads cache even if no pom.xml found', async () => {
|
||||||
|
createStateForMissingBuildFile()
|
||||||
|
await save('maven')
|
||||||
|
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.toBeCalled()
|
||||||
|
expect(spyWarning).toBeCalledWith('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.stringMatching(/^Cache saved with the key:.*/)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('for gradle', () => {
|
||||||
|
it('uploads cache even if no build.gradle found', async () => {
|
||||||
|
createStateForMissingBuildFile()
|
||||||
|
|
||||||
|
await save('gradle')
|
||||||
|
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.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).toBeCalled()
|
||||||
|
expect(spyWarning).not.toBeCalled()
|
||||||
|
expect(spyInfo).toBeCalledWith(
|
||||||
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
it('uploads cache based on build.gradle.kts', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle.kts'))
|
||||||
|
createStateForSuccessfulRestore()
|
||||||
|
|
||||||
|
await save('gradle')
|
||||||
|
expect(spyCacheSave).toBeCalled()
|
||||||
|
expect(spyWarning).not.toBeCalled()
|
||||||
|
expect(spyInfo).toBeCalledWith(
|
||||||
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
it('uploads cache based on buildSrc/Versions.kt', async () => {
|
||||||
|
createDirectory(join(workspace, 'buildSrc'))
|
||||||
|
createFile(join(workspace, 'buildSrc', 'Versions.kt'))
|
||||||
|
createStateForSuccessfulRestore()
|
||||||
|
|
||||||
|
await save('gradle')
|
||||||
|
expect(spyCacheSave).toBeCalled()
|
||||||
|
expect(spyWarning).not.toBeCalled()
|
||||||
|
expect(spyInfo).toBeCalledWith(
|
||||||
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('for sbt', () => {
|
||||||
|
it('uploads cache even if no build.sbt found', async () => {
|
||||||
|
createStateForMissingBuildFile()
|
||||||
|
await save('sbt')
|
||||||
|
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.toBeCalled()
|
||||||
|
expect(spyWarning).toBeCalledWith('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.stringMatching(/^Cache saved with the key:.*/)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function resetState() {
|
||||||
|
jest.spyOn(core, 'getState').mockReset()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create states to emulate a restore process without build file.
|
||||||
|
*/
|
||||||
|
function createStateForMissingBuildFile() {
|
||||||
|
jest.spyOn(core, 'getState').mockImplementation(name => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-graalvm-cache-'
|
||||||
|
default:
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create states to emulate a successful restore process.
|
||||||
|
*/
|
||||||
|
function createStateForSuccessfulRestore() {
|
||||||
|
jest.spyOn(core, 'getState').mockImplementation(name => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-graalvm-cache-primary-key'
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-graalvm-cache-matched-key'
|
||||||
|
default:
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function createFile(path: string) {
|
||||||
|
core.info(`created a file at ${path}`)
|
||||||
|
fs.writeFileSync(path, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDirectory(path: string) {
|
||||||
|
core.info(`created a directory at ${path}`)
|
||||||
|
fs.mkdirSync(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
function projectRoot(workspace: string): string {
|
||||||
|
if (os.platform() === 'darwin') {
|
||||||
|
return `/private${workspace}`
|
||||||
|
} else {
|
||||||
|
return workspace
|
||||||
|
}
|
||||||
|
}
|
||||||
12
__tests__/cache/gradle/.gitignore
vendored
Normal file
12
__tests__/cache/gradle/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
.gradle
|
||||||
|
**/build/
|
||||||
|
!src/**/build/
|
||||||
|
|
||||||
|
# Ignore Gradle GUI config
|
||||||
|
gradle-app.setting
|
||||||
|
|
||||||
|
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||||
|
!gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Cache of project
|
||||||
|
.gradletasknamecache
|
||||||
17
__tests__/cache/gradle/build.gradle
vendored
Normal file
17
__tests__/cache/gradle/build.gradle
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
implementation 'org.codehaus.groovy:groovy:1.8.6'
|
||||||
|
}
|
||||||
|
tasks.register('downloadDependencies') {
|
||||||
|
doLast {
|
||||||
|
def total = configurations.compileClasspath.inject (0) { sum, file ->
|
||||||
|
sum + file.length()
|
||||||
|
}
|
||||||
|
println total
|
||||||
|
}
|
||||||
|
}
|
||||||
11
__tests__/cache/maven/.gitignore
vendored
Normal file
11
__tests__/cache/maven/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
target/
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
release.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
buildNumber.properties
|
||||||
|
.mvn/timing.properties
|
||||||
|
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||||
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
16
__tests__/cache/maven/pom.xml
vendored
Normal file
16
__tests__/cache/maven/pom.xml
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>io.github.actions</groupId>
|
||||||
|
<artifactId>setup-java-maven-example</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>5.7.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
1
__tests__/cache/sbt/.gitignore
vendored
Normal file
1
__tests__/cache/sbt/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
target/
|
||||||
3
__tests__/cache/sbt/build.sbt
vendored
Normal file
3
__tests__/cache/sbt/build.sbt
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ThisBuild / scalaVersion := "2.12.15"
|
||||||
|
|
||||||
|
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"
|
||||||
1
__tests__/cache/sbt/project/build.properties
vendored
Normal file
1
__tests__/cache/sbt/project/build.properties
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
sbt.version=1.6.2
|
||||||
99
__tests__/cleanup.test.ts
Normal file
99
__tests__/cleanup.test.ts
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 GitHub, Inc. and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Forked from https://github.com/actions/setup-java/blob/5b36705a13905facb447b6812d613a06a07e371d/__tests__/cleanup-java.test.ts
|
||||||
|
*/
|
||||||
|
|
||||||
|
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>>
|
||||||
|
let spyInfo: jest.SpyInstance<void, Parameters<typeof core.info>>
|
||||||
|
let spyCacheSave: jest.SpyInstance<
|
||||||
|
ReturnType<typeof cache.saveCache>,
|
||||||
|
Parameters<typeof cache.saveCache>
|
||||||
|
>
|
||||||
|
let spyJobStatusSuccess: jest.SpyInstance
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyWarning = jest.spyOn(core, 'warning')
|
||||||
|
spyWarning.mockImplementation(() => null)
|
||||||
|
spyInfo = jest.spyOn(core, 'info')
|
||||||
|
spyInfo.mockImplementation(() => null)
|
||||||
|
spyCacheSave = jest.spyOn(cache, 'saveCache')
|
||||||
|
createStateForSuccessfulRestore()
|
||||||
|
})
|
||||||
|
afterEach(() => {
|
||||||
|
resetState()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('does not fail nor warn even when the save provess throws a ReserveCacheError', async () => {
|
||||||
|
spyCacheSave.mockImplementation((paths: string[], key: string) =>
|
||||||
|
Promise.reject(
|
||||||
|
new cache.ReserveCacheError(
|
||||||
|
'Unable to reserve cache with key, another job may be creating this cache.'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
|
||||||
|
return name === 'cache' ? 'gradle' : ''
|
||||||
|
})
|
||||||
|
await cleanup()
|
||||||
|
expect(spyCacheSave).toBeCalled()
|
||||||
|
expect(spyWarning).not.toBeCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('does not fail even though the save process throws error', async () => {
|
||||||
|
spyCacheSave.mockImplementation((paths: string[], key: string) =>
|
||||||
|
Promise.reject(new Error('Unexpected error'))
|
||||||
|
)
|
||||||
|
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
|
||||||
|
return name === 'cache' ? 'gradle' : ''
|
||||||
|
})
|
||||||
|
await cleanup()
|
||||||
|
expect(spyCacheSave).toBeCalled()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function resetState() {
|
||||||
|
jest.spyOn(core, 'getState').mockReset()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create states to emulate a successful restore process.
|
||||||
|
*/
|
||||||
|
function createStateForSuccessfulRestore() {
|
||||||
|
jest.spyOn(core, 'getState').mockImplementation(name => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key'
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key'
|
||||||
|
default:
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {downloadGraalVMEE, fetchArtifact} from '../src/gds'
|
import {downloadGraalVMEELegacy, fetchArtifact} from '../src/gds'
|
||||||
import {expect, test} from '@jest/globals'
|
import {expect, test} from '@jest/globals'
|
||||||
|
|
||||||
const TEST_USER_AGENT = 'GraalVMGitHubActionTest/1.0.4'
|
const TEST_USER_AGENT = 'GraalVMGitHubActionTest/1.0.4'
|
||||||
@@ -32,13 +32,15 @@ test('fetch artifacts', async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('errors when downloading artifacts', async () => {
|
test('errors when downloading artifacts', async () => {
|
||||||
await expect(downloadGraalVMEE('invalid', '22.1.0', '11')).rejects.toThrow(
|
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(downloadGraalVMEE('invalid', '1.0.0', '11')).rejects.toThrow(
|
await expect(
|
||||||
'Unable to find JDK11-based GraalVM EE 1.0.0'
|
downloadGraalVMEELegacy('invalid', '1.0.0', '11')
|
||||||
)
|
).rejects.toThrow('Unable to find JDK11-based GraalVM EE 1.0.0')
|
||||||
await expect(downloadGraalVMEE('invalid', '22.1.0', '1')).rejects.toThrow(
|
await expect(
|
||||||
'Unable to find JDK1-based GraalVM EE 22.1.0'
|
downloadGraalVMEELegacy('invalid', '22.1.0', '1')
|
||||||
)
|
).rejects.toThrow('Unable to find JDK1-based GraalVM EE 22.1.0')
|
||||||
})
|
})
|
||||||
|
|||||||
81
__tests__/graalvm.test.ts
Normal file
81
__tests__/graalvm.test.ts
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
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'
|
||||||
|
|
||||||
|
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
|
||||||
|
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
|
||||||
|
|
||||||
|
test('request invalid version/javaVersion', async () => {
|
||||||
|
for (var combination of [
|
||||||
|
['22.3.0', '7'],
|
||||||
|
['22.3', '17'],
|
||||||
|
['22.3', '7']
|
||||||
|
]) {
|
||||||
|
let error = new Error('unexpected')
|
||||||
|
try {
|
||||||
|
await graalvm.setUpGraalVMRelease('', 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 version/javaVersion', async () => {
|
||||||
|
// Make sure the action can find the latest Java version for known major versions
|
||||||
|
for (var majorJavaVersion of ['17', '20']) {
|
||||||
|
await graalvm.findLatestGraalVMJDKCEJavaVersion(majorJavaVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
let error = new Error('unexpected')
|
||||||
|
try {
|
||||||
|
await graalvm.findLatestGraalVMJDKCEJavaVersion('11')
|
||||||
|
fail('Should not find Java version for 11')
|
||||||
|
} catch (err) {
|
||||||
|
if (!(err instanceof Error)) {
|
||||||
|
fail(`Unexpected non-Error: ${err}`)
|
||||||
|
}
|
||||||
|
error = err
|
||||||
|
}
|
||||||
|
expect(error.message).toContain('Unable to find the latest Java version for')
|
||||||
|
|
||||||
|
const latestRelease = await getTaggedRelease(
|
||||||
|
GRAALVM_RELEASES_REPO,
|
||||||
|
'vm-22.3.1'
|
||||||
|
)
|
||||||
|
const latestVersion = findGraalVMVersion(latestRelease)
|
||||||
|
expect(latestVersion).not.toBe('')
|
||||||
|
const latestJavaVersion = findHighestJavaVersion(latestRelease, latestVersion)
|
||||||
|
expect(latestJavaVersion).not.toBe('')
|
||||||
|
|
||||||
|
error = new Error('unexpected')
|
||||||
|
try {
|
||||||
|
const invalidRelease = {...latestRelease, tag_name: 'invalid'}
|
||||||
|
findGraalVMVersion(invalidRelease)
|
||||||
|
} catch (err) {
|
||||||
|
if (!(err instanceof Error)) {
|
||||||
|
fail(`Unexpected non-Error: ${err}`)
|
||||||
|
}
|
||||||
|
error = err
|
||||||
|
}
|
||||||
|
expect(error.message).toContain('Could not find latest GraalVM release:')
|
||||||
|
|
||||||
|
try {
|
||||||
|
findHighestJavaVersion(latestRelease, 'invalid')
|
||||||
|
} catch (err) {
|
||||||
|
if (!(err instanceof Error)) {
|
||||||
|
fail(`Unexpected non-Error: ${err}`)
|
||||||
|
}
|
||||||
|
error = err
|
||||||
|
}
|
||||||
|
expect(error.message).toContain('Could not find highest Java version.')
|
||||||
|
})
|
||||||
54
action.yml
54
action.yml
@@ -1,27 +1,25 @@
|
|||||||
name: 'GitHub Action for GraalVM'
|
name: 'GitHub Action for GraalVM'
|
||||||
description: 'Set up a specific version of GraalVM Community Edition (CE) or Enterprise Edition (EE)'
|
description: 'Set up a specific version of the GraalVM JDK and add the command-line tools to the PATH'
|
||||||
author: 'GraalVM Community'
|
author: 'GraalVM Community'
|
||||||
branding:
|
branding:
|
||||||
icon: 'terminal'
|
icon: 'terminal'
|
||||||
color: 'blue'
|
color: 'blue'
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
|
||||||
required: true
|
|
||||||
description: 'GraalVM version (release, latest, dev).'
|
|
||||||
gds-token:
|
|
||||||
required: false
|
|
||||||
description: 'Download token for the GraalVM Download Service. If provided, the action will set up GraalVM Enterprise Edition.'
|
|
||||||
java-version:
|
java-version:
|
||||||
required: true
|
required: true
|
||||||
description: 'Java version (11 or 17, 8 or 16 for older releases).'
|
description: 'Java version. See examples of supported syntax in the README file.'
|
||||||
|
distribution:
|
||||||
|
description: 'GraalVM distribution. See the list of available distributions in the README file.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
components:
|
components:
|
||||||
required: false
|
required: false
|
||||||
description: 'Comma-separated list of GraalVM components to be installed.'
|
description: 'Comma-separated list of GraalVM components to be installed.'
|
||||||
default: ''
|
default: ''
|
||||||
github-token:
|
github-token:
|
||||||
required: false
|
required: false
|
||||||
description: 'Set it to secrets.GITHUB_TOKEN to increase rate limits when accessing the GitHub API.'
|
description: 'Set it to secrets.GITHUB_TOKEN to increase rate limits when accessing the GitHub API. Defaults to github.token.'
|
||||||
default: ''
|
default: ${{ github.token }}
|
||||||
set-java-home:
|
set-java-home:
|
||||||
required: false
|
required: false
|
||||||
description: 'Set $JAVA_HOME to the GraalVM installation. Default: true.'
|
description: 'Set $JAVA_HOME to the GraalVM installation. Default: true.'
|
||||||
@@ -45,34 +43,18 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
description: 'Post a comment containing a Native Image build report on pull requests.'
|
description: 'Post a comment containing a Native Image build report on pull requests.'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
mvn-settings-path:
|
version:
|
||||||
description: 'Path to where the settings.xml file will be written. Default is ~/.m2.'
|
|
||||||
required: false
|
required: false
|
||||||
|
description: 'GraalVM version (release, latest, dev).'
|
||||||
|
default: ''
|
||||||
|
gds-token:
|
||||||
|
required: false
|
||||||
|
description: 'Download token for the GraalVM Download Service. If provided, the action will set up GraalVM Enterprise Edition.'
|
||||||
outputs:
|
outputs:
|
||||||
cache-hit:
|
cache-hit:
|
||||||
description: 'A boolean value to indicate an exact match was found for the primary key'
|
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: 'node16'
|
||||||
steps:
|
main: 'dist/main/index.js'
|
||||||
- uses: ./dist
|
post: 'dist/cleanup/index.js'
|
||||||
id: graalvm
|
post-if: 'success()'
|
||||||
with:
|
|
||||||
version: ${{ inputs.version }}
|
|
||||||
gds-token: ${{ inputs.gds-token }}
|
|
||||||
java-version: ${{ inputs.java-version }}
|
|
||||||
components: ${{ inputs.components }}
|
|
||||||
github-token: ${{ inputs.github-token }}
|
|
||||||
check-for-updates: ${{ inputs.check-for-updates }}
|
|
||||||
native-image-musl: ${{ inputs.native-image-musl }}
|
|
||||||
native-image-job-reports: ${{ inputs.native-image-job-reports }}
|
|
||||||
native-image-pr-reports: ${{ inputs.native-image-pr-reports }}
|
|
||||||
- name: 'Install Java Development Kit'
|
|
||||||
uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
java-version: ${{ inputs.java-version }}
|
|
||||||
distribution: 'jdkfile'
|
|
||||||
jdkFile: ${{ steps.graalvm.outputs.archive }}
|
|
||||||
cache: ${{ inputs.cache }}
|
|
||||||
settings-path: ${{ inputs.mvn-settings-path }}
|
|
||||||
- shell: bash
|
|
||||||
run: echo "GRAALVM_HOME=$JAVA_HOME" >> $GITHUB_ENV
|
|
||||||
|
|||||||
53
dist/action.yml
generated
vendored
53
dist/action.yml
generated
vendored
@@ -1,53 +0,0 @@
|
|||||||
name: 'GitHub Action for GraalVM'
|
|
||||||
description: 'Set up a specific version of GraalVM Community Edition (CE) or Enterprise Edition (EE)'
|
|
||||||
author: 'GraalVM Community'
|
|
||||||
branding:
|
|
||||||
icon: 'terminal'
|
|
||||||
color: 'blue'
|
|
||||||
inputs:
|
|
||||||
version:
|
|
||||||
required: true
|
|
||||||
description: 'GraalVM version (release, latest, dev).'
|
|
||||||
gds-token:
|
|
||||||
required: false
|
|
||||||
description: 'Download token for the GraalVM Download Service. If provided, the action will set up GraalVM Enterprise Edition.'
|
|
||||||
java-version:
|
|
||||||
required: true
|
|
||||||
description: 'Java version (11 or 17, 8 or 16 for older releases).'
|
|
||||||
components:
|
|
||||||
required: false
|
|
||||||
description: 'Comma-separated list of GraalVM components to be installed.'
|
|
||||||
default: ''
|
|
||||||
github-token:
|
|
||||||
required: false
|
|
||||||
description: 'Set it to secrets.GITHUB_TOKEN to increase rate limits when accessing the GitHub API.'
|
|
||||||
default: ''
|
|
||||||
set-java-home:
|
|
||||||
required: false
|
|
||||||
description: 'Set $JAVA_HOME to the GraalVM installation. Default: true.'
|
|
||||||
default: 'true'
|
|
||||||
check-for-updates:
|
|
||||||
required: false
|
|
||||||
description: 'Annotate jobs with update notifications, for example, when a new GraalVM release is available'
|
|
||||||
default: 'true'
|
|
||||||
native-image-musl:
|
|
||||||
required: false
|
|
||||||
description: 'Set up musl for static image building with GraalVM Native Image.'
|
|
||||||
default: 'false'
|
|
||||||
native-image-job-reports:
|
|
||||||
required: false
|
|
||||||
description: 'Post a job summary containing a Native Image build report.'
|
|
||||||
default: 'false'
|
|
||||||
native-image-pr-reports:
|
|
||||||
required: false
|
|
||||||
description: 'Post a comment containing a Native Image build report on pull requests.'
|
|
||||||
default: 'false'
|
|
||||||
outputs:
|
|
||||||
archive:
|
|
||||||
description: 'The path to the downloaded JDK archive file'
|
|
||||||
value: ${{ steps.download.outputs.archive }}
|
|
||||||
runs:
|
|
||||||
using: 'node16'
|
|
||||||
main: 'main/index.js'
|
|
||||||
post: 'cleanup/index.js'
|
|
||||||
post-if: 'success()'
|
|
||||||
60647
dist/cleanup/index.js
generated
vendored
60647
dist/cleanup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
61011
dist/main/index.js
generated
vendored
61011
dist/main/index.js
generated
vendored
File diff suppressed because one or more lines are too long
6878
package-lock.json
generated
6878
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-graalvm",
|
"name": "setup-graalvm",
|
||||||
"version": "1.0.9",
|
"version": "1.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "GitHub Action for GraalVM",
|
"description": "GitHub Action for GraalVM",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
@@ -11,7 +11,8 @@
|
|||||||
"lint": "eslint src/**/*.ts",
|
"lint": "eslint src/**/*.ts",
|
||||||
"package": "ncc build -o dist/main src/main.ts && ncc build -o dist/cleanup src/cleanup.ts",
|
"package": "ncc build -o dist/main src/main.ts && ncc build -o dist/cleanup src/cleanup.ts",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
|
"all-but-test": "npm run build && npm run format && npm run lint && npm run package",
|
||||||
|
"all": "npm run all-but-test && npm test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -41,7 +42,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.5.2",
|
"@types/jest": "^27.5.2",
|
||||||
"@types/node": "^17.0.6",
|
"@types/node": "^18.15.11",
|
||||||
"@types/semver": "^7.3.13",
|
"@types/semver": "^7.3.13",
|
||||||
"@types/uuid": "^8.3.4",
|
"@types/uuid": "^8.3.4",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/parser": "^5.8.1",
|
||||||
@@ -49,10 +50,10 @@
|
|||||||
"eslint": "^8.6.0",
|
"eslint": "^8.6.0",
|
||||||
"eslint-plugin-github": "^4.3.5",
|
"eslint-plugin-github": "^4.3.5",
|
||||||
"eslint-plugin-jest": "^25.3.4",
|
"eslint-plugin-jest": "^25.3.4",
|
||||||
"jest": "^27.4.5",
|
"jest": "^29.5.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"prettier": "2.5.1",
|
"prettier": "2.5.1",
|
||||||
"ts-jest": "^27.1.2",
|
"ts-jest": "^29.1.0",
|
||||||
"typescript": "^4.2.3"
|
"typescript": "^5.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 GitHub, Inc. and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Forked from https://github.com/actions/setup-java/blob/5b36705a13905facb447b6812d613a06a07e371d/src/cleanup-java.ts
|
||||||
|
*/
|
||||||
|
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import * as constants from './constants'
|
||||||
|
import {save} from './features/cache'
|
||||||
import {generateReports} from './features/reports'
|
import {generateReports} from './features/reports'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check given input and run a save process for the specified package manager
|
||||||
|
* @returns Promise that will be resolved when the save process finishes
|
||||||
|
*/
|
||||||
|
async function saveCache(): Promise<void> {
|
||||||
|
const cache = core.getInput(constants.INPUT_CACHE)
|
||||||
|
return cache ? save(cache) : Promise.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The save process is best-effort, and it should not make the workflow fail
|
* The save process is best-effort, and it should not make the workflow fail
|
||||||
* even though this process throws an error.
|
* even though this process throws an error.
|
||||||
@@ -21,6 +58,7 @@ async function ignoreErrors(promise: Promise<void>): Promise<unknown> {
|
|||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
await ignoreErrors(generateReports())
|
await ignoreErrors(generateReports())
|
||||||
|
await ignoreErrors(saveCache())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ import * as otypes from '@octokit/types'
|
|||||||
export const INPUT_VERSION = 'version'
|
export const INPUT_VERSION = 'version'
|
||||||
export const INPUT_GDS_TOKEN = 'gds-token'
|
export const INPUT_GDS_TOKEN = 'gds-token'
|
||||||
export const INPUT_JAVA_VERSION = 'java-version'
|
export const INPUT_JAVA_VERSION = 'java-version'
|
||||||
|
export const INPUT_DISTRIBUTION = 'distribution'
|
||||||
export const INPUT_COMPONENTS = 'components'
|
export const INPUT_COMPONENTS = 'components'
|
||||||
export const INPUT_GITHUB_TOKEN = 'github-token'
|
export const INPUT_GITHUB_TOKEN = 'github-token'
|
||||||
export const INPUT_SET_JAVA_HOME = 'set-java-home'
|
export const INPUT_SET_JAVA_HOME = 'set-java-home'
|
||||||
|
export const INPUT_CACHE = 'cache'
|
||||||
export const INPUT_CHECK_FOR_UPDATES = 'check-for-updates'
|
export const INPUT_CHECK_FOR_UPDATES = 'check-for-updates'
|
||||||
export const INPUT_NI_MUSL = 'native-image-musl'
|
export const INPUT_NI_MUSL = 'native-image-musl'
|
||||||
|
|
||||||
@@ -13,14 +15,22 @@ export const IS_LINUX = process.platform === 'linux'
|
|||||||
export const IS_MACOS = process.platform === 'darwin'
|
export const IS_MACOS = process.platform === 'darwin'
|
||||||
export const IS_WINDOWS = process.platform === 'win32'
|
export const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
|
export const DISTRIBUTION_GRAALVM = 'graalvm'
|
||||||
|
export const DISTRIBUTION_GRAALVM_COMMUNITY = 'graalvm-community'
|
||||||
|
export const DISTRIBUTION_MANDREL = 'mandrel'
|
||||||
|
|
||||||
export const VERSION_DEV = 'dev'
|
export const VERSION_DEV = 'dev'
|
||||||
export const VERSION_LATEST = 'latest'
|
export const VERSION_LATEST = 'latest'
|
||||||
|
|
||||||
|
export const JDK_ARCH = determineJDKArchitecture()
|
||||||
|
export const JDK_PLATFORM = determineJDKPlatform()
|
||||||
|
export const JDK_HOME_SUFFIX = IS_MACOS ? '/Contents/Home' : ''
|
||||||
|
|
||||||
export const GRAALVM_ARCH = determineGraalVMArchitecture()
|
export const GRAALVM_ARCH = determineGraalVMArchitecture()
|
||||||
export const GRAALVM_FILE_EXTENSION = IS_WINDOWS ? '.zip' : '.tar.gz'
|
export const GRAALVM_FILE_EXTENSION = IS_WINDOWS ? '.zip' : '.tar.gz'
|
||||||
export const GRAALVM_GH_USER = 'graalvm'
|
export const GRAALVM_GH_USER = 'graalvm'
|
||||||
export const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform
|
export const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform
|
||||||
export const JDK_HOME_SUFFIX = IS_MACOS ? '/Contents/Home' : ''
|
export const GRAALVM_RELEASES_REPO = 'graalvm-ce-builds'
|
||||||
|
|
||||||
export const MANDREL_NAMESPACE = 'mandrel-'
|
export const MANDREL_NAMESPACE = 'mandrel-'
|
||||||
|
|
||||||
@@ -30,9 +40,46 @@ export const GDS_GRAALVM_PRODUCT_ID = 'D53FAE8052773FFAE0530F15000AA6C6'
|
|||||||
export const ENV_GITHUB_EVENT_NAME = 'GITHUB_EVENT_NAME'
|
export const ENV_GITHUB_EVENT_NAME = 'GITHUB_EVENT_NAME'
|
||||||
export const EVENT_NAME_PULL_REQUEST = 'pull_request'
|
export const EVENT_NAME_PULL_REQUEST = 'pull_request'
|
||||||
|
|
||||||
|
export const ERROR_HINT =
|
||||||
|
'If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.'
|
||||||
|
|
||||||
export type LatestReleaseResponse =
|
export type LatestReleaseResponse =
|
||||||
otypes.Endpoints['GET /repos/{owner}/{repo}/releases/latest']['response']
|
otypes.Endpoints['GET /repos/{owner}/{repo}/releases/latest']['response']
|
||||||
|
|
||||||
|
export type MatchingRefsResponse =
|
||||||
|
otypes.Endpoints['GET /repos/{owner}/{repo}/git/matching-refs/{ref}']['response']
|
||||||
|
|
||||||
|
function determineJDKArchitecture(): string {
|
||||||
|
switch (process.arch) {
|
||||||
|
case 'x64': {
|
||||||
|
return 'x64'
|
||||||
|
}
|
||||||
|
case 'arm64': {
|
||||||
|
return 'aarch64'
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw new Error(`Unsupported architecture: ${process.arch}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function determineJDKPlatform(): string {
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'linux': {
|
||||||
|
return 'linux'
|
||||||
|
}
|
||||||
|
case 'darwin': {
|
||||||
|
return 'macos'
|
||||||
|
}
|
||||||
|
case 'win32': {
|
||||||
|
return 'windows'
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw new Error(`Unsupported platform: ${process.platform}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function determineGraalVMArchitecture(): string {
|
function determineGraalVMArchitecture(): string {
|
||||||
switch (process.arch) {
|
switch (process.arch) {
|
||||||
case 'x64': {
|
case 'x64': {
|
||||||
|
|||||||
205
src/features/cache.ts
Normal file
205
src/features/cache.ts
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 GitHub, Inc. and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Forked from https://github.com/actions/setup-java/blob/5b36705a13905facb447b6812d613a06a07e371d/src/cache.ts
|
||||||
|
*
|
||||||
|
* @fileoverview this file provides methods handling dependency cache
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {join} from 'path'
|
||||||
|
import os from 'os'
|
||||||
|
import * as cache from '@actions/cache'
|
||||||
|
import * as core from '@actions/core'
|
||||||
|
import * as glob from '@actions/glob'
|
||||||
|
|
||||||
|
const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'
|
||||||
|
const CACHE_MATCHED_KEY = 'cache-matched-key'
|
||||||
|
const CACHE_KEY_PREFIX = 'setup-graalvm'
|
||||||
|
|
||||||
|
interface PackageManager {
|
||||||
|
id: 'maven' | 'gradle' | 'sbt'
|
||||||
|
/**
|
||||||
|
* Paths of the file that specify the files to cache.
|
||||||
|
*/
|
||||||
|
path: string[]
|
||||||
|
pattern: string[]
|
||||||
|
}
|
||||||
|
const supportedPackageManager: PackageManager[] = [
|
||||||
|
{
|
||||||
|
id: 'maven',
|
||||||
|
path: [join(os.homedir(), '.m2', 'repository')],
|
||||||
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
||||||
|
pattern: ['**/pom.xml']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'gradle',
|
||||||
|
path: [
|
||||||
|
join(os.homedir(), '.gradle', 'caches'),
|
||||||
|
join(os.homedir(), '.gradle', 'wrapper')
|
||||||
|
],
|
||||||
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
||||||
|
pattern: [
|
||||||
|
'**/*.gradle*',
|
||||||
|
'**/gradle-wrapper.properties',
|
||||||
|
'buildSrc/**/Versions.kt',
|
||||||
|
'buildSrc/**/Dependencies.kt'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'sbt',
|
||||||
|
path: [
|
||||||
|
join(os.homedir(), '.ivy2', 'cache'),
|
||||||
|
join(os.homedir(), '.sbt'),
|
||||||
|
getCoursierCachePath(),
|
||||||
|
// Some files should not be cached to avoid resolution problems.
|
||||||
|
// In particular the resolution of snapshots (ideological gap between maven/ivy).
|
||||||
|
`!${join(os.homedir(), '.sbt', '*.lock')}`,
|
||||||
|
`!${join(os.homedir(), '**', 'ivydata-*.properties')}`
|
||||||
|
],
|
||||||
|
pattern: [
|
||||||
|
'**/*.sbt',
|
||||||
|
'**/project/build.properties',
|
||||||
|
'**/project/**.{scala,sbt}'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
function getCoursierCachePath(): string {
|
||||||
|
if (os.type() === 'Linux') return join(os.homedir(), '.cache', 'coursier')
|
||||||
|
if (os.type() === 'Darwin')
|
||||||
|
return join(os.homedir(), 'Library', 'Caches', 'Coursier')
|
||||||
|
return join(os.homedir(), 'AppData', 'Local', 'Coursier', 'Cache')
|
||||||
|
}
|
||||||
|
|
||||||
|
function findPackageManager(id: string): PackageManager {
|
||||||
|
const packageManager = supportedPackageManager.find(pm => pm.id === id)
|
||||||
|
if (packageManager === undefined) {
|
||||||
|
throw new Error(`unknown package manager specified: ${id}`)
|
||||||
|
}
|
||||||
|
return packageManager
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function that generates a cache key to use.
|
||||||
|
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
||||||
|
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
|
||||||
|
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
|
||||||
|
*/
|
||||||
|
async function computeCacheKey(
|
||||||
|
packageManager: PackageManager
|
||||||
|
): Promise<string> {
|
||||||
|
const hash = await glob.hashFiles(packageManager.pattern.join('\n'))
|
||||||
|
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore the dependency cache
|
||||||
|
* @param id ID of the package manager, should be "maven" or "gradle"
|
||||||
|
*/
|
||||||
|
export async function restore(id: string): Promise<void> {
|
||||||
|
const packageManager = findPackageManager(id)
|
||||||
|
const primaryKey = await computeCacheKey(packageManager)
|
||||||
|
|
||||||
|
core.debug(`primary key is ${primaryKey}`)
|
||||||
|
core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey)
|
||||||
|
if (primaryKey.endsWith('-')) {
|
||||||
|
throw new Error(
|
||||||
|
`No file in ${process.cwd()} matched to [${
|
||||||
|
packageManager.pattern
|
||||||
|
}], make sure you have checked out the target repository`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269)
|
||||||
|
const matchedKey = await cache.restoreCache(packageManager.path, primaryKey)
|
||||||
|
if (matchedKey) {
|
||||||
|
core.saveState(CACHE_MATCHED_KEY, matchedKey)
|
||||||
|
core.setOutput('cache-hit', matchedKey === primaryKey)
|
||||||
|
core.info(`Cache restored from key: ${matchedKey}`)
|
||||||
|
} else {
|
||||||
|
core.setOutput('cache-hit', false)
|
||||||
|
core.info(`${packageManager.id} cache is not found`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the dependency cache
|
||||||
|
* @param id ID of the package manager, should be "maven" or "gradle"
|
||||||
|
*/
|
||||||
|
export async function save(id: string): Promise<void> {
|
||||||
|
const packageManager = findPackageManager(id)
|
||||||
|
const matchedKey = core.getState(CACHE_MATCHED_KEY)
|
||||||
|
|
||||||
|
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
||||||
|
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY)
|
||||||
|
|
||||||
|
if (!primaryKey) {
|
||||||
|
core.warning('Error retrieving key from state.')
|
||||||
|
return
|
||||||
|
} else if (matchedKey === primaryKey) {
|
||||||
|
// no change in target directories
|
||||||
|
core.info(
|
||||||
|
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await cache.saveCache(packageManager.path, primaryKey)
|
||||||
|
core.info(`Cache saved with the key: ${primaryKey}`)
|
||||||
|
} catch (error) {
|
||||||
|
if (!(error instanceof Error)) {
|
||||||
|
core.info(`Not an Error: ${error}`)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
if (error.name === cache.ReserveCacheError.name) {
|
||||||
|
core.info(error.message)
|
||||||
|
} else {
|
||||||
|
if (isProbablyGradleDaemonProblem(packageManager, error)) {
|
||||||
|
core.warning(
|
||||||
|
'Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param packageManager the specified package manager by user
|
||||||
|
* @param error the error thrown by the saveCache
|
||||||
|
* @returns true if the given error seems related to the {@link https://github.com/actions/cache/issues/454|running Gradle Daemon issue}.
|
||||||
|
* @see {@link https://github.com/actions/cache/issues/454#issuecomment-840493935|why --no-daemon is necessary}
|
||||||
|
*/
|
||||||
|
function isProbablyGradleDaemonProblem(
|
||||||
|
packageManager: PackageManager,
|
||||||
|
error: Error
|
||||||
|
): boolean {
|
||||||
|
if (
|
||||||
|
packageManager.id !== 'gradle' ||
|
||||||
|
process.env['RUNNER_OS'] !== 'Windows'
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const message = error.message || ''
|
||||||
|
return message.startsWith('Tar failed with error: ')
|
||||||
|
}
|
||||||
@@ -1,19 +1,36 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {toSemVer} from '../utils'
|
import {getTaggedRelease, toSemVer} from '../utils'
|
||||||
import {lt, major, minor, valid} from 'semver'
|
import {lt, major, minor, valid} from 'semver'
|
||||||
import {getLatestReleaseVersion} from '../graalvm'
|
import {findGraalVMVersion} from '../graalvm'
|
||||||
|
import {GRAALVM_RELEASES_REPO} from '../constants'
|
||||||
|
|
||||||
export async function checkForUpdates(
|
export async function checkForUpdates(
|
||||||
graalVMVersion: string,
|
graalVMVersion: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (graalVMVersion === '22.3.0' && javaVersion === '11') {
|
if (
|
||||||
|
graalVMVersion.length > 0 &&
|
||||||
|
(javaVersion === '17' || javaVersion === '19')
|
||||||
|
) {
|
||||||
|
const recommendedJDK = javaVersion === '17' ? '17' : '20'
|
||||||
core.notice(
|
core.notice(
|
||||||
'Please consider upgrading your project to Java 17+. The GraalVM 22.3.0 release is the last to support JDK11: https://github.com/oracle/graal/issues/5063'
|
`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`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const latestGraalVMVersion = await getLatestReleaseVersion()
|
|
||||||
|
if (graalVMVersion.startsWith('22.3.') && javaVersion === '11') {
|
||||||
|
core.notice(
|
||||||
|
'Please consider upgrading your project to Java 17+. GraalVM 22.3.X releases are the last to support JDK11: https://github.com/oracle/graal/issues/5063'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const latestRelease = await getTaggedRelease(
|
||||||
|
GRAALVM_RELEASES_REPO,
|
||||||
|
'vm-22.3.1'
|
||||||
|
)
|
||||||
|
const latestGraalVMVersion = findGraalVMVersion(latestRelease)
|
||||||
const selectedVersion = toSemVer(graalVMVersion)
|
const selectedVersion = toSemVer(graalVMVersion)
|
||||||
const latestVersion = toSemVer(latestGraalVMVersion)
|
const latestVersion = toSemVer(latestGraalVMVersion)
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ export async function setUpNativeImageBuildReports(
|
|||||||
const isSupported =
|
const isSupported =
|
||||||
graalVMVersion === c.VERSION_LATEST ||
|
graalVMVersion === c.VERSION_LATEST ||
|
||||||
graalVMVersion === c.VERSION_DEV ||
|
graalVMVersion === c.VERSION_DEV ||
|
||||||
|
graalVMVersion.length === 0 ||
|
||||||
(!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) &&
|
(!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) &&
|
||||||
gte(toSemVer(graalVMVersion), '22.2.0'))
|
gte(toSemVer(graalVMVersion), '22.2.0'))
|
||||||
if (!isSupported) {
|
if (!isSupported) {
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ interface GDSErrorResponse {
|
|||||||
readonly message: string
|
readonly message: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadGraalVMEE(
|
export async function downloadGraalVMEELegacy(
|
||||||
gdsToken: string,
|
gdsToken: string,
|
||||||
version: string,
|
version: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const userAgent = `GraalVMGitHubAction/1.0.9 (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(
|
const baseArtifact = await fetchArtifact(
|
||||||
userAgent,
|
userAgent,
|
||||||
'isBase:True',
|
'isBase:True',
|
||||||
|
|||||||
287
src/graalvm.ts
287
src/graalvm.ts
@@ -1,62 +1,187 @@
|
|||||||
import * as c from './constants'
|
import * as c from './constants'
|
||||||
import {join} from 'path'
|
|
||||||
import {
|
import {
|
||||||
downloadAndExtractJDK,
|
downloadAndExtractJDK,
|
||||||
downloadExtractAndCacheJDK,
|
downloadExtractAndCacheJDK,
|
||||||
getLatestRelease
|
getLatestRelease,
|
||||||
|
getMatchingTags,
|
||||||
|
getTaggedRelease
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import {downloadGraalVMEE} from './gds'
|
import {downloadGraalVMEELegacy} from './gds'
|
||||||
import {downloadTool} from '@actions/tool-cache'
|
import {downloadTool} from '@actions/tool-cache'
|
||||||
import {v4 as uuidv4} from 'uuid'
|
import {basename} from 'path'
|
||||||
|
import {gt as semverGt, valid as semverValid} from 'semver'
|
||||||
|
|
||||||
const GRAALVM_CE_DL_BASE =
|
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm'
|
||||||
'https://github.com/graalvm/graalvm-ce-builds/releases/download'
|
const GRAALVM_CE_DL_BASE = `https://github.com/graalvm/${c.GRAALVM_RELEASES_REPO}/releases/download`
|
||||||
const GRAALVM_REPO_DEV_BUILDS = 'graalvm-ce-dev-builds'
|
const GRAALVM_REPO_DEV_BUILDS = 'graalvm-ce-dev-builds'
|
||||||
const GRAALVM_REPO_RELEASES = 'graalvm-ce-builds'
|
const GRAALVM_JDK_TAG_PREFIX = 'jdk-'
|
||||||
const GRAALVM_TAG_PREFIX = 'vm-'
|
const GRAALVM_TAG_PREFIX = 'vm-'
|
||||||
|
|
||||||
|
// Support for GraalVM for JDK 17 and later
|
||||||
|
|
||||||
|
export async function setUpGraalVMJDK(
|
||||||
|
javaVersionOrDev: string
|
||||||
|
): Promise<string> {
|
||||||
|
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||||
|
return setUpGraalVMJDKDevBuild()
|
||||||
|
}
|
||||||
|
const javaVersion = javaVersionOrDev
|
||||||
|
const toolName = determineToolName(javaVersion, false)
|
||||||
|
let downloadUrl: string
|
||||||
|
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/${toolName}${c.GRAALVM_FILE_EXTENSION}`
|
||||||
|
}
|
||||||
|
const downloader = async () => downloadGraalVMJDK(downloadUrl, javaVersion)
|
||||||
|
return downloadExtractAndCacheJDK(downloader, toolName, javaVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function setUpGraalVMJDKCE(
|
||||||
|
javaVersionOrDev: string
|
||||||
|
): Promise<string> {
|
||||||
|
if (javaVersionOrDev === c.VERSION_DEV) {
|
||||||
|
return setUpGraalVMJDKDevBuild()
|
||||||
|
}
|
||||||
|
let javaVersion = javaVersionOrDev
|
||||||
|
if (!javaVersion.includes('.')) {
|
||||||
|
javaVersion = await findLatestGraalVMJDKCEJavaVersion(javaVersion)
|
||||||
|
}
|
||||||
|
if (javaVersion.split('.').length != 3) {
|
||||||
|
throw new Error(
|
||||||
|
`java-version set to '${javaVersionOrDev}', which was resolved to '${javaVersion}'. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const toolName = determineToolName(javaVersion, true)
|
||||||
|
const downloadUrl = `${GRAALVM_CE_DL_BASE}/jdk-${javaVersion}/${toolName}${c.GRAALVM_FILE_EXTENSION}`
|
||||||
|
const downloader = async () => downloadGraalVMJDK(downloadUrl, javaVersion)
|
||||||
|
return downloadExtractAndCacheJDK(downloader, toolName, javaVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function findLatestGraalVMJDKCEJavaVersion(
|
||||||
|
majorJavaVersion: string
|
||||||
|
): Promise<string> {
|
||||||
|
const matchingRefs = await getMatchingTags(
|
||||||
|
`${GRAALVM_JDK_TAG_PREFIX}${majorJavaVersion}`
|
||||||
|
)
|
||||||
|
const lowestNonExistingVersion = '0.0.1'
|
||||||
|
let highestVersion = lowestNonExistingVersion
|
||||||
|
const versionNumberStartIndex = `refs/tags/${GRAALVM_JDK_TAG_PREFIX}`.length
|
||||||
|
for (const matchingRef of matchingRefs) {
|
||||||
|
const currentVersion = matchingRef.ref.substring(versionNumberStartIndex)
|
||||||
|
if (
|
||||||
|
semverValid(currentVersion) &&
|
||||||
|
semverGt(currentVersion, highestVersion)
|
||||||
|
) {
|
||||||
|
highestVersion = currentVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (highestVersion === lowestNonExistingVersion) {
|
||||||
|
throw new Error(
|
||||||
|
`Unable to find the latest Java version for '${majorJavaVersion}'. Please make sure the java-version is set correctly. ${c.ERROR_HINT}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return highestVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
function determineToolName(javaVersion: string, isCommunity: boolean) {
|
||||||
|
return `graalvm${isCommunity ? '-community' : ''}-jdk-${javaVersion}_${
|
||||||
|
c.JDK_PLATFORM
|
||||||
|
}-${c.JDK_ARCH}_bin`
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downloadGraalVMJDK(
|
||||||
|
downloadUrl: string,
|
||||||
|
javaVersion: string
|
||||||
|
): Promise<string> {
|
||||||
|
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 java-version: '${javaVersion}' is correct?`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
`Failed to download ${basename(downloadUrl)} (error: ${error}).`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Support for GraalVM dev builds
|
||||||
|
|
||||||
|
export async function setUpGraalVMJDKDevBuild(): Promise<string> {
|
||||||
|
const latestDevBuild = await getLatestRelease(GRAALVM_REPO_DEV_BUILDS)
|
||||||
|
const resolvedJavaVersion = findHighestJavaVersion(
|
||||||
|
latestDevBuild,
|
||||||
|
c.VERSION_DEV
|
||||||
|
)
|
||||||
|
const downloadUrl = findDownloadUrl(latestDevBuild, resolvedJavaVersion)
|
||||||
|
return downloadAndExtractJDK(downloadUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findHighestJavaVersion(
|
||||||
|
release: c.LatestReleaseResponse['data'],
|
||||||
|
version: string
|
||||||
|
): string {
|
||||||
|
const graalVMIdentifierPattern = determineGraalVMLegacyIdentifier(
|
||||||
|
false,
|
||||||
|
version,
|
||||||
|
'(\\d+)'
|
||||||
|
)
|
||||||
|
const expectedFileNameRegExp = new RegExp(
|
||||||
|
`^${graalVMIdentifierPattern}${c.GRAALVM_FILE_EXTENSION.replace(
|
||||||
|
/\./g,
|
||||||
|
'\\.'
|
||||||
|
)}$`
|
||||||
|
)
|
||||||
|
let highestJavaVersion = 0
|
||||||
|
for (const asset of release.assets) {
|
||||||
|
const matches = asset.name.match(expectedFileNameRegExp)
|
||||||
|
if (matches) {
|
||||||
|
const javaVersion = +matches[1]
|
||||||
|
if (javaVersion > highestJavaVersion) {
|
||||||
|
highestJavaVersion = javaVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (highestJavaVersion > 0) {
|
||||||
|
return String(highestJavaVersion)
|
||||||
|
} else {
|
||||||
|
throw new Error(
|
||||||
|
'Could not find highest Java version. Please file an issue at: https://github.com/graalvm/setup-graalvm/issues.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Support for GraalVM 22.X releases and earlier
|
||||||
|
|
||||||
export async function setUpGraalVMLatest(
|
export async function setUpGraalVMLatest(
|
||||||
gdsToken: string,
|
gdsToken: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
const lockedVersion = '22.3.1'
|
||||||
if (gdsToken.length > 0) {
|
if (gdsToken.length > 0) {
|
||||||
return setUpGraalVMRelease(gdsToken, c.VERSION_LATEST, javaVersion)
|
return setUpGraalVMRelease(gdsToken, lockedVersion, javaVersion)
|
||||||
}
|
}
|
||||||
const latestReleaseVersion = await getLatestReleaseVersion()
|
const latestRelease = await getTaggedRelease(
|
||||||
return setUpGraalVMRelease(gdsToken, latestReleaseVersion, javaVersion)
|
c.GRAALVM_RELEASES_REPO,
|
||||||
|
GRAALVM_TAG_PREFIX + lockedVersion
|
||||||
|
)
|
||||||
|
const version = findGraalVMVersion(latestRelease)
|
||||||
|
return setUpGraalVMRelease(gdsToken, version, javaVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getLatestReleaseVersion(): Promise<string> {
|
export function findGraalVMVersion(release: c.LatestReleaseResponse['data']) {
|
||||||
const latestRelease = await getLatestRelease(GRAALVM_REPO_RELEASES)
|
const tag_name = release.tag_name
|
||||||
const tag_name = latestRelease.tag_name
|
if (!tag_name.startsWith(GRAALVM_TAG_PREFIX)) {
|
||||||
if (tag_name.startsWith(GRAALVM_TAG_PREFIX)) {
|
|
||||||
return tag_name.substring(GRAALVM_TAG_PREFIX.length, tag_name.length)
|
|
||||||
}
|
|
||||||
throw new Error(`Could not find latest GraalVM release: ${tag_name}`)
|
throw new Error(`Could not find latest GraalVM release: ${tag_name}`)
|
||||||
}
|
|
||||||
|
|
||||||
export async function setUpGraalVMDevBuild(
|
|
||||||
gdsToken: string,
|
|
||||||
javaVersion: string
|
|
||||||
): Promise<string> {
|
|
||||||
if (gdsToken.length > 0) {
|
|
||||||
throw new Error('Downloading GraalVM EE dev builds is not supported')
|
|
||||||
}
|
}
|
||||||
const latestDevBuild = await getLatestRelease(GRAALVM_REPO_DEV_BUILDS)
|
return tag_name.substring(GRAALVM_TAG_PREFIX.length, tag_name.length)
|
||||||
const graalVMIdentifier = determineGraalVMIdentifier(
|
|
||||||
false,
|
|
||||||
'dev',
|
|
||||||
javaVersion
|
|
||||||
)
|
|
||||||
const expectedFileName = `${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`
|
|
||||||
for (const asset of latestDevBuild.assets) {
|
|
||||||
if (asset.name === expectedFileName) {
|
|
||||||
return downloadAndExtractJDK(asset.browser_download_url)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error(
|
|
||||||
`Could not find GraalVM dev build for Java ${javaVersion}. It may no longer be available, so please consider upgrading the Java version. If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setUpGraalVMRelease(
|
export async function setUpGraalVMRelease(
|
||||||
@@ -65,41 +190,77 @@ export async function setUpGraalVMRelease(
|
|||||||
javaVersion: string
|
javaVersion: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const isEE = gdsToken.length > 0
|
const isEE = gdsToken.length > 0
|
||||||
const graalVMIdentifier = determineGraalVMIdentifier(
|
const toolName = determineLegacyToolName(isEE, version, javaVersion)
|
||||||
isEE,
|
|
||||||
version,
|
|
||||||
javaVersion
|
|
||||||
)
|
|
||||||
const toolName = determineToolName(isEE, javaVersion)
|
|
||||||
let downloader: () => Promise<string>
|
let downloader: () => Promise<string>
|
||||||
if (isEE) {
|
if (isEE) {
|
||||||
downloader = async () => downloadGraalVMEE(gdsToken, version, javaVersion)
|
|
||||||
} else {
|
|
||||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`
|
|
||||||
downloader = async () =>
|
downloader = async () =>
|
||||||
downloadTool(
|
downloadGraalVMEELegacy(gdsToken, version, javaVersion)
|
||||||
downloadUrl,
|
} else {
|
||||||
join(
|
downloader = async () => downloadGraalVMCELegacy(version, javaVersion)
|
||||||
process.env['RUNNER_TEMP'] || '',
|
|
||||||
`${uuidv4()}${c.GRAALVM_FILE_EXTENSION}`
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return downloadExtractAndCacheJDK(downloader, toolName, version)
|
return downloadExtractAndCacheJDK(downloader, toolName, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
function determineGraalVMIdentifier(
|
function findDownloadUrl(
|
||||||
|
release: c.LatestReleaseResponse['data'],
|
||||||
|
javaVersion: string
|
||||||
|
): string {
|
||||||
|
const graalVMIdentifier = determineGraalVMLegacyIdentifier(
|
||||||
|
false,
|
||||||
|
c.VERSION_DEV,
|
||||||
|
javaVersion
|
||||||
|
)
|
||||||
|
const expectedFileName = `${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`
|
||||||
|
for (const asset of release.assets) {
|
||||||
|
if (asset.name === expectedFileName) {
|
||||||
|
return asset.browser_download_url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
`Could not find GraalVM dev build for Java ${javaVersion}. It may no longer be available, so please consider upgrading the Java version. ${c.ERROR_HINT}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function determineGraalVMLegacyIdentifier(
|
||||||
isEE: boolean,
|
isEE: boolean,
|
||||||
version: string,
|
version: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
): string {
|
): string {
|
||||||
return `graalvm-${isEE ? 'ee' : 'ce'}-java${javaVersion}-${
|
return `${determineLegacyToolName(isEE, version, javaVersion)}-${
|
||||||
c.GRAALVM_PLATFORM
|
c.GRAALVM_ARCH
|
||||||
}-${c.GRAALVM_ARCH}-${version}`
|
}-${version}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function determineToolName(isEE: boolean, javaVersion: string): string {
|
function determineLegacyToolName(
|
||||||
return `graalvm-${isEE ? 'ee' : 'ce'}-java${javaVersion}-${
|
isEE: boolean,
|
||||||
c.GRAALVM_PLATFORM
|
version: string,
|
||||||
}`
|
javaVersion: string
|
||||||
|
): string {
|
||||||
|
const infix = isEE ? 'ee' : version === c.VERSION_DEV ? 'community' : 'ce'
|
||||||
|
return `graalvm-${infix}-java${javaVersion}-${c.GRAALVM_PLATFORM}`
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downloadGraalVMCELegacy(
|
||||||
|
version: string,
|
||||||
|
javaVersion: string
|
||||||
|
): Promise<string> {
|
||||||
|
const graalVMIdentifier = determineGraalVMLegacyIdentifier(
|
||||||
|
false,
|
||||||
|
version,
|
||||||
|
javaVersion
|
||||||
|
)
|
||||||
|
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${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 ${graalVMIdentifier}. Are you sure version: '${version}' and java-version: '${javaVersion}' are correct?`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
`Failed to download ${graalVMIdentifier} (error: ${error}).`
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
69
src/main.ts
69
src/main.ts
@@ -1,7 +1,10 @@
|
|||||||
import * as c from './constants'
|
import * as c from './constants'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as graalvm from './graalvm'
|
import * as graalvm from './graalvm'
|
||||||
|
import {gte as semverGte, valid as semverValid} from 'semver'
|
||||||
|
import {isFeatureAvailable as isCacheAvailable} from '@actions/cache'
|
||||||
import {join} from 'path'
|
import {join} from 'path'
|
||||||
|
import {restore} from './features/cache'
|
||||||
import {setUpDependencies} from './dependencies'
|
import {setUpDependencies} from './dependencies'
|
||||||
import {setUpGUComponents} from './gu'
|
import {setUpGUComponents} from './gu'
|
||||||
import {setUpMandrel} from './mandrel'
|
import {setUpMandrel} from './mandrel'
|
||||||
@@ -12,19 +15,23 @@ import {setUpNativeImageBuildReports} from './features/reports'
|
|||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const graalvmVersion = core.getInput(c.INPUT_VERSION, {required: true})
|
|
||||||
const gdsToken = core.getInput(c.INPUT_GDS_TOKEN)
|
|
||||||
const javaVersion = core.getInput(c.INPUT_JAVA_VERSION, {required: true})
|
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 gdsToken = core.getInput(c.INPUT_GDS_TOKEN)
|
||||||
const componentsString: string = core.getInput(c.INPUT_COMPONENTS)
|
const componentsString: string = core.getInput(c.INPUT_COMPONENTS)
|
||||||
const components: string[] =
|
const components: string[] =
|
||||||
componentsString.length > 0 ? componentsString.split(',') : []
|
componentsString.length > 0
|
||||||
|
? componentsString.split(',').map(x => x.trim())
|
||||||
|
: []
|
||||||
const setJavaHome = core.getInput(c.INPUT_SET_JAVA_HOME) === 'true'
|
const setJavaHome = core.getInput(c.INPUT_SET_JAVA_HOME) === 'true'
|
||||||
|
const cache = core.getInput(c.INPUT_CACHE)
|
||||||
const enableCheckForUpdates =
|
const enableCheckForUpdates =
|
||||||
core.getInput(c.INPUT_CHECK_FOR_UPDATES) === 'true'
|
core.getInput(c.INPUT_CHECK_FOR_UPDATES) === 'true'
|
||||||
const enableNativeImageMusl = core.getInput(c.INPUT_NI_MUSL) === 'true'
|
const enableNativeImageMusl = core.getInput(c.INPUT_NI_MUSL) === 'true'
|
||||||
|
|
||||||
if (c.IS_WINDOWS) {
|
if (c.IS_WINDOWS) {
|
||||||
setUpWindowsEnvironment()
|
setUpWindowsEnvironment(graalvmVersion)
|
||||||
}
|
}
|
||||||
await setUpDependencies(components)
|
await setUpDependencies(components)
|
||||||
if (enableNativeImageMusl) {
|
if (enableNativeImageMusl) {
|
||||||
@@ -33,12 +40,58 @@ async function run(): Promise<void> {
|
|||||||
|
|
||||||
// Download or build GraalVM
|
// Download or build GraalVM
|
||||||
let graalVMHome
|
let graalVMHome
|
||||||
|
if (distribution.length > 0 || graalvmVersion.length == 0) {
|
||||||
|
switch (distribution) {
|
||||||
|
case c.DISTRIBUTION_GRAALVM:
|
||||||
|
graalVMHome = await graalvm.setUpGraalVMJDK(javaVersion)
|
||||||
|
break
|
||||||
|
case c.DISTRIBUTION_GRAALVM_COMMUNITY:
|
||||||
|
graalVMHome = await graalvm.setUpGraalVMJDKCE(javaVersion)
|
||||||
|
break
|
||||||
|
case c.DISTRIBUTION_MANDREL:
|
||||||
|
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(
|
||||||
|
`This build is using GraalVM Community Edition. To select a specific distribution, use the 'distribution' option (see https://github.com/graalvm/setup-graalvm/tree/main#options).`
|
||||||
|
)
|
||||||
|
graalVMHome = await graalvm.setUpGraalVMJDKDevBuild()
|
||||||
|
} else {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported distribution: ${distribution}`)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
switch (graalvmVersion) {
|
switch (graalvmVersion) {
|
||||||
case c.VERSION_LATEST:
|
case c.VERSION_LATEST:
|
||||||
graalVMHome = await graalvm.setUpGraalVMLatest(gdsToken, javaVersion)
|
if (
|
||||||
|
javaVersion.startsWith('17') ||
|
||||||
|
(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(
|
||||||
|
gdsToken,
|
||||||
|
javaVersion
|
||||||
|
)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case c.VERSION_DEV:
|
case c.VERSION_DEV:
|
||||||
graalVMHome = await graalvm.setUpGraalVMDevBuild(gdsToken, javaVersion)
|
if (gdsToken.length > 0) {
|
||||||
|
throw new Error(
|
||||||
|
'Downloading GraalVM EE dev builds is not supported'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
graalVMHome = await graalvm.setUpGraalVMJDKDevBuild()
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
if (graalvmVersion.startsWith(c.MANDREL_NAMESPACE)) {
|
||||||
@@ -55,6 +108,7 @@ async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Activate GraalVM
|
// Activate GraalVM
|
||||||
core.debug(`Activating GraalVM located at '${graalVMHome}'...`)
|
core.debug(`Activating GraalVM located at '${graalVMHome}'...`)
|
||||||
@@ -75,6 +129,9 @@ async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cache && isCacheAvailable()) {
|
||||||
|
await restore(cache)
|
||||||
|
}
|
||||||
setUpNativeImageBuildReports(graalvmVersion)
|
setUpNativeImageBuildReports(graalvmVersion)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error) core.setFailed(error.message)
|
if (error instanceof Error) core.setFailed(error.message)
|
||||||
|
|||||||
23
src/msvc.ts
23
src/msvc.ts
@@ -1,18 +1,25 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {execSync} from 'child_process'
|
import {execSync} from 'child_process'
|
||||||
import {existsSync} from 'fs'
|
import {existsSync} from 'fs'
|
||||||
|
import {VERSION_DEV} from './constants'
|
||||||
|
|
||||||
// Keep in sync with https://github.com/actions/virtual-environments
|
// Keep in sync with https://github.com/actions/virtual-environments
|
||||||
const KNOWN_VISUAL_STUDIO_INSTALLATIONS = [
|
const KNOWN_VISUAL_STUDIO_INSTALLATIONS = [
|
||||||
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise', // 'windows-2016'
|
'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise', // 'windows-2022' and 'windows-latest'
|
||||||
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise', // 'windows-2019' and 'windows-latest'
|
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise', // 'windows-2019'
|
||||||
'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise' // 'windows-2022'
|
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise' // 'windows-2016' (deprecated and removed)
|
||||||
]
|
]
|
||||||
const VCVARSALL_SUBPATH = '\\VC\\Auxiliary\\Build\\vcvarsall.bat'
|
if (process.env['VSINSTALLDIR']) {
|
||||||
|
// if VSINSTALLDIR is set, make it the first known installation
|
||||||
|
KNOWN_VISUAL_STUDIO_INSTALLATIONS.unshift(
|
||||||
|
process.env['VSINSTALLDIR'].replace(/\\$/, '')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const VCVARSALL_SUBPATH = 'VC\\Auxiliary\\Build\\vcvarsall.bat'
|
||||||
|
|
||||||
function findVcvarsallPath(): string {
|
function findVcvarsallPath(): string {
|
||||||
for (const installation of KNOWN_VISUAL_STUDIO_INSTALLATIONS) {
|
for (const installation of KNOWN_VISUAL_STUDIO_INSTALLATIONS) {
|
||||||
const candidate = `${installation}${VCVARSALL_SUBPATH}`
|
const candidate = `${installation}\\${VCVARSALL_SUBPATH}`
|
||||||
if (existsSync(candidate)) {
|
if (existsSync(candidate)) {
|
||||||
return candidate
|
return candidate
|
||||||
}
|
}
|
||||||
@@ -20,7 +27,11 @@ function findVcvarsallPath(): string {
|
|||||||
throw new Error('Failed to find vcvarsall.bat')
|
throw new Error('Failed to find vcvarsall.bat')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setUpWindowsEnvironment(): void {
|
export function setUpWindowsEnvironment(graalVMVersion: string): void {
|
||||||
|
if (graalVMVersion === VERSION_DEV) {
|
||||||
|
return // no longer required in dev builds
|
||||||
|
}
|
||||||
|
|
||||||
core.startGroup('Updating Windows environment...')
|
core.startGroup('Updating Windows environment...')
|
||||||
|
|
||||||
const vcvarsallPath = findVcvarsallPath()
|
const vcvarsallPath = findVcvarsallPath()
|
||||||
|
|||||||
52
src/utils.ts
52
src/utils.ts
@@ -9,9 +9,9 @@ import {Octokit} from '@octokit/core'
|
|||||||
import {createHash} from 'crypto'
|
import {createHash} from 'crypto'
|
||||||
import {join} from 'path'
|
import {join} from 'path'
|
||||||
|
|
||||||
// Set up Octokit in the same way as @actions/github (see https://git.io/Jy9YP)
|
// Set up Octokit for github.com only and in the same way as @actions/github (see https://git.io/Jy9YP)
|
||||||
const baseUrl = process.env['GITHUB_API_URL'] || 'https://api.github.com'
|
const baseUrl = 'https://api.github.com'
|
||||||
const GitHub = Octokit.defaults({
|
const GitHubDotCom = Octokit.defaults({
|
||||||
baseUrl,
|
baseUrl,
|
||||||
request: {
|
request: {
|
||||||
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
||||||
@@ -38,7 +38,7 @@ export async function getLatestRelease(
|
|||||||
): Promise<c.LatestReleaseResponse['data']> {
|
): Promise<c.LatestReleaseResponse['data']> {
|
||||||
const githubToken = getGitHubToken()
|
const githubToken = getGitHubToken()
|
||||||
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
||||||
const octokit = new GitHub(options)
|
const octokit = new GitHubDotCom(options)
|
||||||
return (
|
return (
|
||||||
await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||||
owner: c.GRAALVM_GH_USER,
|
owner: c.GRAALVM_GH_USER,
|
||||||
@@ -47,12 +47,46 @@ export async function getLatestRelease(
|
|||||||
).data
|
).data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getTaggedRelease(
|
||||||
|
repo: string,
|
||||||
|
tag: string
|
||||||
|
): Promise<c.LatestReleaseResponse['data']> {
|
||||||
|
const githubToken = getGitHubToken()
|
||||||
|
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
||||||
|
const octokit = new GitHubDotCom(options)
|
||||||
|
return (
|
||||||
|
await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||||
|
owner: c.GRAALVM_GH_USER,
|
||||||
|
repo,
|
||||||
|
tag
|
||||||
|
})
|
||||||
|
).data
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getMatchingTags(
|
||||||
|
tagPrefix: string
|
||||||
|
): Promise<c.MatchingRefsResponse['data']> {
|
||||||
|
const githubToken = getGitHubToken()
|
||||||
|
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
||||||
|
const octokit = new GitHubDotCom(options)
|
||||||
|
return (
|
||||||
|
await octokit.request(
|
||||||
|
'GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}',
|
||||||
|
{
|
||||||
|
owner: c.GRAALVM_GH_USER,
|
||||||
|
repo: c.GRAALVM_RELEASES_REPO,
|
||||||
|
tagPrefix
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).data
|
||||||
|
}
|
||||||
|
|
||||||
export async function downloadAndExtractJDK(
|
export async function downloadAndExtractJDK(
|
||||||
downloadUrl: string
|
downloadUrl: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const archive = await tc.downloadTool(downloadUrl)
|
return findJavaHomeInSubfolder(
|
||||||
core.setOutput('archive', archive)
|
await extract(await tc.downloadTool(downloadUrl))
|
||||||
return findJavaHomeInSubfolder(await extract(archive))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadExtractAndCacheJDK(
|
export async function downloadExtractAndCacheJDK(
|
||||||
@@ -65,9 +99,7 @@ export async function downloadExtractAndCacheJDK(
|
|||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.info(`Found ${toolName} ${version} in tool-cache @ ${toolPath}`)
|
core.info(`Found ${toolName} ${version} in tool-cache @ ${toolPath}`)
|
||||||
} else {
|
} else {
|
||||||
const archive = await downloader()
|
const extractDir = await extract(await downloader())
|
||||||
core.setOutput('archive', archive)
|
|
||||||
const extractDir = await extract(archive)
|
|
||||||
core.info(`Adding ${toolName} ${version} to tool-cache ...`)
|
core.info(`Adding ${toolName} ${version} to tool-cache ...`)
|
||||||
toolPath = await tc.cacheDir(extractDir, toolName, semVersion)
|
toolPath = await tc.cacheDir(extractDir, toolName, semVersion)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user