Skip to content

Commit d69712b

Browse files
committed
Use measure to track JAVA_HOME setup time
1 parent 2e82a48 commit d69712b

File tree

2 files changed

+40
-44
lines changed

2 files changed

+40
-44
lines changed

common.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -406,33 +406,31 @@ export function setupPath(newPathEntries) {
406406
}
407407

408408
export async function setupJavaHome() {
409-
core.startGroup(`Modifying JAVA_HOME for JRuby`)
409+
common.measure("Modifying JAVA_HOME for JRuby", async () => {
410+
console.log("attempting to run with existing JAVA_HOME")
410411

411-
console.log("attempting to run with existing JAVA_HOME")
412+
let ret = await exec.exec('ruby', ['--version'])
412413

413-
let ret = await exec.exec('ruby', ['--version'])
414+
if (ret === 0) {
415+
console.log("JRuby successfully starts, using existing JAVA_HOME")
416+
} else {
417+
console.log("JRuby failed to start, try Java 21 envs")
414418

415-
if (ret === 0) {
416-
console.log("JRuby successfully starts, using existing JAVA_HOME")
417-
} else {
418-
console.log("JRuby failed to start, try Java 21 envs")
419-
420-
let arch = os.arch()
421-
if (arch === "x64" || os.platform() !== "darwin") {
422-
arch = "X64"
423-
}
424-
425-
let newHomeVar = `JAVA_HOME_21_${arch}`
426-
let newHome = process.env[newHomeVar]
419+
let arch = os.arch()
420+
if (arch === "x64" || os.platform() !== "darwin") {
421+
arch = "X64"
422+
}
427423

428-
if (newHome === "undefined") {
429-
throw new Error(`JAVA_HOME is not Java 21+ needed for JRuby and \$${newHomeVar} is not defined`)
430-
}
424+
let newHomeVar = `JAVA_HOME_21_${arch}`
425+
let newHome = process.env[newHomeVar]
431426

432-
console.log(`Setting JAVA_HOME to ${newHomeVar} path ${newHome}`)
427+
if (newHome === "undefined") {
428+
throw new Error(`JAVA_HOME is not Java 21+ needed for JRuby and \$${newHomeVar} is not defined`)
429+
}
433430

434-
core.exportVariable("JAVA_HOME", newHome)
435-
}
431+
console.log(`Setting JAVA_HOME to ${newHomeVar} path ${newHome}`)
436432

437-
core.endGroup()
433+
core.exportVariable("JAVA_HOME", newHome)
434+
}
435+
})
438436
}

dist/index.js

Lines changed: 20 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)