Skip to content

Commit

Permalink
Update maestro scripts with retries (stripe#7169)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswoo-stripe authored Aug 18, 2023
1 parent 9ef6ea0 commit a3427e4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 44 deletions.
12 changes: 8 additions & 4 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ workflows:
- wait-for-android-emulator@1:
inputs:
- boot_timeout: 600
- script-runner@0:
- script@1:
title: Execute Maestro tests
inputs:
- file_path: ./scripts/execute_maestro_paymentsheet_tests.sh
- content: |-
#!/usr/bin/env bash
bash ./scripts/execute_maestro_elements_tests.sh paymentsheet
- slack@3:
is_always_run: true
run_if: .IsBuildFailed
Expand All @@ -140,10 +142,12 @@ workflows:
- wait-for-android-emulator@1:
inputs:
- boot_timeout: 600
- script-runner@0:
- script@1:
title: Execute Maestro tests
inputs:
- file_path: ./scripts/execute_maestro_customersheet_tests.sh
- content: |-
#!/usr/bin/env bash
bash ./scripts/execute_maestro_elements_tests.sh customersheet
- slack@3:
is_always_run: true
run_if: .IsBuildFailed
Expand Down
20 changes: 0 additions & 20 deletions scripts/execute_maestro_customersheet_tests.sh

This file was deleted.

43 changes: 43 additions & 0 deletions scripts/execute_maestro_elements_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -o pipefail
set -x

# Retry mechanism for Maestro installation
MAX_RETRIES=3
RETRY_COUNT=0

# Get the first command line argument as the parameter, one of [customersheet, paymentsheet]
elementType=$1

now=$(date +%F_%H-%M-%S)
echo $now

while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
export MAESTRO_VERSION=1.30.4
curl -Ls "https://get.maestro.mobile.dev" | bash

if [ $? -eq 0 ]; then
# If successful, set PATH and break loop
export PATH="$PATH":"$HOME/.maestro/bin"
maestro -v
break
else
let RETRY_COUNT=RETRY_COUNT+1
echo "Attempt $RETRY_COUNT failed. Retrying..."
sleep 5
fi
done

if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
echo "Failed to download and install Maestro after $MAX_RETRIES attempts."
exit 1
fi

# Create test results folder.
mkdir -p /tmp/test_results

# Compile and install APK.
./gradlew :paymentsheet-example:installDebug

# Clear and start collecting logs
maestro test --format junit --output maestroReport.xml maestro/$elementType
20 changes: 0 additions & 20 deletions scripts/execute_maestro_paymentsheet_tests.sh

This file was deleted.

0 comments on commit a3427e4

Please sign in to comment.