mobile-dev-inc / maestro

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

(1.39.0) ENV variables are not persisting when set from a pipeline #2101

Open nboxill opened 1 month ago

nboxill commented 1 month ago

Is there an existing issue for this?

Steps to reproduce

Run maestro test on a flow from a gitlab pipeline - using a shell-script installed runner on the host machine.

Actual results

I have a niche use-case with maestro, with my app i'm using a shell-script gitlab runner to run test flows said runner, on a host machine.

Env variables are set from a pipeline:

- export MAESTRO_TEST_EMAIL="$TEST_EMAIL"

CLI 1.38.1

- inputText: ${MAESTRO_TEST_EMAIL} works

CLI 1.39.0

- inputText: ${MAESTRO_TEST_EMAIL} returns null

Expected results

Expect the env variables to persist in maestro tests when set from a gitlab pipeline.

About app

App is a native android application

About environment

MacOS Sonoma

Logs

Logs ``` ```

Maestro version

1.39.0

How did you install Maestro?

install script (https://get.maestro.mobile.dev)

Anything else?

N/A

linear[bot] commented 1 month ago

MA-2369 (1.39.0) ENV variables no longer working when set from a pipeline

arancauchi commented 1 month ago

Seeing the same issue

freak4pc commented 1 month ago

We're experiencing the same issue

Fishbowler commented 1 month ago

I've recreated this in a simple example.

https://github.com/Fishbowler/maestro-examples/tree/env_vars/env-vars

(I regret naming the folder and branch the same - sorry about that)

Running run.sh gives:

Running on emulator-5554                                                        

 ║                                                                              
 ║  > Flow: flow                                                                
 ║                                                                              
 ║    ✅   Run test.js                                                          
 ║         Log messages:                                                        
 ║           Running test.js                                                    
 ║           MAESTRO_EXAMPLE: undefined                                         
 ║           The env var $MAESTRO_EXAMPLE should be 'potato' but it is not      
 ║    ✅   Run test.js                                                          
 ║         Log messages:                                                        
 ║           Running test.js                                                    
 ║           MAESTRO_EXAMPLE: undefined                                         
 ║           The env var $MAESTRO_EXAMPLE should be 'potato' but it is not      
 ║    ✅   Run ${console.log('MAESTRO_EXAMPLE:' + MAESTRO_EXAMPLE)}             
 ║         Log messages:                                                        
 ║           MAESTRO_EXAMPLE:$MAESTRO_EXAMPLE 

Log file: maestro.log

woytekn commented 1 month ago

Same here. The issue has been solved after using 1.38.1 version in the pipeline

debsouto commented 3 weeks ago

Any updated regarding this issue? When we use the command export MAESTRO_VERSION=1.38.1 it seems to work fine ONLY if used together with curl -Ls "https://get.maestro.mobile.dev" | bash after. if we remove the command to update Maestro (even tough we settled the correct version) it seems to be masking the emulator boot

DanielPritchard commented 3 weeks ago

I just spent a day trying to debug why this was not working, I have had to downgrade to 1.38.1 to get my tests running again

Fishbowler commented 2 weeks ago

Locally, I'm working around this in v1.39.1 by passing them tiresomely at the CLI.

e.g. For the OP's example, maestro test -e MAESTRO_TEST_EMAIL=$MAESTRO_TEST_EMAIL myFolderOfFlows

arancauchi commented 1 week ago

Be aware that for env vars passed to maestro they need a preceding -e before each key/value pair (the docs don't state this). If expanding from a .env file you can use:

env_vars=$(cat .env | sed 's/^/-e /' | xargs)
maestro test $env_vars