Compare commits
18 Commits
composite
...
fniephaus/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b11d36630f | ||
|
|
babc303d7e | ||
|
|
5f2753d6bc | ||
|
|
6acd592e3e | ||
|
|
cf001e2d43 | ||
|
|
90a2c32c8b | ||
|
|
4297237826 | ||
|
|
c85a448ca4 | ||
|
|
c8fdb59e88 | ||
|
|
40947ba8ce | ||
|
|
4356481765 | ||
|
|
8b27096bbf | ||
|
|
93d8fee7fa | ||
|
|
76d605752b | ||
|
|
b53bc17dd7 | ||
|
|
d01f5f519f | ||
|
|
4aba115fa5 | ||
|
|
7c84ab1ba7 |
71
.github/workflows/test.yml
vendored
71
.github/workflows/test.yml
vendored
@@ -25,23 +25,32 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
version: [latest, dev]
|
version: ['latest', 'dev']
|
||||||
java-version: ['17', '19']
|
java-version: ['19', '20']
|
||||||
components: ['native-image']
|
components: ['native-image']
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
|
exclude:
|
||||||
|
- version: 'latest'
|
||||||
|
java-version: '20'
|
||||||
|
- version: 'dev'
|
||||||
|
java-version: '19'
|
||||||
include:
|
include:
|
||||||
- version: '22.2.0' # for update notifications
|
- version: '22.2.0' # for update notifications
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
components: 'native-image'
|
components: 'native-image'
|
||||||
os: ubuntu-18.04
|
os: ubuntu-20.04
|
||||||
- version: '22.3.0'
|
- version: '22.3.1'
|
||||||
java-version: '11' # for JDK11 notification
|
java-version: '11' # for JDK11 notification
|
||||||
components: 'native-image'
|
components: 'native-image'
|
||||||
os: macos-11
|
os: macos-11
|
||||||
- version: '22.3.0'
|
- version: '22.3.1'
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
components: 'native-image'
|
components: 'native-image'
|
||||||
os: windows-2022
|
os: windows-2022
|
||||||
|
- version: 'dev'
|
||||||
|
java-version: 'dev'
|
||||||
|
components: 'native-image'
|
||||||
|
os: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
@@ -63,6 +72,7 @@ jobs:
|
|||||||
java --version
|
java --version
|
||||||
java --version | grep "GraalVM CE" || exit 34
|
java --version | grep "GraalVM CE" || exit 34
|
||||||
native-image --version
|
native-image --version
|
||||||
|
gu list
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
- name: Check Windows environment
|
- name: Check Windows environment
|
||||||
run: |
|
run: |
|
||||||
@@ -70,6 +80,7 @@ jobs:
|
|||||||
echo "JAVA_HOME: $env:JAVA_HOME"
|
echo "JAVA_HOME: $env:JAVA_HOME"
|
||||||
java --version
|
java --version
|
||||||
native-image --version
|
native-image --version
|
||||||
|
gu.cmd remove native-image
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
test-ee:
|
test-ee:
|
||||||
name: EE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
name: EE ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
||||||
@@ -77,10 +88,19 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
version: ['22.3.0', 'latest']
|
version: ['latest']
|
||||||
java-version: ['11', '17', '19']
|
java-version: ['19']
|
||||||
components: ['native-image']
|
components: ['native-image']
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
|
include:
|
||||||
|
- version: '22.3.0'
|
||||||
|
java-version: '11'
|
||||||
|
components: 'native-image'
|
||||||
|
os: ubuntu-latest
|
||||||
|
- version: '22.3.0'
|
||||||
|
java-version: '17'
|
||||||
|
components: 'native-image'
|
||||||
|
os: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
@@ -99,6 +119,7 @@ jobs:
|
|||||||
java --version
|
java --version
|
||||||
java --version | grep "GraalVM EE" || exit 23
|
java --version | grep "GraalVM EE" || exit 23
|
||||||
native-image --version
|
native-image --version
|
||||||
|
gu list
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
- name: Check Windows environment
|
- name: Check Windows environment
|
||||||
run: |
|
run: |
|
||||||
@@ -106,6 +127,7 @@ jobs:
|
|||||||
echo "JAVA_HOME: $env:JAVA_HOME"
|
echo "JAVA_HOME: $env:JAVA_HOME"
|
||||||
java --version
|
java --version
|
||||||
native-image --version
|
native-image --version
|
||||||
|
gu.cmd remove native-image
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
test-mandrel:
|
test-mandrel:
|
||||||
name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
name: ${{ matrix.version }} + JDK${{ matrix.java-version }} on ${{ matrix.os }}
|
||||||
@@ -138,7 +160,7 @@ jobs:
|
|||||||
java --version
|
java --version
|
||||||
native-image --version
|
native-image --version
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
test-native-image-msvc:
|
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,7 +171,30 @@ jobs:
|
|||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 'latest'
|
version: 'dev'
|
||||||
|
java-version: 'dev'
|
||||||
|
components: 'native-image'
|
||||||
|
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-2019
|
||||||
|
runs-on: windows-2019
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write # for `native-image-pr-reports` option
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Run setup-graalvm action
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: '22.3.1'
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
components: 'native-image'
|
components: 'native-image'
|
||||||
native-image-job-reports: 'true'
|
native-image-job-reports: 'true'
|
||||||
@@ -172,8 +217,8 @@ jobs:
|
|||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 'latest'
|
version: 'dev'
|
||||||
java-version: '19'
|
java-version: 'dev'
|
||||||
components: 'native-image'
|
components: 'native-image'
|
||||||
native-image-musl: 'true'
|
native-image-musl: 'true'
|
||||||
native-image-job-reports: 'true'
|
native-image-job-reports: 'true'
|
||||||
@@ -196,7 +241,7 @@ jobs:
|
|||||||
- name: Run setup-graalvm action
|
- name: Run setup-graalvm action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 'dev'
|
version: 'latest'
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
components: 'espresso,llvm-toolchain,native-image,nodejs,python,R,ruby,wasm'
|
components: 'espresso,llvm-toolchain,native-image,nodejs,python,R,ruby,wasm'
|
||||||
set-java-home: 'false'
|
set-java-home: 'false'
|
||||||
@@ -240,3 +285,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 R ruby wasm
|
||||||
|
|||||||
@@ -116,9 +116,9 @@ jobs:
|
|||||||
|-----------------|:--------:|-------------|
|
|-----------------|:--------:|-------------|
|
||||||
| `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]. |
|
| `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]. |
|
||||||
| `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)). |
|
| `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)). |
|
||||||
| `java-version`<br>*(required)* | n/a | `'17'` or `'19'` for a specific Java version.<br>(`'8'`, `'11'`, `'16'` are supported for older GraalVM releases.) |
|
| `java-version`<br>*(required)* | n/a | `'17'` or `'19'` for a specific Java version, `'dev'` for the highest Java version available (requires `version: 'dev'`).<br>(`'8'`, `'11'`, `'16'` are supported for older GraalVM releases.) |
|
||||||
| `components` | `''` | Comma-spearated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
|
| `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. |
|
| `github-token` | `'${{ 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. It can 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. |
|
||||||
|
|||||||
64
__tests__/graalvm.test.ts
Normal file
64
__tests__/graalvm.test.ts
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
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-Erro: ${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 () => {
|
||||||
|
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('')
|
||||||
|
|
||||||
|
let 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-Erro: ${err}`)
|
||||||
|
}
|
||||||
|
error = err
|
||||||
|
}
|
||||||
|
expect(error.message).toContain('Could not find highest Java version.')
|
||||||
|
})
|
||||||
@@ -20,8 +20,8 @@ inputs:
|
|||||||
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.'
|
||||||
|
|||||||
17424
dist/cleanup/index.js
generated
vendored
17424
dist/cleanup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
17671
dist/main/index.js
generated
vendored
17671
dist/main/index.js
generated
vendored
File diff suppressed because one or more lines are too long
6876
package-lock.json
generated
6876
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.0.11",
|
||||||
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ 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 GRAALVM_RELEASES_REPO = 'graalvm-ce-builds'
|
||||||
export const JDK_HOME_SUFFIX = IS_MACOS ? '/Contents/Home' : ''
|
export const JDK_HOME_SUFFIX = IS_MACOS ? '/Contents/Home' : ''
|
||||||
|
|
||||||
export const MANDREL_NAMESPACE = 'mandrel-'
|
export const MANDREL_NAMESPACE = 'mandrel-'
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ export async function save(id: string): Promise<void> {
|
|||||||
await cache.saveCache(packageManager.path, primaryKey)
|
await cache.saveCache(packageManager.path, primaryKey)
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`)
|
core.info(`Cache saved with the key: ${primaryKey}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (!(error instanceof Error)) {
|
||||||
|
core.info(`Not an Error: ${error}`)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
if (error.name === cache.ReserveCacheError.name) {
|
if (error.name === cache.ReserveCacheError.name) {
|
||||||
core.info(error.message)
|
core.info(error.message)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,19 +1,25 @@
|
|||||||
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.startsWith('22.3.') && javaVersion === '11') {
|
||||||
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'
|
'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
|
return
|
||||||
}
|
}
|
||||||
const latestGraalVMVersion = await getLatestReleaseVersion()
|
|
||||||
|
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 (
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export async function downloadGraalVMEE(
|
|||||||
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.0.11 (arch:${c.GRAALVM_ARCH}; os:${c.GRAALVM_PLATFORM}; java:${javaVersion})`
|
||||||
const baseArtifact = await fetchArtifact(
|
const baseArtifact = await fetchArtifact(
|
||||||
userAgent,
|
userAgent,
|
||||||
'isBase:True',
|
'isBase:True',
|
||||||
|
|||||||
155
src/graalvm.ts
155
src/graalvm.ts
@@ -2,35 +2,38 @@ import * as c from './constants'
|
|||||||
import {
|
import {
|
||||||
downloadAndExtractJDK,
|
downloadAndExtractJDK,
|
||||||
downloadExtractAndCacheJDK,
|
downloadExtractAndCacheJDK,
|
||||||
getLatestRelease
|
getLatestRelease,
|
||||||
|
getTaggedRelease
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import {downloadGraalVMEE} from './gds'
|
import {downloadGraalVMEE} from './gds'
|
||||||
import {downloadTool} from '@actions/tool-cache'
|
import {downloadTool} from '@actions/tool-cache'
|
||||||
|
|
||||||
const GRAALVM_CE_DL_BASE =
|
const GRAALVM_CE_DL_BASE = `https://github.com/graalvm/${c.GRAALVM_RELEASES_REPO}/releases/download`
|
||||||
'https://github.com/graalvm/graalvm-ce-builds/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_TAG_PREFIX = 'vm-'
|
const GRAALVM_TAG_PREFIX = 'vm-'
|
||||||
|
|
||||||
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)) {
|
throw new Error(`Could not find latest GraalVM release: ${tag_name}`)
|
||||||
return tag_name.substring(GRAALVM_TAG_PREFIX.length, tag_name.length)
|
|
||||||
}
|
}
|
||||||
throw new Error(`Could not find latest GraalVM release: ${tag_name}`)
|
return tag_name.substring(GRAALVM_TAG_PREFIX.length, tag_name.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setUpGraalVMDevBuild(
|
export async function setUpGraalVMDevBuild(
|
||||||
@@ -41,20 +44,14 @@ export async function setUpGraalVMDevBuild(
|
|||||||
throw new Error('Downloading GraalVM EE dev builds is not supported')
|
throw new Error('Downloading GraalVM EE dev builds is not supported')
|
||||||
}
|
}
|
||||||
const latestDevBuild = await getLatestRelease(GRAALVM_REPO_DEV_BUILDS)
|
const latestDevBuild = await getLatestRelease(GRAALVM_REPO_DEV_BUILDS)
|
||||||
const graalVMIdentifier = determineGraalVMIdentifier(
|
let resolvedJavaVersion
|
||||||
false,
|
if (javaVersion == c.VERSION_DEV) {
|
||||||
'dev',
|
resolvedJavaVersion = findHighestJavaVersion(latestDevBuild, c.VERSION_DEV)
|
||||||
javaVersion
|
} else {
|
||||||
)
|
resolvedJavaVersion = 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(
|
const downloadUrl = findDownloadUrl(latestDevBuild, resolvedJavaVersion)
|
||||||
`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.`
|
return downloadAndExtractJDK(downloadUrl)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setUpGraalVMRelease(
|
export async function setUpGraalVMRelease(
|
||||||
@@ -63,34 +60,110 @@ 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 = determineToolName(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)
|
downloader = async () => downloadGraalVMEE(gdsToken, version, javaVersion)
|
||||||
} else {
|
} else {
|
||||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`
|
downloader = async () => downloadGraalVMCE(version, javaVersion)
|
||||||
downloader = async () => downloadTool(downloadUrl)
|
|
||||||
}
|
}
|
||||||
return downloadExtractAndCacheJDK(downloader, toolName, version)
|
return downloadExtractAndCacheJDK(downloader, toolName, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findHighestJavaVersion(
|
||||||
|
release: c.LatestReleaseResponse['data'],
|
||||||
|
version: string
|
||||||
|
): string {
|
||||||
|
const graalVMIdentifierPattern = determineGraalVMIdentifier(
|
||||||
|
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.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function findDownloadUrl(
|
||||||
|
release: c.LatestReleaseResponse['data'],
|
||||||
|
javaVersion: string
|
||||||
|
): string {
|
||||||
|
const graalVMIdentifier = determineGraalVMIdentifier(
|
||||||
|
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. If you think this is a mistake, please file an issue at: https://github.com/graalvm/setup-graalvm/issues.`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function determineGraalVMIdentifier(
|
function determineGraalVMIdentifier(
|
||||||
isEE: boolean,
|
isEE: boolean,
|
||||||
version: string,
|
version: string,
|
||||||
javaVersion: string
|
javaVersion: string
|
||||||
): string {
|
): string {
|
||||||
return `graalvm-${isEE ? 'ee' : 'ce'}-java${javaVersion}-${
|
return `${determineToolName(isEE, version, javaVersion)}-${
|
||||||
c.GRAALVM_PLATFORM
|
c.GRAALVM_ARCH
|
||||||
}-${c.GRAALVM_ARCH}-${version}`
|
}-${version}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function determineToolName(isEE: boolean, javaVersion: string): string {
|
function determineToolName(
|
||||||
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 downloadGraalVMCE(
|
||||||
|
version: string,
|
||||||
|
javaVersion: string
|
||||||
|
): Promise<string> {
|
||||||
|
const graalVMIdentifier = determineGraalVMIdentifier(
|
||||||
|
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}).`
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ async function run(): Promise<void> {
|
|||||||
const javaVersion = core.getInput(c.INPUT_JAVA_VERSION, {required: true})
|
const javaVersion = core.getInput(c.INPUT_JAVA_VERSION, {required: true})
|
||||||
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 cache = core.getInput(c.INPUT_CACHE)
|
||||||
const enableCheckForUpdates =
|
const enableCheckForUpdates =
|
||||||
@@ -27,7 +29,7 @@ async function run(): Promise<void> {
|
|||||||
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) {
|
||||||
|
|||||||
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()
|
||||||
|
|||||||
24
src/utils.ts
24
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,6 +47,22 @@ 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 downloadAndExtractJDK(
|
export async function downloadAndExtractJDK(
|
||||||
downloadUrl: string
|
downloadUrl: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
|||||||
Reference in New Issue
Block a user