From 8345d2b3f42d44fff25d265840d52b425f614059 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Tue, 30 Jan 2024 11:58:52 +0100 Subject: [PATCH] [RNMobile] Address Android E2E tests failure by setting fixed versions of Appium drivers (#58408) * Detect and install required versions of Appium drivers * Enable Android E2E tests --- .github/workflows/rnmobile-android-runner.yml | 4 +-- .../react-native-editor/bin/test-e2e-setup.sh | 36 ++++++++++++++----- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/rnmobile-android-runner.yml b/.github/workflows/rnmobile-android-runner.yml index 2a4ac7d0f76caa..e0a3b9639cf389 100644 --- a/.github/workflows/rnmobile-android-runner.yml +++ b/.github/workflows/rnmobile-android-runner.yml @@ -15,9 +15,7 @@ concurrency: jobs: test: runs-on: macos-12 - # Disable for now until we fix failures in the job. - if: false - # if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} strategy: matrix: native-test-name: [gutenberg-editor-rendering] diff --git a/packages/react-native-editor/bin/test-e2e-setup.sh b/packages/react-native-editor/bin/test-e2e-setup.sh index ed896a03eacb85..b4fd55c9bea122 100755 --- a/packages/react-native-editor/bin/test-e2e-setup.sh +++ b/packages/react-native-editor/bin/test-e2e-setup.sh @@ -1,5 +1,13 @@ #!/bin/bash -e +# ================================================================= +# Appium Drivers +# +# NOTE: Please update the following versions when upgrading Appium. +# ================================================================= +UI_AUTOMATOR_2_VERSION="2.32.3" +XCUITEST_VERSION="5.7.0" + set -o pipefail if command -v appium >/dev/null 2>&1; then @@ -23,18 +31,30 @@ function log_error() { output=$($APPIUM_CMD driver list --installed --json) -if echo "$output" | grep -q 'uiautomator2'; then - log_info "UiAutomator2 available." +# UiAutomator2 driver installation +matched_version=$(echo "$output" | jq -r '.uiautomator2.version // empty') +if [ -z "$matched_version" ]; then + log_info "UiAutomator2 not installed, installing version $UI_AUTOMATOR_2_VERSION..." + $APPIUM_CMD driver install "uiautomator2@$UI_AUTOMATOR_2_VERSION" +elif [ "$matched_version" = "$UI_AUTOMATOR_2_VERSION" ]; then + log_info "UiAutomator2 version $UI_AUTOMATOR_2_VERSION is available." else - log_info "UiAutomator2 not found, installing..." - $APPIUM_CMD driver install uiautomator2 + log_info "UiAutomator2 version $matched_version is installed, replacing it with version $UI_AUTOMATOR_2_VERSION..." + $APPIUM_CMD driver uninstall uiautomator2 + $APPIUM_CMD driver install "uiautomator2@$UI_AUTOMATOR_2_VERSION" fi -if echo "$output" | grep -q 'xcuitest'; then - log_info "XCUITest available." +# XCUITest driver installation +matched_version=$(echo "$output" | jq -r '.xcuitest.version // empty') +if [ -z "$matched_version" ]; then + log_info "XCUITest not installed, installing version $XCUITEST_VERSION..." + $APPIUM_CMD driver install "xcuitest@$XCUITEST_VERSION" +elif [ "$matched_version" = "$XCUITEST_VERSION" ]; then + log_info "XCUITest version $XCUITEST_VERSION is available." else - log_info "XCUITest not found, installing..." - $APPIUM_CMD driver install xcuitest + log_info "XCUITest version $matched_version is installed, replacing it with version $XCUITEST_VERSION..." + $APPIUM_CMD driver uninstall xcuitest + $APPIUM_CMD driver install "xcuitest@$XCUITEST_VERSION" fi CONFIG_FILE="$(pwd)/__device-tests__/helpers/device-config.json"