Don't use virtual io by default in CI

The CI output logs for the sbt build are truncated when using sbt
1.4.0-M2 because the virtual tty provided by the build agent doesn't
seem to work well with sbt's virtual io.
This commit is contained in:
Ethan Atkins 2020-08-19 11:21:53 -07:00
parent 85a0d08a4e
commit f0055cd18a
1 changed files with 6 additions and 3 deletions

View File

@ -171,6 +171,8 @@ object Terminal {
// Disable noisy jline log spam
if (System.getProperty("sbt.jline.verbose", "false") != "true")
jline.internal.Log.setOutput(new PrintStream(_ => {}, false))
private[this] val isCI = System.getProperty("sbt.ci", "") == "true" ||
sys.env.contains("BUILD_NUMBER") || sys.env.contains("CI")
def consoleLog(string: String): Unit = {
try Terminal.console.printStream.println(s"[info] $string")
catch { case _: IOException => }
@ -281,7 +283,9 @@ object Terminal {
* @return the result of the thunk
*/
private[sbt] def withStreams[T](isServer: Boolean)(f: => T): T =
if (System.getProperty("sbt.io.virtual", "true") == "true") {
// In ci environments, don't touch the io streams unless run with -Dsbt.io.virtual=true
if (isCI && System.getProperty("sbt.io.virtual", "") != "true") f
else {
hasProgress.set(isServer)
consoleTerminalHolder.set(wrap(jline.TerminalFactory.get))
activeTerminal.set(consoleTerminalHolder.get)
@ -313,7 +317,7 @@ object Terminal {
console.close()
}
}
} else f
}
private[this] object ProxyTerminal extends Terminal {
private def t: Terminal = activeTerminal.get
@ -775,7 +779,6 @@ object Terminal {
val size = system.getSize
(size.getColumns, size.getRows)
}
private[this] val isCI = sys.env.contains("BUILD_NUMBER") || sys.env.contains("CI")
override lazy val isAnsiSupported: Boolean = term.isAnsiSupported && !isCI
override private[sbt] def progressState: ProgressState = consoleProgressState.get
override def isEchoEnabled: Boolean = system.echo()