Skip to content
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

device model + OS params on upload #2338

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion maestro-cli/src/main/java/maestro/cli/api/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class ApiClient(
deviceLocale: String? = null,
progressListener: (totalBytes: Long, bytesWritten: Long) -> Unit = { _, _ -> },
projectId: String? = null,
deviceModel: String? = null,
deviceOs: String? = null,
): UploadResponse {
if (appBinaryId == null && appFile == null) throw CliError("Missing required parameter for option '--app-file' or '--app-binary-id'")
if (appFile != null && !appFile.exists()) throw CliError("App file does not exist: ${appFile.absolutePathString()}")
Expand All @@ -266,6 +268,8 @@ class ApiClient(
appBinaryId?.let { requestPart["appBinaryId"] = it }
deviceLocale?.let { requestPart["deviceLocale"] = it }
projectId?.let { requestPart["projectId"] = it }
deviceModel?.let { requestPart["deviceModel"] = it }
deviceOs?.let { requestPart["deviceOs"] = it }
if (includeTags.isNotEmpty()) requestPart["includeTags"] = includeTags
if (excludeTags.isNotEmpty()) requestPart["excludeTags"] = excludeTags
if (disableNotifications) requestPart["disableNotifications"] = true
Expand Down Expand Up @@ -335,7 +339,7 @@ class ApiClient(
val url = if (projectId != null) {
"$baseUrl/v2/project/$projectId/runMaestroTest"
} else {
"$baseUrl/v2/upload"
throw CliError("A Project ID is required for uploading to Robin")
}
val response = try {
val request = Request.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class CloudInteractor(
disableNotifications: Boolean = false,
deviceLocale: String? = null,
projectId: String? = null,
deviceModel: String? = null,
deviceOs: String? = null,
): Int {
if (appBinaryId == null && appFile == null && !flowFile.isWebFlow()) throw CliError("Missing required parameter for option '--app-file' or '--app-binary-id'")
if (!flowFile.exists()) throw CliError("File does not exist: ${flowFile.absolutePath}")
Expand Down Expand Up @@ -132,7 +134,9 @@ class CloudInteractor(
projectId = projectId,
progressListener = { totalBytes, bytesWritten ->
progressBar.set(bytesWritten.toFloat() / totalBytes.toFloat())
}
},
deviceModel = deviceModel,
deviceOs = deviceOs
)

when (response) {
Expand Down
16 changes: 12 additions & 4 deletions maestro-cli/src/main/java/maestro/cli/command/CloudCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import kotlin.io.path.absolutePathString
@CommandLine.Command(
name = "cloud",
description = [
"Test a Flow or set of Flows on Maestro Cloud (https://cloud.mobile.dev)",
"Provide your application file and a folder with Maestro flows to run them in parallel on multiple devices in Maestro Cloud",
"Test a Flow or set of Flows on Robin (https://robintest.com)",
"Provide your application file and a folder with Maestro flows to run them in parallel on multiple devices in Robin",
"By default, the command will block until all analyses have completed. You can use the --async flag to run the command asynchronously and exit immediately.",
]
)
Expand Down Expand Up @@ -106,7 +106,7 @@ class CloudCommand : Callable<Int> {
@Option(order = 11, names = ["--async"], description = ["Run the upload asynchronously"])
private var async: Boolean = false

@Option(order = 12, names = ["--android-api-level"], description = ["Android API level to run your flow against"])
@Option(order = 12, names = ["--android-api-level"], description = ["Android API level to run your flow against (deprecated: please use --device-os and --device-model instead)"])
private var androidApiLevel: Int? = null

@Option(
Expand Down Expand Up @@ -145,7 +145,7 @@ class CloudCommand : Callable<Int> {
)
private var output: File? = null

@Option(order = 17, names = ["--ios-version"], description = ["iOS version to run your flow against"])
@Option(order = 17, names = ["--ios-version"], description = ["iOS version to run your flow against (deprecated: please use --device-os and --device-model instead)"])
private var iOSVersion: String? = null

@Option(order = 18, names = ["--app-binary-id", "--appBinaryId"], description = ["The ID of the app binary previously uploaded to Maestro Cloud"])
Expand All @@ -154,6 +154,12 @@ class CloudCommand : Callable<Int> {
@Option(order = 19, names = ["--device-locale"], description = ["Locale that will be set to a device, ISO-639-1 code and uppercase ISO-3166-1 code i.e. \"de_DE\" for Germany"])
private var deviceLocale: String? = null

@Option(order = 20, names = ["--device-model"], description = ["Device model to run your flow against"])
private var deviceModel: String? = null

@Option(order = 21, names = ["--device-os"], description = ["OS version to run your flow against"])
private var deviceOs: String? = null

@Option(hidden = true, names = ["--fail-on-cancellation"], description = ["Fail the command if the upload is marked as cancelled"])
private var failOnCancellation: Boolean = false

Expand Down Expand Up @@ -221,6 +227,8 @@ class CloudCommand : Callable<Int> {
disableNotifications = disableNotifications,
deviceLocale = deviceLocale,
projectId = projectId,
deviceModel = deviceModel,
deviceOs = deviceOs
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import java.util.concurrent.Callable
@CommandLine.Command(
name = "start-device",
description = [
"Starts or creates an iOS Simulator or Android Emulator similar to the ones on Maestro Cloud",
"Starts or creates an iOS Simulator or Android Emulator similar to the ones on Robin",
"Supported device types: iPhone11 (iOS), Pixel 6 (Android)",
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ class UploadCommand : Callable<Int> {
@Option(order = 9, names = ["--android-api-level"], description = ["Android API level to run your flow against"])
private var androidApiLevel: Int? = null

@Option(order = 10, names = ["--device-model"], description = ["Device model to run your flow against"])
private var deviceModel: String? = null

@Option(order = 11, names = ["--device-os"], description = ["OS version to run your flow against"])
private var deviceOs: String? = null


override fun call(): Int {
println(
ansi()
Expand Down Expand Up @@ -109,6 +116,8 @@ class UploadCommand : Callable<Int> {
pullRequestId = pullRequestId,
apiKey = apiKey,
androidApiLevel = androidApiLevel,
deviceModel = deviceModel,
deviceOs = deviceOs
)
}

Expand Down
Loading