Skip to content

Commit

Permalink
Merge branch 'main' into feature/maestro_ai
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Aug 23, 2024
2 parents 87a46f7 + 8ba33f7 commit 0fb5550
Show file tree
Hide file tree
Showing 31 changed files with 125 additions and 446 deletions.
9 changes: 4 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ body:
- type: markdown
attributes:
value: >
### Thank you for using Maestro
### Thank you for using Maestro!
Before creating a new issue, please first search the
[existing issues database] and make sure it hasn't been reported
before.
Before creating a new issue, please first search the [existing issues]
and make sure it hasn't been reported before.
If you are sure that you have found a bug that hasn't been reported yet,
Expand All @@ -20,7 +19,7 @@ body:
---
[existing issues database]: https://github.com/mobile-dev-inc/maestro
[existing issues]: https://github.com/mobile-dev-inc/maestro
- type: checkboxes
attributes:
label: Is there an existing issue for this?
Expand Down
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

72 changes: 72 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Suggest a feature
description: You want to share a new idea to improve Maestro.
body:
- type: markdown
attributes:
value: >
### Thank you for using Maestro!
We can't wait to hear your idea!
First though, please search the [existing issues] to see if an issue
already exists for the feature you need. Maybe someone already did the
job for you and you don't need to fill this template.
---
If you are sure that the feature you want to suggest hasn't been
requested before, or if our documentation doesn't have an answer to what
you're looking for, then fill out the template below. Please bear in
mind that duplicates and unsufficiently described feature requests will
be closed.
[existing issues]: https://github.com/mobile-dev-inc/maestro/issues
- type: textarea
attributes:
label: Use case
description: >
Please tell us more about the use case you have that led to you wanting
this new feature.
Is your feature request related to a problem? Please give a clear and
concise description of what the problem is. This will help avoid the
[XY problem].
Describe the alternative solutions you've considered and the tradeoffs
they come with. The more context you can provide, the better.
[XY problem]: https://en.wikipedia.org/wiki/XY_problem
validations:
required: true
- type: textarea
attributes:
label: Proposal
description: >
Briefly but precisely describe what the new feature should look like
from the user perspective.
Consider attaching something showing what you are imagining:
* code samples (maybe you already know )
* API design ideas (e.g. of new YAML commands)
validations:
required: true
- type: textarea
validations:
required: false
attributes:
label: Anything else?
description: >
Links? Other issues? StackOverflow threads? Anything that will give us
more context about this feature request will be helpful.
> [!TIP]
> You can attach images or other files by clicking this area to highlight it and then dragging files in.
35 changes: 26 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# Maestro 🎹
# Maestro

Maestro is the easiest way to automate UI testing for your mobile app.

> [!NOTE]
>
> **Full documentation for Maestro can be found at [maestro.mobile.dev](https://maestro.mobile.dev)**
<img src="https://user-images.githubusercontent.com/847683/187275009-ddbdf963-ce1d-4e07-ac08-b10f145e8894.gif" />


## Why Maestro?

Maestro is built on learnings from its predecessors (Appium, Espresso, UIAutomator, XCTest)
Expand All @@ -21,6 +16,28 @@ Maestro is built on learnings from its predecessors (Appium, Espresso, UIAutomat

## Resources

- :book:&nbsp;&nbsp;Full documentation for Maestro can be found at [**maestro.mobile.dev**](https://maestro.mobile.dev)
- :speech_balloon:&nbsp;&nbsp;Public Slack channel: [**Join the workspace**](https://docsend.com/view/3r2sf8fvvcjxvbtk), then head to the `#maestro` channel
- :page_with_curl:&nbsp;&nbsp;Blog Post: [**Introducing: Maestro — Painless Mobile UI Automation**](https://blog.mobile.dev/introducing-maestro-painless-mobile-ui-automation-bee4992d13c1)
### Documentation

**Available at [maestro.mobile.dev](https://maestro.mobile.dev)**

To get more background on why we built Maestro, read [the Maestro announcement blogpost][blogpost].

### Community

We invite everyone to [join our public Slack channel](https://docsend.com/view/3r2sf8fvvcjxvbtk).

### Contributing

Maestro is an open-source project and we love getting contributions.

To get started, take a look at [issues with the `good first issue` label][good first issues] and [the contributing guide](./CONTRIBUTING.md).

### Built by

[mobile.dev](https://www.mobile.dev)

![](./logo.png)

[good first issues]: https://github.com/mobile-dev-inc/maestro/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22
[blogpost]: https://blog.mobile.dev/introducing-maestro-painless-mobile-ui-automation-bee4992d13c1

Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import maestro.orchestra.ApplyConfigurationCommand
import maestro.orchestra.CompositeCommand
import maestro.orchestra.MaestroCommand
import maestro.orchestra.Orchestra
import maestro.orchestra.OrchestraAppState
import maestro.orchestra.yaml.YamlCommandReader
import maestro.utils.Insight
import okio.Buffer
Expand All @@ -57,9 +56,8 @@ object MaestroCommandRunner {
commands: List<MaestroCommand>,
debugOutput: FlowDebugOutput,
aiOutput: FlowAIOutput,
): Result {
): Boolean {
val config = YamlCommandReader.getConfig(commands)
val initFlow = config?.initFlow
val onFlowComplete = config?.onFlowComplete
val onFlowStart = config?.onFlowStart

Expand Down Expand Up @@ -104,11 +102,6 @@ object MaestroCommandRunner {
view.setState(
UiState.Running(
device = device,
initCommands = toCommandStates(
initFlow?.commands ?: emptyList(),
commandStatuses,
commandMetadata
),
onFlowStartCommands = toCommandStates(
onFlowStart?.commands ?: emptyList(),
commandStatuses,
Expand Down Expand Up @@ -205,8 +198,7 @@ object MaestroCommandRunner {
)

val flowSuccess = orchestra.runFlow(commands)

return Result(flowSuccess = flowSuccess, cachedAppState = null)
return flowSuccess
}

private fun toCommandStates(
Expand Down Expand Up @@ -238,9 +230,4 @@ object MaestroCommandRunner {
)
}
}

data class Result(
val flowSuccess: Boolean,
val cachedAppState: OrchestraAppState?
)
}
27 changes: 5 additions & 22 deletions maestro-cli/src/main/java/maestro/cli/runner/TestRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import maestro.cli.runner.resultview.UiState
import maestro.cli.util.PrintUtils
import maestro.cli.view.ErrorViewUtils
import maestro.orchestra.MaestroCommand
import maestro.orchestra.MaestroInitFlow
import maestro.orchestra.OrchestraAppState
import maestro.orchestra.util.Env.withEnv
import maestro.orchestra.yaml.YamlCommandReader
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -82,7 +80,7 @@ object TestRunner {

if (debugOutput.exception != null) PrintUtils.err("${debugOutput.exception?.message}")

return if (result.get()?.flowSuccess == true) 0 else 1
return if (result.get() == true) 0 else 1
}

/**
Expand All @@ -99,8 +97,6 @@ object TestRunner {
val fileWatcher = FileWatcher()

var previousCommands: List<MaestroCommand>? = null
var previousInitFlow: MaestroInitFlow? = null
var previousResult: MaestroCommandRunner.Result? = null

var ongoingTest: Thread? = null
do {
Expand All @@ -110,25 +106,16 @@ object TestRunner {
join()
}

val commands = YamlCommandReader.readCommands(flowFile.toPath())
val commands = YamlCommandReader
.readCommands(flowFile.toPath())
.withEnv(env)
val initFlow = getInitFlow(commands)

// Restart the flow if anything has changed
if (commands != previousCommands || initFlow != previousInitFlow) {
if (commands != previousCommands) {
ongoingTest = thread {
// If previous init flow was successful and there were no changes to the init flow,
// then reuse cached app state (and skip the init commands)
val cachedAppState: OrchestraAppState? = if (initFlow == previousInitFlow) {
previousResult?.cachedAppState
} else {
null
}

previousCommands = commands
previousInitFlow = initFlow

previousResult = runCatching(resultView, maestro) {
runCatching(resultView, maestro) {
MaestroCommandRunner.runCommands(
maestro = maestro,
device = device,
Expand Down Expand Up @@ -159,10 +146,6 @@ object TestRunner {
} while (true)
}

private fun getInitFlow(commands: List<MaestroCommand>): MaestroInitFlow? {
return YamlCommandReader.getConfig(commands)?.initFlow
}

private fun <T> runCatching(
view: ResultView,
maestro: Maestro,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ class AnsiResultView(
render("Running on ${state.device.description}\n")
}
render("\n")
if (state.initCommands.isNotEmpty()) {
render("\n")
render(" ║ > Init Flow\n")
render("\n")
renderCommands(state.initCommands)
}
if (state.onFlowStartCommands.isNotEmpty()) {
render("\n")
render(" ║ > On Flow Start\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ class PlainTextResultView: ResultView {
}
}

if (state.initCommands.isNotEmpty()) {
if (shouldPrintStep()) {
println(" > Init Flow")
}

renderCommandsPlainText(state.initCommands)
}

if (state.onFlowStartCommands.isNotEmpty()) {
if (shouldPrintStep()) {
println(" > On Flow Start")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sealed class UiState {

data class Running(
val device: Device? = null,
val initCommands: List<CommandState> = emptyList(),
val onFlowStartCommands: List<CommandState> = emptyList(),
val onFlowCompleteCommands: List<CommandState> = emptyList(),
val commands: List<CommandState>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import kotlin.system.exitProcess
object MaestroSessionManager {
private const val defaultHost = "localhost"
private const val defaultXctestHost = "[::1]"
private const val defaultIdbPort = 10882
private const val defaultXcTestPort = 22087

private val executor = Executors.newScheduledThreadPool(1)
Expand Down Expand Up @@ -217,20 +216,6 @@ object MaestroSessionManager {
}
}

private fun isIOS(host: String?, port: Int?): Boolean {
return try {
val channel = ManagedChannelBuilder.forAddress(host ?: defaultHost, port ?: defaultIdbPort)
.usePlaintext()
.build()

channel.shutdownNow()

true
} catch (_: Exception) {
false
}
}

private fun pickAndroidDevice(
host: String?,
port: Int?,
Expand Down
4 changes: 1 addition & 3 deletions maestro-cli/src/main/java/maestro/cli/view/ErrorViewUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package maestro.cli.view

import maestro.MaestroException
import maestro.orchestra.error.InvalidFlowFile
import maestro.orchestra.error.InvalidInitFlowFile
import maestro.orchestra.error.NoInputException
import maestro.orchestra.error.UnicodeNotSupportedError
import maestro.orchestra.error.ValidationError
Expand All @@ -14,7 +13,6 @@ object ErrorViewUtils {
return when (e) {
is ValidationError -> e.message
is NoInputException -> "No commands found in Flow file"
is InvalidInitFlowFile -> "initFlow file is invalid: ${e.initFlowPath}"
is InvalidFlowFile -> "Flow file is invalid: ${e.flowPath}"
is UnicodeNotSupportedError -> "Unicode character input is not supported: ${e.text}. Please use ASCII characters. Follow the issue: https://github.com/mobile-dev-inc/maestro/issues/146"
is InterruptedException -> "Interrupted"
Expand All @@ -24,4 +22,4 @@ object ErrorViewUtils {
}
}

}
}
1 change: 0 additions & 1 deletion maestro-cli/src/main/resources/simplelogger.properties

This file was deleted.

Loading

0 comments on commit 0fb5550

Please sign in to comment.