Compare commits
7 Commits
v1.0.9
...
fniephaus/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4aba115fa5 | ||
|
|
7c84ab1ba7 | ||
|
|
778af55c2a | ||
|
|
a20b6434b3 | ||
|
|
2ada328403 | ||
|
|
254814bb57 | ||
|
|
79e8ca0cfa |
10
README.md
10
README.md
@@ -60,7 +60,7 @@ jobs:
|
|||||||
- uses: graalvm/setup-graalvm@v1
|
- uses: graalvm/setup-graalvm@v1
|
||||||
with:
|
with:
|
||||||
version: '22.3.0'
|
version: '22.3.0'
|
||||||
java-version: '11'
|
java-version: '17'
|
||||||
components: 'native-image'
|
components: 'native-image'
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
native-image-job-reports: 'true'
|
native-image-job-reports: 'true'
|
||||||
@@ -100,7 +100,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: '22.3.0'
|
version: '22.3.0'
|
||||||
gds-token: ${{ secrets.GDS_TOKEN }}
|
gds-token: ${{ secrets.GDS_TOKEN }}
|
||||||
java-version: '11'
|
java-version: '17'
|
||||||
components: 'native-image'
|
components: 'native-image'
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Example step
|
- name: Example step
|
||||||
@@ -114,16 +114,16 @@ jobs:
|
|||||||
|
|
||||||
| Name | Default | Description |
|
| Name | Default | Description |
|
||||||
|-----------------|:--------:|-------------|
|
|-----------------|:--------:|-------------|
|
||||||
| `version`<br>*(required)* | n/a | `X.Y.Z` (e.g., `21.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 | `'11'` or `'17'` for a specific Java version.<br>(`'8'` and `'16'` are supported for GraalVM 21.2 and earlier.) |
|
| `java-version`<br>*(required)* | n/a | `'17'` or `'19'` for a specific Java version.<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` | `''` | 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. |
|
||||||
| `native-image-job-reports` *) | `'false'` | If set to `'true'`, post a job summary containing a Native Image build report. |
|
|
||||||
| `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-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]. |
|
||||||
|
|
||||||
**) 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.*
|
||||||
|
|||||||
25
__tests__/graalvm.test.ts
Normal file
25
__tests__/graalvm.test.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import * as path from 'path'
|
||||||
|
import * as graalvm from '../src/graalvm'
|
||||||
|
import {expect, test} from '@jest/globals'
|
||||||
|
|
||||||
|
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
|
||||||
|
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
|
||||||
|
|
||||||
|
test('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) {
|
||||||
|
error = err
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).not.toBeUndefined()
|
||||||
|
expect(error.message).toContain('Failed to download')
|
||||||
|
expect(error.message).toContain('Are you sure version')
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -45,6 +45,9 @@ 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'
|
||||||
|
outputs:
|
||||||
|
cache-hit:
|
||||||
|
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
main: 'dist/main/index.js'
|
main: 'dist/main/index.js'
|
||||||
|
|||||||
21
dist/cleanup/index.js
generated
vendored
21
dist/cleanup/index.js
generated
vendored
@@ -73781,7 +73781,7 @@ function saveCache() {
|
|||||||
* @param promise the promise to ignore error from
|
* @param promise the promise to ignore error from
|
||||||
* @returns Promise that will ignore error reported by the given promise
|
* @returns Promise that will ignore error reported by the given promise
|
||||||
*/
|
*/
|
||||||
function ignoreError(promise) {
|
function ignoreErrors(promise) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
/* eslint-disable github/no-then */
|
/* eslint-disable github/no-then */
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -73796,8 +73796,8 @@ function ignoreError(promise) {
|
|||||||
}
|
}
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
reports_1.generateReports();
|
yield ignoreErrors(reports_1.generateReports());
|
||||||
yield ignoreError(saveCache());
|
yield ignoreErrors(saveCache());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
@@ -74151,6 +74151,7 @@ function setUpNativeImageBuildReports(graalVMVersion) {
|
|||||||
}
|
}
|
||||||
exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports;
|
exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports;
|
||||||
function generateReports() {
|
function generateReports() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (areJobReportsEnabled() || arePRReportsEnabled()) {
|
if (areJobReportsEnabled() || arePRReportsEnabled()) {
|
||||||
if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) {
|
if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) {
|
||||||
core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?');
|
core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?');
|
||||||
@@ -74166,6 +74167,7 @@ function generateReports() {
|
|||||||
utils_1.createPRComment(report);
|
utils_1.createPRComment(report);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
exports.generateReports = generateReports;
|
exports.generateReports = generateReports;
|
||||||
function areJobReportsEnabled() {
|
function areJobReportsEnabled() {
|
||||||
@@ -74413,9 +74415,9 @@ const fs_1 = __nccwpck_require__(7147);
|
|||||||
const core_1 = __nccwpck_require__(6762);
|
const core_1 = __nccwpck_require__(6762);
|
||||||
const crypto_1 = __nccwpck_require__(6113);
|
const crypto_1 = __nccwpck_require__(6113);
|
||||||
const path_1 = __nccwpck_require__(1017);
|
const path_1 = __nccwpck_require__(1017);
|
||||||
// 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 = core_1.Octokit.defaults({
|
const GitHubDotCom = core_1.Octokit.defaults({
|
||||||
baseUrl,
|
baseUrl,
|
||||||
request: {
|
request: {
|
||||||
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
||||||
@@ -74436,7 +74438,7 @@ function getLatestRelease(repo) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
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 (yield octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
return (yield octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||||
owner: c.GRAALVM_GH_USER,
|
owner: c.GRAALVM_GH_USER,
|
||||||
repo
|
repo
|
||||||
@@ -74521,7 +74523,12 @@ function createPRComment(content) {
|
|||||||
throw new Error('Not a PR event.');
|
throw new Error('Not a PR event.');
|
||||||
}
|
}
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
|
try {
|
||||||
yield github.getOctokit(getGitHubToken()).rest.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.number, body: content }));
|
yield github.getOctokit(getGitHubToken()).rest.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.number, body: content }));
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
core.error(`Failed to create pull request comment. Please make sure this job has 'write' permissions for the 'pull-requests' scope (see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)? Internal error: ${err}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.createPRComment = createPRComment;
|
exports.createPRComment = createPRComment;
|
||||||
|
|||||||
37
dist/main/index.js
generated
vendored
37
dist/main/index.js
generated
vendored
@@ -74253,6 +74253,7 @@ function setUpNativeImageBuildReports(graalVMVersion) {
|
|||||||
}
|
}
|
||||||
exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports;
|
exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports;
|
||||||
function generateReports() {
|
function generateReports() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (areJobReportsEnabled() || arePRReportsEnabled()) {
|
if (areJobReportsEnabled() || arePRReportsEnabled()) {
|
||||||
if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) {
|
if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) {
|
||||||
core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?');
|
core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?');
|
||||||
@@ -74268,6 +74269,7 @@ function generateReports() {
|
|||||||
utils_1.createPRComment(report);
|
utils_1.createPRComment(report);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
exports.generateReports = generateReports;
|
exports.generateReports = generateReports;
|
||||||
function areJobReportsEnabled() {
|
function areJobReportsEnabled() {
|
||||||
@@ -74738,22 +74740,20 @@ function setUpGraalVMDevBuild(gdsToken, javaVersion) {
|
|||||||
return utils_1.downloadAndExtractJDK(asset.browser_download_url);
|
return utils_1.downloadAndExtractJDK(asset.browser_download_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Error('Could not find GraalVM dev build');
|
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.`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.setUpGraalVMDevBuild = setUpGraalVMDevBuild;
|
exports.setUpGraalVMDevBuild = setUpGraalVMDevBuild;
|
||||||
function setUpGraalVMRelease(gdsToken, version, javaVersion) {
|
function setUpGraalVMRelease(gdsToken, version, javaVersion) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const isEE = gdsToken.length > 0;
|
const isEE = gdsToken.length > 0;
|
||||||
const graalVMIdentifier = determineGraalVMIdentifier(isEE, version, javaVersion);
|
|
||||||
const toolName = determineToolName(isEE, javaVersion);
|
const toolName = determineToolName(isEE, javaVersion);
|
||||||
let downloader;
|
let downloader;
|
||||||
if (isEE) {
|
if (isEE) {
|
||||||
downloader = () => __awaiter(this, void 0, void 0, function* () { return gds_1.downloadGraalVMEE(gdsToken, version, javaVersion); });
|
downloader = () => __awaiter(this, void 0, void 0, function* () { return gds_1.downloadGraalVMEE(gdsToken, version, javaVersion); });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`;
|
downloader = () => __awaiter(this, void 0, void 0, function* () { return downloadGraalVMCE(version, javaVersion); });
|
||||||
downloader = () => __awaiter(this, void 0, void 0, function* () { return tool_cache_1.downloadTool(downloadUrl); });
|
|
||||||
}
|
}
|
||||||
return utils_1.downloadExtractAndCacheJDK(downloader, toolName, version);
|
return utils_1.downloadExtractAndCacheJDK(downloader, toolName, version);
|
||||||
});
|
});
|
||||||
@@ -74765,6 +74765,22 @@ function determineGraalVMIdentifier(isEE, version, javaVersion) {
|
|||||||
function determineToolName(isEE, javaVersion) {
|
function determineToolName(isEE, javaVersion) {
|
||||||
return `graalvm-${isEE ? 'ee' : 'ce'}-java${javaVersion}-${c.GRAALVM_PLATFORM}`;
|
return `graalvm-${isEE ? 'ee' : 'ce'}-java${javaVersion}-${c.GRAALVM_PLATFORM}`;
|
||||||
}
|
}
|
||||||
|
function downloadGraalVMCE(version, javaVersion) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const graalVMIdentifier = determineGraalVMIdentifier(false, version, javaVersion);
|
||||||
|
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`;
|
||||||
|
try {
|
||||||
|
return yield tool_cache_1.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 javaVersion: '${javaVersion}' are correct?`);
|
||||||
|
}
|
||||||
|
throw new Error(`Failed to download ${graalVMIdentifier} (error: ${error}).`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -75160,9 +75176,9 @@ const fs_1 = __nccwpck_require__(7147);
|
|||||||
const core_1 = __nccwpck_require__(6762);
|
const core_1 = __nccwpck_require__(6762);
|
||||||
const crypto_1 = __nccwpck_require__(6113);
|
const crypto_1 = __nccwpck_require__(6113);
|
||||||
const path_1 = __nccwpck_require__(1017);
|
const path_1 = __nccwpck_require__(1017);
|
||||||
// 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 = core_1.Octokit.defaults({
|
const GitHubDotCom = core_1.Octokit.defaults({
|
||||||
baseUrl,
|
baseUrl,
|
||||||
request: {
|
request: {
|
||||||
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
||||||
@@ -75183,7 +75199,7 @@ function getLatestRelease(repo) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
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 (yield octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
return (yield octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||||
owner: c.GRAALVM_GH_USER,
|
owner: c.GRAALVM_GH_USER,
|
||||||
repo
|
repo
|
||||||
@@ -75268,7 +75284,12 @@ function createPRComment(content) {
|
|||||||
throw new Error('Not a PR event.');
|
throw new Error('Not a PR event.');
|
||||||
}
|
}
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
|
try {
|
||||||
yield github.getOctokit(getGitHubToken()).rest.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.number, body: content }));
|
yield github.getOctokit(getGitHubToken()).rest.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.number, body: content }));
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
core.error(`Failed to create pull request comment. Please make sure this job has 'write' permissions for the 'pull-requests' scope (see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)? Internal error: ${err}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.createPRComment = createPRComment;
|
exports.createPRComment = createPRComment;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ async function saveCache(): Promise<void> {
|
|||||||
* @param promise the promise to ignore error from
|
* @param promise the promise to ignore error from
|
||||||
* @returns Promise that will ignore error reported by the given promise
|
* @returns Promise that will ignore error reported by the given promise
|
||||||
*/
|
*/
|
||||||
async function ignoreError(promise: Promise<void>): Promise<unknown> {
|
async function ignoreErrors(promise: Promise<void>): Promise<unknown> {
|
||||||
/* eslint-disable github/no-then */
|
/* eslint-disable github/no-then */
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
promise
|
promise
|
||||||
@@ -57,8 +57,8 @@ async function ignoreError(promise: Promise<void>): Promise<unknown> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
generateReports()
|
await ignoreErrors(generateReports())
|
||||||
await ignoreError(saveCache())
|
await ignoreErrors(saveCache())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export async function setUpNativeImageBuildReports(
|
|||||||
) // Escape backslashes for Windows
|
) // Escape backslashes for Windows
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generateReports(): void {
|
export async function generateReports(): Promise<void> {
|
||||||
if (areJobReportsEnabled() || arePRReportsEnabled()) {
|
if (areJobReportsEnabled() || arePRReportsEnabled()) {
|
||||||
if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) {
|
if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) {
|
||||||
core.warning(
|
core.warning(
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ export async function setUpGraalVMDevBuild(
|
|||||||
return downloadAndExtractJDK(asset.browser_download_url)
|
return downloadAndExtractJDK(asset.browser_download_url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Error('Could not find GraalVM dev build')
|
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(
|
||||||
@@ -61,18 +63,12 @@ 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(
|
|
||||||
isEE,
|
|
||||||
version,
|
|
||||||
javaVersion
|
|
||||||
)
|
|
||||||
const toolName = determineToolName(isEE, 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)
|
||||||
}
|
}
|
||||||
@@ -92,3 +88,28 @@ function determineToolName(isEE: boolean, javaVersion: string): string {
|
|||||||
c.GRAALVM_PLATFORM
|
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 javaVersion: '${javaVersion}' are correct?`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
`Failed to download ${graalVMIdentifier} (error: ${error}).`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
14
src/utils.ts
14
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,
|
||||||
@@ -127,9 +127,15 @@ export async function createPRComment(content: string): Promise<void> {
|
|||||||
throw new Error('Not a PR event.')
|
throw new Error('Not a PR event.')
|
||||||
}
|
}
|
||||||
const context = github.context
|
const context = github.context
|
||||||
|
try {
|
||||||
await github.getOctokit(getGitHubToken()).rest.issues.createComment({
|
await github.getOctokit(getGitHubToken()).rest.issues.createComment({
|
||||||
...context.repo,
|
...context.repo,
|
||||||
issue_number: context.payload.pull_request?.number as number,
|
issue_number: context.payload.pull_request?.number as number,
|
||||||
body: content
|
body: content
|
||||||
})
|
})
|
||||||
|
} catch (err) {
|
||||||
|
core.error(
|
||||||
|
`Failed to create pull request comment. Please make sure this job has 'write' permissions for the 'pull-requests' scope (see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)? Internal error: ${err}`
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user