Skip to content

Commit 2fe20c9

Browse files
authored
test: improve android e2e build and test time (#6576)
1 parent ce36d1d commit 2fe20c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+203
-40
lines changed

.github/workflows/build-pr.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ jobs:
8080
uses: ./.github/workflows/maestro-android.yml
8181
needs: [e2e-build-android]
8282
secrets: inherit
83+
strategy:
84+
matrix:
85+
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
86+
fail-fast: false
87+
with:
88+
shard: ${{ matrix.shard }}
8389

8490
e2e-build-ios:
8591
name: E2E Build iOS
@@ -93,4 +99,5 @@ jobs:
9399
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
94100
uses: ./.github/workflows/maestro-ios.yml
95101
needs: [e2e-build-ios]
96-
secrets: inherit
102+
secrets: inherit
103+

.github/workflows/e2e-build-android.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,25 @@ jobs:
2828
- name: Checkout and Setup Node
2929
uses: ./.github/actions/setup-node
3030

31-
- name: Setup E2E Account
32-
uses: ./.github/actions/e2e-account
31+
- name: Cache Gradle dependencies
32+
uses: actions/cache@v4
3333
with:
34-
E2E_ACCOUNT: ${{ secrets.E2E_ACCOUNT }}
34+
path: |
35+
~/.gradle
36+
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
37+
restore-keys: |
38+
gradle-${{ runner.os }}-
3539
36-
- name: Cache Gradle dependencies
40+
- name: Cache Android build
3741
uses: actions/cache@v4
3842
with:
3943
path: |
40-
~/.gradle/caches/modules-2
41-
~/.gradle/caches/transforms-*
42-
~/.gradle/caches/build-cache-*
43-
key: gradle-transforms-v1-${{ runner.os }}-${{ hashFiles('**/*.gradle*', 'gradle-wrapper.properties') }}
44+
android/.gradle
45+
android/app/build
46+
android/app/.cxx
47+
key: android-build-${{ runner.os }}-${{ hashFiles('package.json', '**/*.gradle*', 'android/gradle.properties', 'android/settings.gradle') }}
4448
restore-keys: |
45-
gradle-transforms-v1-${{ runner.os }}-
49+
android-build-${{ runner.os }}-
4650
4751
- name: Set up JDK
4852
uses: actions/setup-java@v4
@@ -57,7 +61,6 @@ jobs:
5761
uses: gradle/actions/setup-gradle@v4
5862
with:
5963
gradle-version: wrapper
60-
cache-disabled: true
6164

6265
- name: Decode Keystore
6366
run: |
@@ -70,7 +73,7 @@ jobs:
7073
echo -e "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8" >> ./gradle.properties
7174
echo -e "android.useAndroidX=true" >> ./gradle.properties
7275
echo -e "android.enableJetifier=true" >> ./gradle.properties
73-
echo -e "reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64" >> ./gradle.properties
76+
echo -e "reactNativeArchitectures=x86_64" >> ./gradle.properties
7477
echo -e "APPLICATION_ID=chat.rocket.reactnative" >> ./gradle.properties
7578
echo -e "newArchEnabled=true" >> ./gradle.properties
7679
echo -e "hermesEnabled=true" >> ./gradle.properties

.github/workflows/maestro-android.yml

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ name: Maestro Tests on Android
22

33
on:
44
workflow_call:
5+
inputs:
6+
shard:
7+
required: true
8+
type: string
59

610
jobs:
711
android-test:
12+
name: 'Android Tests'
813
runs-on: ubuntu-latest
914

1015
steps:
@@ -38,8 +43,63 @@ jobs:
3843
sudo udevadm control --reload-rules
3944
sudo udevadm trigger --name-match=kvm
4045
46+
- name: Create Maestro script
47+
run: |
48+
cat << 'EOF' > run-maestro.sh
49+
#!/bin/bash
50+
SHARD=${{ inputs.shard }}
51+
echo "Running shard: $SHARD"
52+
53+
adb shell settings put system show_touches 1
54+
adb install app-experimental-release.apk
55+
adb shell monkey -p chat.rocket.reactnative -c android.intent.category.LAUNCHER 1
56+
sleep 10
57+
adb shell am force-stop chat.rocket.reactnative
58+
export MAESTRO_DRIVER_STARTUP_TIMEOUT=120000
59+
60+
MAX_RETRIES=3
61+
ATTEMPT=1
62+
FINAL_EXIT_CODE=1
63+
64+
while [ $ATTEMPT -le $MAX_RETRIES ]; do
65+
echo "Attempt $ATTEMPT of $MAX_RETRIES"
66+
67+
echo "Starting screen recording..."
68+
adb shell screenrecord /sdcard/test_run.mp4 > /dev/null 2>&1 &
69+
RECORD_PID=$!
70+
71+
maestro test .maestro --exclude-tags=util --include-tags=test-$SHARD --format junit --output maestro-report.xml
72+
TEST_EXIT_CODE=$?
73+
74+
echo "Stopping screen recording..."
75+
kill -INT $RECORD_PID || true
76+
sleep 2
77+
78+
echo "Pulling video from device..."
79+
adb pull /sdcard/test_run.mp4 test_run_${SHARD}_attempt_${ATTEMPT}.mp4 || true
80+
adb shell rm /sdcard/test_run.mp4 || true
81+
82+
if [ $TEST_EXIT_CODE -eq 0 ]; then
83+
echo "Maestro passed on attempt $ATTEMPT"
84+
FINAL_EXIT_CODE=0
85+
break
86+
else
87+
echo "Maestro failed on attempt $ATTEMPT"
88+
fi
89+
90+
ATTEMPT=$((ATTEMPT+1))
91+
done
92+
93+
exit $FINAL_EXIT_CODE
94+
EOF
95+
96+
chmod +x run-maestro.sh
97+
env:
98+
SHARD: ${{ inputs.shard }}
99+
41100
- name: Start Android Emulator and Run Maestro Tests
42101
uses: reactivecircus/android-emulator-runner@v2
102+
timeout-minutes: 60
43103
with:
44104
api-level: 34
45105
disk-size: 4096M
@@ -51,24 +111,20 @@ jobs:
51111
force-avd-creation: false
52112
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
53113
disable-animations: true
54-
script: |
55-
adb install app-experimental-release.apk
56-
adb shell monkey -p chat.rocket.reactnative -c android.intent.category.LAUNCHER 1
57-
sleep 10
58-
adb shell am force-stop chat.rocket.reactnative
59-
export MAESTRO_DRIVER_STARTUP_TIMEOUT=120000
60-
maestro test .maestro --format junit --output maestro-report.xml
114+
script: ./run-maestro.sh
61115

62116
- name: Upload Test Report
63117
if: always()
64118
uses: actions/upload-artifact@v4
65119
with:
66-
name: Android Test Report
120+
name: Android Test Report - Shard ${{ inputs.shard }}
67121
path: maestro-report.xml
68-
69-
- name: Upload Maestro Logs
122+
retention-days: 7
123+
124+
- name: Upload Screen Recording
70125
if: always()
71126
uses: actions/upload-artifact@v4
72127
with:
73-
name: Android Maestro Logs
74-
path: ~/.maestro/tests/
128+
name: maestro-video-${{ inputs.shard }}
129+
path: test_run_${{ inputs.shard }}_attempt_*.mp4
130+
retention-days: 7

.maestro/tests/accessibilityAndAppearance/ToastsAndDialogs.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ onFlowStart:
44
- runFlow: '../../helpers/setup.yaml'
55
onFlowEnd:
66
- evalScript: ${output.utils.deleteCreatedUsers()}
7+
tags:
8+
- test-13
79

810
---
911
- runFlow: ../../helpers/launch-app.yaml
@@ -21,7 +23,10 @@ onFlowEnd:
2123
- tapOn:
2224
id: 'status-view-offline'
2325
- tapOn: 'Save'
24-
- assertVisible: 'Status saved successfully!'
26+
- extendedWaitUntil:
27+
visible:
28+
text: 'Status saved successfully!'
29+
timeout: 60000
2530

2631
# Show alerts as Dialogs
2732
- tapOn: 'Accessibility & appearance'
@@ -33,6 +38,9 @@ onFlowEnd:
3338
- tapOn:
3439
id: 'status-view-online'
3540
- tapOn: 'Save'
36-
- assertVisible: 'Status saved successfully!'
41+
- extendedWaitUntil:
42+
visible:
43+
text: 'Status saved successfully!'
44+
timeout: 60000
3745
- assertVisible: 'OK'
3846
- tapOn: 'OK'

.maestro/tests/assorted/accessibility-and-appearance.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ onFlowStart:
44
- runFlow: '../../helpers/setup.yaml'
55
onFlowComplete:
66
- evalScript: ${output.utils.deleteCreatedUsers()}
7+
tags:
8+
- test-5
79

810
---
911
- evalScript: ${output.user = output.utils.createUser()}

.maestro/tests/assorted/broadcast.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ onFlowStart:
44
- runFlow: '../../helpers/setup.yaml'
55
onFlowComplete:
66
- evalScript: ${output.utils.deleteCreatedUsers()}
7+
tags:
8+
- test-5
79

810
---
911
- evalScript: ${output.room = 'broadcast' + output.random()}

.maestro/tests/assorted/change-avatar.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ onFlowStart:
44
- runFlow: '../../helpers/setup.yaml'
55
onFlowComplete:
66
- evalScript: ${output.utils.deleteCreatedUsers()}
7+
tags:
8+
- test-5
79

810
---
911
- evalScript: ${output.user = output.utils.createUser()}

.maestro/tests/assorted/changeserver.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ onFlowStart:
44
- runFlow: '../../helpers/setup.yaml'
55
onFlowComplete:
66
- evalScript: ${output.utils.deleteCreatedUsers()}
7+
tags:
8+
- test-5
79

810
---
911
- evalScript: ${output.user = output.utils.createUser()}

.maestro/tests/assorted/deeplink.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ onFlowStart:
44
- runFlow: '../../helpers/setup.yaml'
55
onFlowComplete:
66
- evalScript: ${output.utils.deleteCreatedUsers()}
7+
tags:
8+
- test-6
79

810
---
911
- evalScript: ${output.user = output.utils.createUser()}

.maestro/tests/assorted/delete-server.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ onFlowStart:
44
- runFlow: '../../helpers/setup.yaml'
55
onFlowComplete:
66
- evalScript: ${output.utils.deleteCreatedUsers()}
7+
tags:
8+
- test-6
79

810
---
911
- evalScript: ${output.user = output.utils.createUser()}

0 commit comments

Comments
 (0)