Repository navigation
ci: run the Android mobile web e2e tests on an emulator #1306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6f185ca
test: let the local Android configs take the AVD and version from env…
dprevost-LMI 37b66b6
ci: run the Android mobile web e2e tests on an emulator
dprevost-LMI 03c106b
ci: use the pixel_6 profile for the Android emulator, document the wo…
dprevost-LMI 19c946f
ci: fail on a missing baseline in the Android compare run, run on dep…
dprevost-LMI 3a5c7d0
ci: stop the Android emulator job from hanging, keep Appium out of th…
dprevost-LMI cfd084f
ci: warm up the Android emulator before the setup run
dprevost-LMI 67ef5f4
ci: match crashpad_handler by its command line in the emulator cleanup
dprevost-LMI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #!/usr/bin/env bash | ||
| # Runs the Android mobile web e2e tests on the emulator that reactivecircus/android-emulator-runner started. | ||
| # The baselines are not in git: the first run saves them, the second run compares with them. | ||
| set -euo pipefail | ||
|
|
||
| adb devices | ||
| adb shell getprop ro.build.version.release | ||
| if ! adb shell pm list packages | grep -q 'com.android.chrome'; then | ||
| echo "Chrome is not installed on the emulator, use a system image with Chrome (google_apis)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| mkdir -p logs | ||
| # Appium downloads the chromedriver that matches the Chrome version of the emulator. | ||
| # Its output goes to a file (uploaded when the job fails), not to the job log. | ||
| appium --port 4723 --allow-insecure 'uiautomator2:chromedriver_autodownload' > logs/appium.log 2>&1 & | ||
| APPIUM_PID=$! | ||
|
|
||
| cleanup() { | ||
| kill "$APPIUM_PID" 2> /dev/null || true | ||
| # When the action stops the emulator, it waits for all emulator processes, but the emulator leaves its | ||
| # crashpad_handler processes running, so the job hangs (ReactiveCircus/android-emulator-runner#385). | ||
| # Kill them after the emulator stopped. Linux cuts process names to 15 characters ("crashpad_handle"), | ||
| # so match the command line (-f) with the path of the executable. | ||
| ( | ||
| sleep 30 | ||
| for _ in $(seq 1 12); do | ||
| pgrep -f '/crashpad_handler' > /dev/null || break | ||
| pkill -9 -f '/crashpad_handler' || true | ||
| sleep 5 | ||
| done | ||
| ) > /dev/null 2>&1 & | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| for _ in $(seq 1 60); do | ||
| curl -sf http://127.0.0.1:4723/status > /dev/null && break | ||
| sleep 1 | ||
| done | ||
| curl -sf http://127.0.0.1:4723/status > /dev/null || { echo "Appium did not start"; cat logs/appium.log; exit 1; } | ||
|
|
||
| # Warm-up: in the first minutes after the boot the emulator is busy, and a screenshot can still show the frame before | ||
| # a scroll (wrong full page stitch: 2 of 3 CI jobs without a warm-up, 0 of 3 with it). Its files are not kept. | ||
| echo "::group::Warm up the emulator" | ||
| BASELINE_SETUP=true pnpm test.local.emus.web --mochaOpts.grep "full page screenshot successful" || true | ||
| rm -rf tests/localBaseline .tmp | ||
| echo "::endgroup::" | ||
|
|
||
| echo "::group::Save the baselines" | ||
| BASELINE_SETUP=true pnpm test.local.emus.web | ||
| echo "::endgroup::" | ||
|
|
||
| echo "::group::Compare with the baselines" | ||
| pnpm test.local.emus.web | ||
| echo "::endgroup::" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| name: android emulator | ||
|
|
||
| # The Android mobile web e2e tests on an emulator in the GitHub runner. No cloud credentials are needed, so this | ||
| # also runs for pull requests from forks. It runs only when a change can affect the mobile screenshots. | ||
| # The LambdaTest Android jobs (e2e workflow) stay: they test real cloud devices with committed baselines. | ||
| on: | ||
| pull_request: | ||
| paths: | ||
| # Dependency updates (for example webdriverio, @wdio/*, Appium-related packages) can change the screenshots | ||
| - "package.json" | ||
| - "pnpm-lock.yaml" | ||
| - "pnpm-workspace.yaml" | ||
| - "patches/**" | ||
| - "packages/image-comparison-core/package.json" | ||
| - "packages/visual-service/package.json" | ||
| - "packages/image-comparison-core/src/**" | ||
| - "packages/visual-service/src/**" | ||
| - "tests/specs/mobile.web.spec.ts" | ||
| - "tests/configs/wdio.shared.conf.ts" | ||
| - "tests/configs/wdio.local.appium.shared.conf.ts" | ||
| - "tests/configs/wdio.local.android.emus.web.conf.ts" | ||
| - ".github/scripts/android-emulator-e2e.sh" | ||
| - ".github/workflows/android-emulator.yml" | ||
|
plum117 marked this conversation as resolved.
|
||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| android-emulator-web: | ||
| name: 🤖 Run the Android mobile web e2e tests on an emulator | ||
| runs-on: ubuntu-latest | ||
| # Without a limit, a hung job runs until the GitHub default of 6 hours | ||
| timeout-minutes: 45 | ||
| env: | ||
| # Used by tests/configs/wdio.local.android.emus.web.conf.ts | ||
| ANDROID_AVD: ci_android_35 | ||
| ANDROID_PLATFORM_VERSION: "15" | ||
| steps: | ||
| - name: ⬇️ Checkout Repository | ||
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: 📦 Setup pnpm | ||
| uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 | ||
|
|
||
| - name: 🟢 Setup Node.js | ||
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | ||
| with: | ||
| node-version-file: ".nvmrc" | ||
| cache: pnpm | ||
|
|
||
| - name: 🧩 Install Dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: 🏗️ Build | ||
| run: pnpm build | ||
|
|
||
| - name: 📱 Install Appium and the UiAutomator2 driver | ||
| run: | | ||
| npm install --global appium@3.8.0 | ||
| appium driver install uiautomator2@8.7.0 | ||
|
|
||
| # The emulator needs hardware acceleration | ||
| - name: ⚙️ Enable KVM | ||
| run: | | ||
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | ||
| sudo udevadm control --reload-rules | ||
| sudo udevadm trigger --name-match=kvm | ||
|
|
||
| # A new AVD with a `google_apis` image: it has Chrome, and without a Play Store account Chrome | ||
| # can not update itself during the run | ||
| - name: 🤖 Run the e2e tests on the Android emulator | ||
| uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 | ||
| with: | ||
| api-level: 35 | ||
| target: google_apis | ||
| arch: x86_64 | ||
| # The cmdline-tools of the runner image do not know the newest Pixel profiles | ||
| profile: pixel_6 | ||
| pre-emulator-launch-script: avdmanager list device -c | tr '\n' ' ' | ||
| avd-name: ci_android_35 | ||
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot | ||
| disable-animations: true | ||
| script: bash .github/scripts/android-emulator-e2e.sh | ||
|
|
||
| - name: 📤 Upload artifacts | ||
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | ||
| if: failure() | ||
| with: | ||
| name: android-emulator-logs | ||
| include-hidden-files: true | ||
| path: | | ||
| logs/ | ||
| .tmp/ | ||
| tests/localBaseline/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.