Skip to content

Commit dad12fe

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

File tree

2 files changed

+42
-44
lines changed

2 files changed

+42
-44
lines changed

common.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const crypto = require('crypto')
77
const core = require('@actions/core')
88
const tc = require('@actions/tool-cache')
99
const exec = require('@actions/exec')
10+
const common = require('./common')
1011
const { performance } = require('perf_hooks')
1112
const linuxOSInfo = require('linux-os-info')
1213

@@ -406,33 +407,31 @@ export function setupPath(newPathEntries) {
406407
}
407408

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

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

413-
let ret = await exec.exec('ruby', ['--version'])
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")
414419

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]
420+
let arch = os.arch()
421+
if (arch === "x64" || os.platform() !== "darwin") {
422+
arch = "X64"
423+
}
427424

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

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

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

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

dist/index.js

Lines changed: 21 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)