Skip to content
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

[Mobile] - Move Appium drivers setup to bash script #55257

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ jobs:
- name: Setup Node.js and install dependencies
uses: ./.github/setup-node

- name: Restore Appium drivers cache
- name: Restore tests setup cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: |
~/.appium
key: ${{ runner.os }}-appium-${{ hashFiles('package-lock.json') }}
key: ${{ runner.os }}-tests-setup-${{ hashFiles('package-lock.json') }}

- name: Gradle cache
uses: gradle/gradle-build-action@b5126f31dbc19dd434c3269bf8c28c315e121da2 # v2.8.1
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ jobs:
- name: Setup Node.js and install dependencies
uses: ./.github/setup-node

- name: Restore Appium drivers cache
- name: Restore tests setup cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: |
~/.appium
key: ${{ runner.os }}-appium-${{ hashFiles('package-lock.json') }}
key: ${{ runner.os }}-tests-setup-${{ hashFiles('package-lock.json') }}

- name: Install Appium drivers
run: npm run native appium:setup
- name: Prepare tests setup
run: npm run native test:e2e:setup

- name: Prepare build cache key
run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt
Expand Down
26 changes: 26 additions & 0 deletions packages/react-native-editor/bin/test-e2e-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -eu

set -o pipefail

if command -v appium >/dev/null 2>&1; then
APPIUM_CMD="appium"
else
# Use relative path to access the locally installed appium
APPIUM_CMD="../../../node_modules/.bin/appium"
fi

output=$($APPIUM_CMD driver list --installed --json)

if echo "$output" | grep -q 'uiautomator2'; then
echo 'UiAutomator2 is installed, skipping installation.'
else
echo 'UiAutomator2 not found, installing...'
$APPIUM_CMD driver install uiautomator2
fi

if echo "$output" | grep -q 'xcuitest'; then
echo 'XCUITest is installed, skipping installation.'
else
echo 'XCUITest not found, installing...'
$APPIUM_CMD driver install xcuitest
fi
6 changes: 3 additions & 3 deletions packages/react-native-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@
"device-tests-canary": "cross-env NODE_ENV=test jest --forceExit --detectOpenHandles --no-cache --maxWorkers=2 --testPathPattern=@canary --config ./jest_ui.config.js",
"device-tests:local": "cross-env NODE_ENV=test jest --runInBand --detectOpenHandles --forceExit --config ./jest_ui.config.js",
"device-tests:debug": "cross-env NODE_ENV=test node $NODE_DEBUG_OPTION --inspect-brk node_modules/jest/bin/jest --runInBand --detectOpenHandles --verbose --config ./jest_ui.config.js",
"appium:setup": "output=`appium driver list --installed --json` && (echo $output | grep -q 'uiautomator2' && echo 'uiautomator2 is installed, skipping installation.' || (echo 'uiautomator2 not found, installing...' && appium driver install uiautomator2)) && (echo $output | grep -q 'xcuitest' && echo 'xcuitest is installed, skipping installation.' || (echo 'xcuitest not found, installing...' && appium driver install xcuitest))",
"appium:start": "node ./__device-tests__/helpers/appium-local-start.js",
"test:e2e:setup": "./bin/test-e2e-setup.sh",
"test:e2e:bundle:android": "mkdir -p android/app/src/main/assets && npm run rn-bundle -- --reset-cache --platform android --dev false --minify false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"test:e2e:build-app:android": "cd android && ./gradlew clean && ./gradlew assembleDebug",
"test:e2e:android:local": "npm run appium:setup && npm run test:e2e:bundle:android && npm run test:e2e:build-app:android && TEST_RN_PLATFORM=android npm run device-tests:local",
"test:e2e:android:local": "npm run test:e2e:setup && npm run test:e2e:bundle:android && npm run test:e2e:build-app:android && TEST_RN_PLATFORM=android npm run device-tests:local",
"test:e2e:bundle:ios": "mkdir -p ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app && npm run bundle:ios && cp bundle/ios/App.js ./ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/main.jsbundle && cp -r bundle/ios/assets ./ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/",
"test:e2e:build-app:ios": "npm run preios && ./bin/build_e2e_ios_app",
"test:e2e:build-wda": "xcodebuild -project ~/.appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ios/build/WDA",
"test:e2e:ios:local": "npm run appium:setup && npm run test:e2e:bundle:ios && npm run test:e2e:build-app:ios && npm run test:e2e:build-wda && TEST_RN_PLATFORM=ios npm run device-tests:local",
"test:e2e:ios:local": "npm run test:e2e:setup && npm run test:e2e:bundle:ios && npm run test:e2e:build-app:ios && npm run test:e2e:build-wda && TEST_RN_PLATFORM=ios npm run device-tests:local",
"build:gutenberg": "cd gutenberg && npm ci && npm run build",
"clean": "npm run clean:build-artifacts; npm run clean:aztec; npm run clean:haste; npm run clean:metro; npm run clean:watchman",
"clean:runtime": "npm run clean:haste; npm run clean:metro; npm run clean:watchman; npm run clean:babel-cache",
Expand Down
Loading