Skip to content

Commit 9c3d6fc

Browse files
authored
Add workaround to prevent emulator from getting stuck on CI jobs (#393)
* Add workaround to prevent emulator from getting stuck on CI jobs * Reference script in later step * Inverse order
1 parent 5498f79 commit 9c3d6fc

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

.github/workflows/android.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,28 @@ jobs:
9191
~/.android/adb*
9292
key: avd-${{ matrix.api-level }}
9393

94+
- name: Prepare script to run
95+
id: script
96+
env:
97+
SCRIPT: |
98+
# Workaround for https://github.com/ReactiveCircus/android-emulator-runner/issues/373
99+
pre_terminate_crashpad() {
100+
# For some reason pgrep/pkill sees only crashpad_handle, not crashpad_handler,
101+
# but it's definitely called ${ANDROID_HOME}/emulator/crashpad_handler.
102+
103+
# Best-effort gracefully terminate all crashpad_handler processes.
104+
pkill --exact --echo --signal SIGTERM crashpad_handle || return
105+
sleep 10
106+
pkill --exact --echo --signal SIGKILL crashpad_handle || return
107+
}
108+
trap pre_terminate_crashpad EXIT
109+
110+
${{ inputs.script }}
111+
run: |
112+
script_file="${RUNNER_TEMP}/reactivecircus-android-emulator-runner-prepared-script.sh"
113+
echo "${SCRIPT}" > "${script_file}"
114+
echo "file=${script_file}" >> "${GITHUB_OUTPUT}"
115+
94116
- name: Create AVD and generate snapshot for caching
95117
if: steps.avd-cache.outputs.cache-hit != 'true'
96118
uses: reactivecircus/android-emulator-runner@v2
@@ -108,7 +130,11 @@ jobs:
108130
force-avd-creation: false
109131
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
110132
disable-animations: true
111-
script: ./gradlew connectedCheck --no-daemon --stacktrace
133+
script: |
134+
adb devices -l
135+
bash --noprofile --norc -eo pipefail "${{ steps.script.outputs.file }}"
136+
./gradlew connectedCheck --no-daemon --stacktrace
137+
112138
113139
- name: Start emulator and run UI Tests w/ KSP
114140
uses: reactivecircus/android-emulator-runner@v2
@@ -117,7 +143,10 @@ jobs:
117143
force-avd-creation: false
118144
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
119145
disable-animations: true
120-
script: ./gradlew connectedCheck --no-daemon --stacktrace -PuseKsp=true
146+
script: |
147+
adb devices -l
148+
bash --noprofile --norc -eo pipefail "${{ steps.script.outputs.file }}"
149+
./gradlew connectedCheck --no-daemon --stacktrace -PuseKsp=true
121150
122151
- name: Run Screenshot Tests
123152
uses: reactivecircus/android-emulator-runner@v2

0 commit comments

Comments
 (0)