Skip to content

Commit 2b1ed8e

Browse files
committed
[#510]: Invoke Maestro CI via single-line bash script file
android-emulator-runner runs each script line as sh -c; multiline heredocs still break. Move Gradle/Maestro into scripts/maestro-ci-emulator.sh.
1 parent 5ae02e1 commit 2b1ed8e

3 files changed

Lines changed: 46 additions & 34 deletions

File tree

.github/workflows/maestro-android.yml

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ jobs:
9797
env:
9898
CI: 'true'
9999

100-
# Assemble inside emulator-runner so ANDROID_HOME / SDK from the action are available.
101-
# android-emulator-runner invokes script with /usr/bin/sh (dash on ubuntu) — run the
102-
# body via a bash heredoc so `pipefail` and ${HOME} expansion work (#510).
100+
# android-emulator-runner runs *each line* of `script:` as a separate
101+
# `/usr/bin/sh -c` (dash). Keep this a single line that execs a bash file (#510).
103102
- name: Build APK + run Maestro on emulator
104103
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
105104
env:
105+
MAESTRO_SUITE: ${{ inputs.suite }}
106106
MAESTRO_EMAIL: ${{ secrets.MAESTRO_EMAIL }}
107107
MAESTRO_PASSWORD: ${{ secrets.MAESTRO_PASSWORD }}
108108
MAESTRO_EMAIL_2: ${{ secrets.MAESTRO_EMAIL_2 }}
@@ -115,36 +115,7 @@ jobs:
115115
disable-animations: true
116116
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -no-metrics
117117
emulator-boot-timeout: 900
118-
script: |
119-
bash -euo pipefail <<'SCRIPT'
120-
export PATH="${HOME}/.maestro/bin:${PATH}"
121-
chmod +x android/gradlew
122-
(
123-
cd android
124-
./gradlew :app:assembleRelease --no-daemon -PreactNativeArchitectures=x86_64
125-
)
126-
APK="android/app/build/outputs/apk/release/app-release.apk"
127-
test -f "${APK}"
128-
adb install -r "${APK}"
129-
mkdir -p .maestro/test_output
130-
suite="${{ inputs.suite }}"
131-
case "${suite}" in
132-
harness)
133-
npm run maestro:test:harness -- --format junit --output .maestro/test_output/report.xml
134-
;;
135-
smokes)
136-
npm run maestro:test:smokes -- --format junit --output .maestro/test_output/report.xml
137-
;;
138-
multi-account)
139-
npm run maestro:test:multi-account -- --format junit --output .maestro/test_output/report.xml
140-
;;
141-
*)
142-
echo "Unknown suite: ${suite}" >&2
143-
exit 1
144-
;;
145-
esac
146-
adb logcat -d > .maestro/test_output/logcat.txt || true
147-
SCRIPT
118+
script: bash ./scripts/maestro-ci-emulator.sh
148119

149120
- name: Upload Maestro artifacts
150121
if: always()

docs/guides/maestro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Opt-in **Android-only** Maestro suite for Fluent Mobile ([#488](https://github.c
4545

4646
Dispatch: **Actions → Maestro Android (informational) → Run workflow** (after the workflow exists on the target branch / `main`). Artifacts: JUnit + Maestro output + APK (14-day retention).
4747

48-
Note: `android-emulator-runner` runs its `script` under `/usr/bin/sh` (dash on Ubuntu). The workflow runs the body through a `bash -euo pipefail` heredoc so bashisms like `pipefail` work (#510).
48+
Note: `android-emulator-runner` runs **each line** of `script:` as a separate `/usr/bin/sh -c` (dash on Ubuntu). The workflow keeps `script:` to one line — `bash ./scripts/maestro-ci-emulator.sh` so bashisms and multiline Gradle/Maestro logic live in that script file (#510).
4949

5050
See also [docs/ci.md](../ci.md) and [`.github/README.md`](../../.github/README.md).
5151

scripts/maestro-ci-emulator.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
# Invoked as a *single line* by android-emulator-runner (that action runs each
3+
# `script:` line via `/usr/bin/sh -c`, so multiline YAML scripts break).
4+
# Expects: repo root CWD, ANDROID_HOME from emulator-runner, MAESTRO_SUITE set.
5+
set -euo pipefail
6+
7+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
8+
cd "$ROOT"
9+
10+
export PATH="${HOME}/.maestro/bin:${PATH}"
11+
12+
chmod +x android/gradlew
13+
(
14+
cd android
15+
./gradlew :app:assembleRelease --no-daemon -PreactNativeArchitectures=x86_64
16+
)
17+
18+
APK="android/app/build/outputs/apk/release/app-release.apk"
19+
test -f "${APK}"
20+
adb install -r "${APK}"
21+
22+
mkdir -p .maestro/test_output
23+
suite="${MAESTRO_SUITE:?MAESTRO_SUITE is required (harness|smokes|multi-account)}"
24+
25+
case "${suite}" in
26+
harness)
27+
npm run maestro:test:harness -- --format junit --output .maestro/test_output/report.xml
28+
;;
29+
smokes)
30+
npm run maestro:test:smokes -- --format junit --output .maestro/test_output/report.xml
31+
;;
32+
multi-account)
33+
npm run maestro:test:multi-account -- --format junit --output .maestro/test_output/report.xml
34+
;;
35+
*)
36+
echo "Unknown MAESTRO_SUITE: ${suite}" >&2
37+
exit 1
38+
;;
39+
esac
40+
41+
adb logcat -d > .maestro/test_output/logcat.txt || true

0 commit comments

Comments
 (0)