diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 44bd71d..ea278cf 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -90553,10 +90553,10 @@ const c = __importStar(__nccwpck_require__(9042)); const core = __importStar(__nccwpck_require__(2186)); const fs = __importStar(__nccwpck_require__(7147)); const github = __importStar(__nccwpck_require__(5438)); +const semver = __importStar(__nccwpck_require__(1383)); const path_1 = __nccwpck_require__(1017); const os_1 = __nccwpck_require__(2037); const utils_1 = __nccwpck_require__(1314); -const semver_1 = __nccwpck_require__(1383); const BUILD_OUTPUT_JSON_PATH = (0, path_1.join)((0, os_1.tmpdir)(), 'native-image-build-output.json'); const BYTES_TO_KiB = 1024; const BYTES_TO_MiB = 1024 * 1024; @@ -90565,8 +90565,9 @@ const DOCS_BASE = 'https://github.com/oracle/graal/blob/master/docs/reference-ma const INPUT_NI_JOB_REPORTS = 'native-image-job-reports'; const INPUT_NI_PR_REPORTS = 'native-image-pr-reports'; const NATIVE_IMAGE_CONFIG_FILE = (0, path_1.join)((0, os_1.tmpdir)(), 'native-image-options.properties'); +const NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS'; const NATIVE_IMAGE_CONFIG_FILE_ENV = 'NATIVE_IMAGE_CONFIG_FILE'; -function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion) { +function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, javaVersionOrDev, graalVMVersion) { return __awaiter(this, void 0, void 0, function* () { const isRequired = areJobReportsEnabled() || arePRReportsEnabled(); if (!isRequired) { @@ -90576,12 +90577,12 @@ function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion) graalVMVersion === c.VERSION_LATEST || graalVMVersion === c.VERSION_DEV || (!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) && - (0, semver_1.gte)((0, utils_1.toSemVer)(graalVMVersion), '22.2.0')); + semver.gte((0, utils_1.toSemVer)(graalVMVersion), '22.2.0')); if (!isSupported) { core.warning(`Build reports for PRs and job summaries are only available in GraalVM 22.2.0 or later. This build job uses GraalVM ${graalVMVersion}.`); return; } - setNativeImageOption(`-H:BuildOutputJSONFile=${BUILD_OUTPUT_JSON_PATH.replace(/\\/g, '\\\\')}`); // Escape backslashes for Windows + setNativeImageOption(javaVersionOrDev, `-H:BuildOutputJSONFile=${BUILD_OUTPUT_JSON_PATH.replace(/\\/g, '\\\\')}`); // Escape backslashes for Windows }); } exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports; @@ -90611,6 +90612,30 @@ function areJobReportsEnabled() { function arePRReportsEnabled() { return (0, utils_1.isPREvent)() && core.getInput(INPUT_NI_PR_REPORTS) === 'true'; } +function setNativeImageOption(javaVersionOrDev, optionValue) { + const coercedJavaVersionOrDev = semver.coerce(javaVersionOrDev); + if ((coercedJavaVersionOrDev && + semver.gte(coercedJavaVersionOrDev, '22.0.0')) || + javaVersionOrDev === c.VERSION_DEV || + javaVersionOrDev.endsWith('-ea')) { + /* NATIVE_IMAGE_OPTIONS was introduced in GraalVM for JDK 22 (so were EA builds). */ + let newOptionValue = optionValue; + const existingOptions = process.env[NATIVE_IMAGE_OPTIONS_ENV]; + if (existingOptions) { + newOptionValue = `${existingOptions} ${newOptionValue}`; + } + core.exportVariable(NATIVE_IMAGE_OPTIONS_ENV, newOptionValue); + } + else { + const optionsFile = getNativeImageOptionsFile(); + if (fs.existsSync(optionsFile)) { + fs.appendFileSync(optionsFile, ` ${optionValue}`); + } + else { + fs.writeFileSync(optionsFile, `NativeImageArgs = ${optionValue}`); + } + } +} function getNativeImageOptionsFile() { let optionsFile = process.env[NATIVE_IMAGE_CONFIG_FILE_ENV]; if (optionsFile === undefined) { @@ -90619,15 +90644,6 @@ function getNativeImageOptionsFile() { } return optionsFile; } -function setNativeImageOption(value) { - const optionsFile = getNativeImageOptionsFile(); - if (fs.existsSync(optionsFile)) { - fs.appendFileSync(optionsFile, ` ${value}`); - } - else { - fs.writeFileSync(optionsFile, `NativeImageArgs = ${value}`); - } -} function createReport(data) { const context = github.context; const info = data.general_info; diff --git a/dist/main/index.js b/dist/main/index.js index 4a0f10d..5d74cc2 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -91333,10 +91333,10 @@ const c = __importStar(__nccwpck_require__(9042)); const core = __importStar(__nccwpck_require__(2186)); const fs = __importStar(__nccwpck_require__(7147)); const github = __importStar(__nccwpck_require__(5438)); +const semver = __importStar(__nccwpck_require__(1383)); const path_1 = __nccwpck_require__(1017); const os_1 = __nccwpck_require__(2037); const utils_1 = __nccwpck_require__(1314); -const semver_1 = __nccwpck_require__(1383); const BUILD_OUTPUT_JSON_PATH = (0, path_1.join)((0, os_1.tmpdir)(), 'native-image-build-output.json'); const BYTES_TO_KiB = 1024; const BYTES_TO_MiB = 1024 * 1024; @@ -91345,8 +91345,9 @@ const DOCS_BASE = 'https://github.com/oracle/graal/blob/master/docs/reference-ma const INPUT_NI_JOB_REPORTS = 'native-image-job-reports'; const INPUT_NI_PR_REPORTS = 'native-image-pr-reports'; const NATIVE_IMAGE_CONFIG_FILE = (0, path_1.join)((0, os_1.tmpdir)(), 'native-image-options.properties'); +const NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS'; const NATIVE_IMAGE_CONFIG_FILE_ENV = 'NATIVE_IMAGE_CONFIG_FILE'; -function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion) { +function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, javaVersionOrDev, graalVMVersion) { return __awaiter(this, void 0, void 0, function* () { const isRequired = areJobReportsEnabled() || arePRReportsEnabled(); if (!isRequired) { @@ -91356,12 +91357,12 @@ function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion) graalVMVersion === c.VERSION_LATEST || graalVMVersion === c.VERSION_DEV || (!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) && - (0, semver_1.gte)((0, utils_1.toSemVer)(graalVMVersion), '22.2.0')); + semver.gte((0, utils_1.toSemVer)(graalVMVersion), '22.2.0')); if (!isSupported) { core.warning(`Build reports for PRs and job summaries are only available in GraalVM 22.2.0 or later. This build job uses GraalVM ${graalVMVersion}.`); return; } - setNativeImageOption(`-H:BuildOutputJSONFile=${BUILD_OUTPUT_JSON_PATH.replace(/\\/g, '\\\\')}`); // Escape backslashes for Windows + setNativeImageOption(javaVersionOrDev, `-H:BuildOutputJSONFile=${BUILD_OUTPUT_JSON_PATH.replace(/\\/g, '\\\\')}`); // Escape backslashes for Windows }); } exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports; @@ -91391,6 +91392,30 @@ function areJobReportsEnabled() { function arePRReportsEnabled() { return (0, utils_1.isPREvent)() && core.getInput(INPUT_NI_PR_REPORTS) === 'true'; } +function setNativeImageOption(javaVersionOrDev, optionValue) { + const coercedJavaVersionOrDev = semver.coerce(javaVersionOrDev); + if ((coercedJavaVersionOrDev && + semver.gte(coercedJavaVersionOrDev, '22.0.0')) || + javaVersionOrDev === c.VERSION_DEV || + javaVersionOrDev.endsWith('-ea')) { + /* NATIVE_IMAGE_OPTIONS was introduced in GraalVM for JDK 22 (so were EA builds). */ + let newOptionValue = optionValue; + const existingOptions = process.env[NATIVE_IMAGE_OPTIONS_ENV]; + if (existingOptions) { + newOptionValue = `${existingOptions} ${newOptionValue}`; + } + core.exportVariable(NATIVE_IMAGE_OPTIONS_ENV, newOptionValue); + } + else { + const optionsFile = getNativeImageOptionsFile(); + if (fs.existsSync(optionsFile)) { + fs.appendFileSync(optionsFile, ` ${optionValue}`); + } + else { + fs.writeFileSync(optionsFile, `NativeImageArgs = ${optionValue}`); + } + } +} function getNativeImageOptionsFile() { let optionsFile = process.env[NATIVE_IMAGE_CONFIG_FILE_ENV]; if (optionsFile === undefined) { @@ -91399,15 +91424,6 @@ function getNativeImageOptionsFile() { } return optionsFile; } -function setNativeImageOption(value) { - const optionsFile = getNativeImageOptionsFile(); - if (fs.existsSync(optionsFile)) { - fs.appendFileSync(optionsFile, ` ${value}`); - } - else { - fs.writeFileSync(optionsFile, `NativeImageArgs = ${value}`); - } -} function createReport(data) { const context = github.context; const info = data.general_info; @@ -92524,7 +92540,7 @@ function run() { if (cache && (0, cache_1.isFeatureAvailable)()) { yield (0, cache_2.restore)(cache); } - (0, reports_1.setUpNativeImageBuildReports)(isGraalVMforJDK17OrLater, graalVMVersion); + (0, reports_1.setUpNativeImageBuildReports)(isGraalVMforJDK17OrLater, javaVersion, graalVMVersion); core.startGroup(`Successfully set up '${(0, path_1.basename)(graalVMHome)}'`); yield (0, exec_1.exec)((0, path_1.join)(graalVMHome, 'bin', `java${c.EXECUTABLE_SUFFIX}`), [ javaVersion.startsWith('8') ? '-version' : '--version' diff --git a/src/features/reports.ts b/src/features/reports.ts index 3504654..c2d1365 100644 --- a/src/features/reports.ts +++ b/src/features/reports.ts @@ -2,10 +2,10 @@ import * as c from '../constants' import * as core from '@actions/core' import * as fs from 'fs' import * as github from '@actions/github' +import * as semver from 'semver' import {join} from 'path' import {tmpdir} from 'os' import {createPRComment, isPREvent, toSemVer} from '../utils' -import {gte} from 'semver' const BUILD_OUTPUT_JSON_PATH = join(tmpdir(), 'native-image-build-output.json') const BYTES_TO_KiB = 1024 @@ -19,6 +19,7 @@ const NATIVE_IMAGE_CONFIG_FILE = join( tmpdir(), 'native-image-options.properties' ) +const NATIVE_IMAGE_OPTIONS_ENV = 'NATIVE_IMAGE_OPTIONS' const NATIVE_IMAGE_CONFIG_FILE_ENV = 'NATIVE_IMAGE_CONFIG_FILE' interface AnalysisResult { @@ -91,6 +92,7 @@ interface BuildOutput { export async function setUpNativeImageBuildReports( isGraalVMforJDK17OrLater: boolean, + javaVersionOrDev: string, graalVMVersion: string ): Promise { const isRequired = areJobReportsEnabled() || arePRReportsEnabled() @@ -102,7 +104,7 @@ export async function setUpNativeImageBuildReports( graalVMVersion === c.VERSION_LATEST || graalVMVersion === c.VERSION_DEV || (!graalVMVersion.startsWith(c.MANDREL_NAMESPACE) && - gte(toSemVer(graalVMVersion), '22.2.0')) + semver.gte(toSemVer(graalVMVersion), '22.2.0')) if (!isSupported) { core.warning( `Build reports for PRs and job summaries are only available in GraalVM 22.2.0 or later. This build job uses GraalVM ${graalVMVersion}.` @@ -110,6 +112,7 @@ export async function setUpNativeImageBuildReports( return } setNativeImageOption( + javaVersionOrDev, `-H:BuildOutputJSONFile=${BUILD_OUTPUT_JSON_PATH.replace(/\\/g, '\\\\')}` ) // Escape backslashes for Windows } @@ -144,6 +147,34 @@ function arePRReportsEnabled(): boolean { return isPREvent() && core.getInput(INPUT_NI_PR_REPORTS) === 'true' } +function setNativeImageOption( + javaVersionOrDev: string, + optionValue: string +): void { + const coercedJavaVersionOrDev = semver.coerce(javaVersionOrDev) + if ( + (coercedJavaVersionOrDev && + semver.gte(coercedJavaVersionOrDev, '22.0.0')) || + javaVersionOrDev === c.VERSION_DEV || + javaVersionOrDev.endsWith('-ea') + ) { + /* NATIVE_IMAGE_OPTIONS was introduced in GraalVM for JDK 22 (so were EA builds). */ + let newOptionValue = optionValue + const existingOptions = process.env[NATIVE_IMAGE_OPTIONS_ENV] + if (existingOptions) { + newOptionValue = `${existingOptions} ${newOptionValue}` + } + core.exportVariable(NATIVE_IMAGE_OPTIONS_ENV, newOptionValue) + } else { + const optionsFile = getNativeImageOptionsFile() + if (fs.existsSync(optionsFile)) { + fs.appendFileSync(optionsFile, ` ${optionValue}`) + } else { + fs.writeFileSync(optionsFile, `NativeImageArgs = ${optionValue}`) + } + } +} + function getNativeImageOptionsFile(): string { let optionsFile = process.env[NATIVE_IMAGE_CONFIG_FILE_ENV] if (optionsFile === undefined) { @@ -153,15 +184,6 @@ function getNativeImageOptionsFile(): string { return optionsFile } -function setNativeImageOption(value: string): void { - const optionsFile = getNativeImageOptionsFile() - if (fs.existsSync(optionsFile)) { - fs.appendFileSync(optionsFile, ` ${value}`) - } else { - fs.writeFileSync(optionsFile, `NativeImageArgs = ${value}`) - } -} - function createReport(data: BuildOutput): string { const context = github.context const info = data.general_info diff --git a/src/main.ts b/src/main.ts index 50ed996..75b373e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -160,7 +160,11 @@ async function run(): Promise { if (cache && isCacheAvailable()) { await restore(cache) } - setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion) + setUpNativeImageBuildReports( + isGraalVMforJDK17OrLater, + javaVersion, + graalVMVersion + ) core.startGroup(`Successfully set up '${basename(graalVMHome)}'`) await exec(join(graalVMHome, 'bin', `java${c.EXECUTABLE_SUFFIX}`), [