mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.63k stars 254 forks source link

Allow for running flows with subflows using `maestro cloud` without uploading the whole workspace #1791

Open paulsweeting opened 1 month ago

paulsweeting commented 1 month ago

Describe the bug Upload requests fail to maestro cloud when using the CLI if the test contains sub-flows:

- runFlow: subflows/onboarding-android.yaml

To Reproduce Follow https://cloud.mobile.dev/getting-started/quickstart in login into CLI and download samples

  1. maestro download-samples
  2. cd ./samples
  3. Run maestro cloud sample.zip ios-advanced-flow.yaml or maestro cloud sample.apk android-advanced-flow.yaml
  4. The Flow fails with error:
    Upload request failed (400): Syntax error: Failed to parse file: /./ios-advanced-flow.yaml
    Flow file does not exist: jar:file:///tmpFiles/workspaces/workflow197377531878186231.zip!/./subflows/onboarding-ios.yaml

Expected behavior It works as expected with simple flows that do NOT contain subflow e.g. maestro cloud sample.zip ios-flow.yaml

Environment information (please complete the following information):

bartekpacia commented 1 month ago

Hi @paulsweeting, thanks for creating the issue and sorry for the problems.

Could you share a simple, example flows just so that we can reproduce this easily?

paulsweeting commented 1 month ago

@bartekpacia - Yeap, I'm just using the out of the box example flows when you run maestro download-samples

appId: org.wikipedia
tags:
  - advanced
---
- runFlow: subflows/onboarding-android.yaml
- tapOn:
    id: "org.wikipedia:id/search_container"
- runScript: scripts/getSearchQuery.js
- inputText: ${output.result}
- assertVisible: ${output.result}
bartekpacia commented 1 month ago

Thanks for the report, I confirm it occurs.

Error message in code:

https://github.com/mobile-dev-inc/maestro/blob/dab2362b581049d2c43480d27bbc50ca7d06f2e5/maestro-orchestra/src/main/java/maestro/orchestra/yaml/YamlFluentCommand.kt#L360-L362

bartekpacia commented 1 month ago

Looks like this is expected behavior. When using subflows, you have to upload the whole workspace. This is explained in the docs here:

Screenshot 2024-07-11 at 19 22 35

I agree a better job should be done here, to inform users about this. Maestro CLI should maybe say:

Your flow includes a subflow. To run on Maestro Cloud, you need to upload the whole workspace instead:

<example invocation>

See also:

paulsweeting commented 1 month ago

Thank you @bartekpacia I can confirm that following works and runs all flows in the samples folder

maestro cloud samples/sample.zip samples

However, we want to be able to run single advanced flows. All of our tests use subflows. When writing a new test, we'd like the ability to run the test via the maestro cloud CLI to confirm it runs and passes before raising the PR, where all tests run as part of GitHub actions.

For example, using the samples, we want to be able to run:

maestro cloud samples/sample.zip samples/ios-advanced-flow.yaml

Which currently gives the same error:

Upload request failed (400): Syntax error: Failed to parse file: /./ios-advanced-flow.yaml
Flow file does not exist: jar:file:///tmpFiles/workspaces/workflow17464117397033909285.zip!/./subflows/onboarding-ios.yaml

From what you've said this isn't possible at the moment. Is there a feature request open for this already? Or any suggested workarounds?

bartekpacia commented 1 month ago

No, afaik, it's not possible as well right now. I see why you need this. Sorry for the problems.

Is there a feature request open for this already?

Let's consider this issue to be a feature request.

paulsweeting commented 1 month ago

Just an update for anyone looking for a workaround. To run single advanced flow you can use tags. For example, add the tag 'single-test-run' to the flow:

appId: org.wikimedia.wikipedia
tags:
  - advanced
  - single-test-run

Then pass the tag through using --include-tags

maestro cloud samples/sample.zip samples --include-tags=single-test-run

Which runs the single flow:

[Passed] ios-advanced-flow (1m 21s)
1/1 Flow Passed