Skip to content

Commit

Permalink
Add bugsnag
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Feb 23, 2019
1 parent 5b0d232 commit 1db54d9
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
2 changes: 2 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## v?

- Add bugsnag reporting to detect Flank crashes.

## v4.4.0

- [#505](https://github.com/TestArmada/flank/pull/505) Fix `flank auth login` by using `google-auth-library-java`. ([bootstraponline](https://github.com/bootstraponline))
Expand Down
2 changes: 2 additions & 0 deletions test_runner/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ dependencies {
compile(Libs.KOTLIN_STD_LIB)
compile(Libs.KOTLIN_COROUTINES_CORE)

compile("com.bugsnag:bugsnag:3.+")

// https://github.com/remkop/picocli/releases
compile("info.picocli:picocli:3.9.0")
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.6")
Expand Down
12 changes: 7 additions & 5 deletions test_runner/src/main/kotlin/ftl/Main.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package ftl

import com.bugsnag.Bugsnag
import ftl.cli.AuthCommand
import ftl.cli.FirebaseCommand
import ftl.cli.firebase.CancelCommand
import ftl.cli.firebase.RefreshCommand
import ftl.cli.firebase.test.AndroidCommand
import ftl.cli.firebase.test.IosCommand
import ftl.config.FtlConstants
import ftl.config.FtlConstants.bugsnag
import ftl.util.Utils.readRevision
import ftl.util.Utils.readTextResource
import ftl.util.Utils.readVersion
import picocli.CommandLine

@CommandLine.Command(
Expand All @@ -24,11 +29,8 @@ import picocli.CommandLine
class Main : Runnable {
override fun run() {
if (printVersion) {
// inline functions like .trim aren't counted as code coverage
// https://github.com/jacoco/jacoco/issues/654
// https://github.com/jacoco/jacoco/issues/754
val version = readTextResource("version.txt").trim()
println(version)
println(readVersion())
println(readRevision())
} else {
CommandLine.usage(Main::class.java, System.out)
}
Expand Down
14 changes: 14 additions & 0 deletions test_runner/src/main/kotlin/ftl/config/FtlConstants.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package ftl.config

import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import com.bugsnag.Bugsnag
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport
import com.google.api.client.googleapis.util.Utils
import com.google.api.client.http.HttpRequestInitializer
Expand All @@ -13,9 +16,13 @@ import ftl.args.IArgs
import ftl.args.IosArgs
import ftl.gc.UserAuth
import ftl.http.HttpTimeoutIncrease
import ftl.util.Utils.readRevision
import ftl.util.Utils.readVersion
import java.nio.file.Path
import java.nio.file.Paths
import java.util.Date
import org.slf4j.LoggerFactory


object FtlConstants {
var useMock = false
Expand All @@ -36,6 +43,13 @@ object FtlConstants {
const val GCS_PREFIX = "gs://"
val JSON_FACTORY: JsonFactory by lazy { Utils.getDefaultJsonFactory() }

val bugsnag = Bugsnag(if (useMock) null else "3d5f8ba4ee847d6bb51cb9c347eda74f")

init {
bugsnag.setAppVersion(readRevision())
(LoggerFactory.getLogger(Bugsnag::class.java) as Logger).level = Level.OFF
}

val httpTransport: NetHttpTransport by lazy {
try {
return@lazy GoogleNetHttpTransport.newTrustedTransport()
Expand Down
10 changes: 10 additions & 0 deletions test_runner/src/main/kotlin/ftl/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ object Utils {
?: throw RuntimeException("Unable to find resource: $name")
}

// app version: flank_snapshot
fun readVersion(): String {
return readTextResource("version.txt").trim()
}

// git commit name: 5b0d23215e3bd90e5f9c1c57149320634aad8008
fun readRevision(): String {
return readTextResource("revision.txt").trim()
}

fun readTextResource(name: String): String {
return getResource(name).bufferedReader().use { it.readText() }
}
Expand Down
1 change: 1 addition & 0 deletions test_runner/src/main/resources/revision.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
unknown
2 changes: 1 addition & 1 deletion test_runner/src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
flank_snapshot
unknown

0 comments on commit 1db54d9

Please sign in to comment.