Configure --info and --stacktrace when GitHub ACTIONS_RUNNER_DEBUG is true

Fixes #6
This commit is contained in:
hfhbd
2024-01-29 23:21:40 +01:00
committed by daz
parent 79414b4f92
commit f4f7af32dc
5 changed files with 63 additions and 1 deletions

View File

@@ -192,6 +192,10 @@ export class GradleStateCache {
// Copy the default toolchain definitions to `~/.m2/toolchains.xml`
this.registerToolchains()
if (core.isDebug()) {
this.configureInfoLogLevel()
}
}
private copyInitScripts(): void {
@@ -240,6 +244,23 @@ export class GradleStateCache {
return fs.readFileSync(absolutePath, 'utf8')
}
/**
* When the GitHub environment ACTIONS_RUNNER_DEBUG is true, run Gradle with --info and --stacktrace.
* see https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging
*/
configureInfoLogLevel(): void {
const infoProperties = `org.gradle.logging.level=info\norg.gradle.logging.stacktrace=all\n`
const propertiesFile = path.resolve(this.gradleUserHome, 'gradle.properties')
if (fs.existsSync(propertiesFile)) {
core.info(`Merged --info and --stacktrace into existing ${propertiesFile} file`)
const existingProperties = fs.readFileSync(propertiesFile, 'utf-8')
fs.writeFileSync(propertiesFile, `${infoProperties}\n${existingProperties}`)
} else {
core.info(`Created a new ${propertiesFile} with --info and --stacktrace`)
fs.writeFileSync(propertiesFile, infoProperties)
}
}
/**
* When cache debugging is enabled, this method will give a detailed report
* of the Gradle User Home contents.