-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support roboTest without roboScript (sanityRobo) #177
Changes from all commits
cbb00ae
abed478
3095ac1
79b0e11
e4dd6ee
750ae1b
f08f456
1a6c8b6
e4b1e1f
cd22c9b
65213bd
82cd138
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : Fl | |
@get:Input | ||
val flankCoordinates: Property<String> = objects.property(String::class.java).convention("com.github.flank:flank") | ||
|
||
override val sanityRobo: Property<Boolean> = objects.property<Boolean>().convention(false) | ||
|
||
@get:Input | ||
val flankVersion: Property<String> = objects.property(String::class.java).convention("20.09.3") | ||
// Project id is automatically discovered by default. Use this to override the project id. | ||
|
@@ -50,12 +52,9 @@ open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : Fl | |
/** | ||
* debugApk and instrumentationApk are [Property<String>] and not [RegularFileProperty] because we support wildcard characters. | ||
*/ | ||
@get:Input | ||
@get:Optional | ||
val debugApk: Property<String> = objects.property() | ||
@get:Input | ||
@get:Optional | ||
val instrumentationApk: Property<String> = objects.property() | ||
override val debugApk: Property<String> = objects.property() | ||
|
||
override val instrumentationApk: Property<String> = objects.property() | ||
|
||
override val directoriesToPull: ListProperty<String> = objects.listProperty() | ||
|
||
pawelpasterz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -115,6 +114,9 @@ open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : Fl | |
name = it, | ||
projectId = objects.property<String>().convention(projectId), | ||
serviceAccountCredentials = objects.fileProperty().convention(serviceAccountCredentials), | ||
debugApk = objects.property<String>().convention(debugApk), | ||
instrumentationApk = objects.property<String>().convention(instrumentationApk), | ||
sanityRobo = objects.property<Boolean>().convention(false), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we be passing the value from the base here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we shouldn't. Assuming we have Of course, I can change it to behave otherwise. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You make a good point here. I think we want consistency though. All other values are inherited. We shouldn't assume that users will not try to have multiple different |
||
useOrchestrator = objects.property<Boolean>().convention(useOrchestrator), | ||
autoGoogleLogin = objects.property<Boolean>().convention(autoGoogleLogin), | ||
devices = objects.listProperty<Map<String, String>>().convention(devices), | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||||
package com.osacky.flank.gradle | ||||||
|
||||||
import org.gradle.api.GradleException | ||||||
import org.gradle.api.provider.ListProperty | ||||||
import org.gradle.api.provider.Property | ||||||
|
||||||
@Throws(GradleException::class) | ||||||
fun checkIfSanityAndValidateConfigs(config: FladleConfig) = when (config) { | ||||||
is FlankGradleExtension -> config.checkAndValidateConfig() { option, _ -> | ||||||
"Incorrect [base] configuration. [$option] can't be used together with sanityRobo." | ||||||
} | ||||||
is FladleConfigImpl -> config.checkAndValidateConfig(config.name) { option, name -> | ||||||
"Incorrect [$name] configuration. [$option] can't be used together with sanityRobo. " + | ||||||
"If you want to launch robo test run without robo script place only clearPropertiesForSanityRobo() into [$name] configuration" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'm changing the wording here a bit because a robo test run could also be with the robo directives. In that case, these instructions could be confusing. Let's refer specifically to |
||||||
} | ||||||
else -> throw GradleException("Unable to check for sanity, check config type") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's throw an |
||||||
} | ||||||
|
||||||
private fun FladleConfig.checkAndValidateConfig(name: String = "base", message: (String, String) -> String) { | ||||||
if (sanityRobo.getOrElse(false)) when { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should just get the default value since it is already set to
Suggested change
|
||||||
roboDirectives.isNotPresentOrEmpty -> throw GradleException(message("roboDirectives", name)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think an |
||||||
roboScript.isNotPresentOrBlank -> throw GradleException(message("roboScript", name)) | ||||||
instrumentationApk.isNotPresentOrBlank -> throw GradleException(message("instrumentationApk", name)) | ||||||
additionalTestApks.isNotPresentOrEmpty -> throw GradleException(message("additionalTestApks", name)) | ||||||
} | ||||||
} | ||||||
|
||||||
private val Property<String>.isNotPresentOrBlank | ||||||
get() = orNull.isNullOrBlank().not() | ||||||
|
||||||
private val <T> ListProperty<T>.isNotPresentOrEmpty | ||||||
get() = getOrElse(emptyList()).isEmpty().not() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,27 +12,31 @@ 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.orNull.isNullOrBlank()) { | ||
val prefix = if (base.instrumentationApk.isPresent && !base.roboScript.orNull.isNullOrBlank()) { | ||
"Both instrumentationApk file and roboScript file were specified, but only one is expected." | ||
} else { | ||
"Must specify either a instrumentationApk file or a roboScript file." | ||
} | ||
""" | ||
if (config.sanityRobo.get() == false) { | ||
check(config.instrumentationApk.isPresent xor !config.roboScript.orNull.isNullOrBlank()) { | ||
val prefix = if (base.instrumentationApk.isPresent && !config.roboScript.orNull.isNullOrBlank()) { | ||
"Both instrumentationApk file and roboScript file were specified, but only one is expected." | ||
} else { | ||
"Must specify either a instrumentationApk file or a roboScript file." | ||
} | ||
""" | ||
$prefix | ||
instrumentationApk=${base.instrumentationApk.orNull} | ||
roboScript=${base.roboScript.orNull} | ||
""".trimIndent() | ||
instrumentationApk=${config.instrumentationApk.orNull} | ||
roboScript=${config.roboScript.orNull} | ||
""".trimIndent() | ||
} | ||
} | ||
|
||
val shouldPrintTestAndRobo = config.sanityRobo.get().not() | ||
val additionalProperties = writeAdditionalProperties(config) | ||
val flankProperties = writeFlankProperties(config) | ||
|
||
return buildString { | ||
appendln("gcloud:") | ||
appendln(" app: ${base.debugApk.get()}") | ||
if (base.instrumentationApk.isPresent) { | ||
appendln(" test: ${base.instrumentationApk.get()}") | ||
appendln(" app: ${config.debugApk.get()}") | ||
// We don't want to print instrumentation apks if sanityRobo == true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we throw an error here if sanityRobo is true? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sanity run validation if the user sets So actually this is applicable only for case when Logic could be simplified if we would agree that |
||
if (shouldPrintTestAndRobo && config.instrumentationApk.isPresent) { | ||
appendln(" test: ${config.instrumentationApk.get()}") | ||
} | ||
if (config.devices.isPresentAndNotEmpty) appendln(createDeviceString(config.devices.get())) | ||
appendln(additionalProperties) | ||
|
@@ -50,7 +54,8 @@ internal class YamlWriter { | |
appendProperty(config.projectId, name = "project") | ||
appendProperty(config.keepFilePath, name = "keep-file-path") | ||
appendListProperty(config.filesToDownload, name = "files-to-download") { appendln(" - $it") } | ||
appendListProperty(config.additionalTestApks, name = "additional-app-test-apks") { appendln(" $it") } | ||
if (!config.sanityRobo.get()) | ||
appendListProperty(config.additionalTestApks, name = "additional-app-test-apks") { appendln(" $it") } | ||
appendProperty(config.runTimeout, name = "run-timeout") | ||
appendProperty(config.ignoreFailedTests, name = "ignore-failed-tests") | ||
appendProperty(config.disableSharding, name = "disable-sharding") | ||
|
@@ -82,10 +87,12 @@ internal class YamlWriter { | |
appendMapProperty(config.clientDetails, name = "client-details") { appendln(" ${it.key}: ${it.value}") } | ||
appendMapProperty(config.otherFiles, name = "other-files") { appendln(" ${it.key}: ${it.value}") } | ||
appendProperty(config.networkProfile, name = "network-profile") | ||
appendProperty(config.roboScript, name = "robo-script") | ||
appendListProperty(config.roboDirectives, name = "robo-directives") { | ||
val value = it.getOrElse(2) { "" }.let { stringValue -> if (stringValue.isBlank()) "\"\"" else stringValue } | ||
appendln(" ${it[0]}:${it[1]}: $value") | ||
if (!config.sanityRobo.get()) { | ||
appendProperty(config.roboScript, name = "robo-script") | ||
appendListProperty(config.roboDirectives, name = "robo-directives") { | ||
val value = it.getOrElse(2) { "" }.let { stringValue -> if (stringValue.isBlank()) "\"\"" else stringValue } | ||
appendln(" ${it[0]}:${it[1]}: $value") | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move this to be the first line in
createTasksForConfig
that way the next line can be removed as well.