Skip to content

Commit

Permalink
Implement sanityRobo
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelpasterz committed Sep 25, 2020
1 parent 7678e81 commit 4978a4b
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class FladlePluginDelegate {
// Must be done afterEvaluate otherwise extension values will not be set.
project.dependencies.add(FLADLE_CONFIG, "${base.flankCoordinates.get()}:${base.flankVersion.get()}")

if (project.hasProperty("sanityRobo")) base.sanityRobo.set(true)

// Only use automatic apk path detection for 'com.android.application' projects.
project.pluginManager.withPlugin("com.android.application") {
if (!base.debugApk.isPresent || !base.instrumentationApk.isPresent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : Fl
@get:Input
val flankCoordinates: Property<String> = objects.property(String::class.java).convention("com.github.flank:flank")

@get:Input
val sanityRobo: Property<Boolean> = objects.property<Boolean>().convention(false)

@get:Input
val flankVersion: Property<String> = objects.property(String::class.java).convention("20.08.3")
// Project id is automatically discovered by default. Use this to override the project id.
Expand Down
20 changes: 11 additions & 9 deletions buildSrc/src/main/java/com/osacky/flank/gradle/YamlWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@ internal class YamlWriter {
check(base.serviceAccountCredentials.isPresent) { "ServiceAccountCredentials in fladle extension not set. https://github.com/runningcode/fladle#serviceaccountcredentials" }
}
check(base.debugApk.isPresent) { "debugApk must be specified" }
check(base.instrumentationApk.isPresent xor !base.roboScript.isNullOrBlank()) {
check(base.sanityRobo.get() == true || (base.instrumentationApk.isPresent xor !base.roboScript.isNullOrBlank())) {
"""
Either instrumentationApk file or roboScript file must be specified but not both.
instrumentationApk=${base.instrumentationApk.orNull}
roboScript=${base.roboScript}
""".trimIndent()
}

val shouldPrintTestAndRobo = base.sanityRobo.get().not()
val deviceString = createDeviceString(config.devices)
val additionalProperties = writeAdditionalProperties(config)
val flankProperties = writeFlankProperties(config)
val additionalProperties = writeAdditionalProperties(config, shouldPrintTestAndRobo)
val flankProperties = writeFlankProperties(config, shouldPrintTestAndRobo)

return buildString {
appendln("gcloud:")
appendln(" app: ${base.debugApk.get()}")
if (base.instrumentationApk.isPresent) {
// We don't want to print instrumentation apks if sanityRobo == true
if (shouldPrintTestAndRobo && base.instrumentationApk.isPresent) {
appendln(" test: ${base.instrumentationApk.get()}")
}
appendln(deviceString)
Expand All @@ -33,7 +35,7 @@ internal class YamlWriter {
}
}

internal fun writeFlankProperties(config: FladleConfig): String = buildString {
internal fun writeFlankProperties(config: FladleConfig, printApk: Boolean = true): String = buildString {
val testShards = config.testShards
val shardTime = config.shardTime
val repeatTests = config.repeatTests
Expand Down Expand Up @@ -73,7 +75,7 @@ internal class YamlWriter {
}
val additionalTestApks = config.additionalTestApks.getOrElse(emptyList())

if (additionalTestApks.isNotEmpty()) {
if (printApk && additionalTestApks.isNotEmpty()) {
appendln(" additional-app-test-apks:")
additionalTestApks.forEach {
appendln(" $it")
Expand Down Expand Up @@ -101,7 +103,7 @@ internal class YamlWriter {
appendln(" output-style: ${config.outputStyle.get()}")
}

internal fun writeAdditionalProperties(config: FladleConfig): String = buildString {
internal fun writeAdditionalProperties(config: FladleConfig, printRobo: Boolean = true): String = buildString {
appendln(" use-orchestrator: ${config.useOrchestrator}")
appendln(" auto-google-login: ${config.autoGoogleLogin}")
appendln(" record-video: ${config.recordVideo}")
Expand Down Expand Up @@ -166,11 +168,11 @@ internal class YamlWriter {
appendln(" network-profile: $it")
}

config.roboScript?.let {
if (printRobo) config.roboScript?.let {
appendln(" robo-script: $it")
}

if (config.roboDirectives.isNotEmpty()) {
if (printRobo && config.roboDirectives.isNotEmpty()) {
appendln(" robo-directives:")
config.roboDirectives.forEach {
val value = it.getOrElse(2) { "" }.let { stringValue -> if (stringValue.isBlank()) "\"\"" else stringValue }
Expand Down
Loading

0 comments on commit 4978a4b

Please sign in to comment.