Skip to content

Commit 3677e0c

Browse files
chore: Update iOS e2e tests (#1178)
1 parent b22b031 commit 3677e0c

File tree

14 files changed

+430
-227
lines changed

14 files changed

+430
-227
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: 'Start Appium Server'
2+
description: 'Start Appium server with configurable arguments and wait for startup'
3+
4+
inputs:
5+
port:
6+
description: 'Appium server port'
7+
required: false
8+
default: '4723'
9+
host:
10+
description: 'Appium server host'
11+
required: false
12+
default: '127.0.0.1'
13+
timeout:
14+
description: 'Timeout in seconds to wait for server startup'
15+
required: false
16+
default: '25'
17+
server_args:
18+
description: 'Additional server arguments (space-separated)'
19+
required: false
20+
default: ''
21+
log_file:
22+
description: 'Log file name'
23+
required: false
24+
default: 'appium.log'
25+
26+
runs:
27+
using: 'composite'
28+
steps:
29+
- name: Start Appium server
30+
shell: bash
31+
run: |
32+
nohup appium server \
33+
--port=${{ inputs.port }} \
34+
--address=${{ inputs.host }} \
35+
--log-no-colors \
36+
--log-timestamp \
37+
--keep-alive-timeout 1200 \
38+
${{ inputs.server_args }} \
39+
2>&1 > ${{ inputs.log_file }} &
40+
41+
- name: Wait for Appium server to start
42+
shell: bash
43+
run: |
44+
TIMEOUT_SEC=${{ inputs.timeout }}
45+
INTERVAL_SEC=1
46+
47+
start_time=$(date +%s)
48+
while true; do
49+
current_time=$(date +%s)
50+
elapsed=$((current_time - start_time))
51+
52+
if nc -z ${{ inputs.host }} ${{ inputs.port }}; then
53+
echo "Appium server is running after $elapsed seconds"
54+
cat ${{ inputs.log_file }}
55+
exit 0
56+
fi
57+
58+
if [[ "$elapsed" -ge "$TIMEOUT_SEC" ]]; then
59+
echo "${elapsed} seconds timeout reached: Appium server is NOT running"
60+
exit 1
61+
fi
62+
63+
echo "Waiting $elapsed seconds for Appium server to start..."
64+
sleep "$INTERVAL_SEC"
65+
done

.github/workflows/functional-test.yml

Lines changed: 105 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ name: Functional Tests
33
on:
44
# Run by manual at this time
55
workflow_dispatch:
6-
push:
7-
branches: [ master ]
86
pull_request:
97
branches: [ master ]
108

119
concurrency:
1210
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1311
cancel-in-progress: true
1412

13+
env:
14+
APPIUM_TEST_SERVER_PORT: '4723'
15+
APPIUM_TEST_SERVER_HOST: '127.0.0.1'
16+
1517
jobs:
1618
ios_test:
1719
strategy:
@@ -26,9 +28,10 @@ jobs:
2628
# Please make sure the available Xcode versions and iOS versions
2729
# on the runner images. https://github.com/actions/runner-images
2830
env:
29-
XCODE_VERSION: 16.4
30-
IOS_VERSION: 18.5
31-
IPHONE_MODEL: iPhone 16 Plus
31+
XCODE_VERSION: '16.4'
32+
IOS_VERSION: '18.5'
33+
IPHONE_MODEL: 'iPhone 16 Plus'
34+
PREBUILT_WDA_PATH: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app
3235

3336
steps:
3437
- uses: actions/checkout@v4
@@ -42,43 +45,61 @@ jobs:
4245
uses: maxim-lobanov/setup-xcode@v1
4346
with:
4447
xcode-version: ${{ env.XCODE_VERSION }}
48+
4549
- run: defaults write com.apple.iphonesimulator PasteboardAutomaticSync -bool false
4650

47-
- uses: futureware-tech/simulator-action@v3
51+
- name: Prepare iOS simulator
52+
uses: futureware-tech/simulator-action@v4
4853
with:
49-
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
5054
model: ${{ env.IPHONE_MODEL }}
5155
os_version: ${{ env.IOS_VERSION }}
56+
wait_for_boot: true
57+
shutdown_after_job: false
5258

53-
# needed?
54-
- run: brew install ffmpeg
55-
56-
# Start Appium
57-
- run: npm install -g appium
58-
- run: |
59+
- name: Install Appium and drivers
60+
run: |
61+
npm install -g appium
5962
appium driver install xcuitest
60-
appium driver run xcuitest build-wda --sdk=${{ env.IOS_VERSION }} --name='${{ env.IPHONE_MODEL }}'
61-
appium plugin install images
62-
appium plugin install execute-driver
63-
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors > appium.log &
6463
65-
- run: |
66-
appium driver run xcuitest download-wda-sim --platform=ios --outdir=${{ github.workspace }}/wda
67-
name: Downloading prebuilt WDA
64+
- name: Start Appium server
65+
uses: ./.github/actions/setup-appium-server
66+
with:
67+
port: ${{ env.APPIUM_TEST_SERVER_PORT }}
68+
host: ${{ env.APPIUM_TEST_SERVER_HOST }}
69+
server_args: '--relaxed-security'
6870

69-
- name: Set up Python 3.12
71+
- name: Downloading prebuilt WDA
72+
run: |
73+
appium driver run xcuitest download-wda-sim --platform=ios --outdir=$(dirname "$PREBUILT_WDA_PATH")
74+
75+
- name: Set up Python
7076
uses: actions/setup-python@v5
7177
with:
7278
python-version: 3.12
7379

80+
- name: Cache uv modules
81+
uses: actions/cache@v4
82+
with:
83+
path: |
84+
~/.cache/uv
85+
.venv
86+
key: ${{ runner.os }}-uv-shared-${{ hashFiles('**/uv.lock') }}
87+
restore-keys: |
88+
${{ runner.os }}-uv-shared-
89+
7490
- name: Install uv
7591
run: make install-uv
7692

7793
- name: Run Tests
7894
run: |
79-
uv run pytest ${{ matrix.test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
95+
uv run pytest ${{ matrix.test_targets.target}} \
96+
--doctest-modules \
97+
--junitxml=junit/test-results.xml \
98+
--cov=com \
99+
--cov-report=xml \
100+
--cov-report=html
80101
env:
81-
LOCAL_PREBUILT_WDA: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app
102+
LOCAL_PREBUILT_WDA: ${{ env.PREBUILT_WDA_PATH }}
82103

83104
- name: Save server output
84105
if: ${{ always() }}
@@ -115,13 +136,19 @@ jobs:
115136
with:
116137
node-version: 'lts/*'
117138

118-
# Start Appium
119-
- run: npm install -g appium
120-
- run: |
139+
- name: Install Appium and drivers
140+
run: |
141+
npm install -g appium
121142
appium driver install uiautomator2
122143
appium driver install espresso
123144
appium plugin install execute-driver
124-
nohup appium --use-plugins=execute-driver --relaxed-security --log-timestamp --log-no-colors 2>&1 > appium.log &
145+
146+
- name: Start Appium server
147+
uses: ./.github/actions/setup-appium-server
148+
with:
149+
port: ${{ env.APPIUM_TEST_SERVER_PORT }}
150+
host: ${{ env.APPIUM_TEST_SERVER_HOST }}
151+
server_args: '--relaxed-security --use-plugins=execute-driver'
125152

126153
- name: Enable KVM group perms
127154
run: |
@@ -154,6 +181,16 @@ jobs:
154181
with:
155182
python-version: 3.12
156183

184+
- name: Cache uv modules
185+
uses: actions/cache@v4
186+
with:
187+
path: |
188+
~/.cache/uv
189+
.venv
190+
key: ${{ runner.os }}-uv-shared-${{ hashFiles('**/uv.lock') }}
191+
restore-keys: |
192+
${{ runner.os }}-uv-shared-
193+
157194
- name: run tests
158195
uses: reactivecircus/android-emulator-runner@v2
159196
with:
@@ -230,15 +267,31 @@ jobs:
230267
with:
231268
node-version: 'lts/*'
232269

233-
- name: Install Appium
234-
run: npm install --location=global appium
235-
236-
- name: Install Android drivers and Run Appium
270+
- name: Install Appium and drivers
237271
if: matrix.e2e-tests == 'flutter-android'
238272
run: |
273+
npm install --location=global appium
239274
appium driver install uiautomator2
240275
appium driver install appium-flutter-integration-driver --source npm
241-
nohup appium --allow-insecure=adb_shell --relaxed-security --log-timestamp --log-no-colors 2>&1 > appium_flutter_android.log &
276+
277+
- name: Start Appium server for Android
278+
if: matrix.e2e-tests == 'flutter-android'
279+
uses: ./.github/actions/setup-appium-server
280+
with:
281+
port: ${{ env.APPIUM_TEST_SERVER_PORT }}
282+
host: ${{ env.APPIUM_TEST_SERVER_HOST }}
283+
server_args: '--relaxed-security'
284+
log_file: 'appium_flutter_android.log'
285+
286+
- name: Cache uv modules
287+
uses: actions/cache@v4
288+
with:
289+
path: |
290+
~/.cache/uv
291+
.venv
292+
key: ${{ runner.os }}-uv-shared-${{ hashFiles('**/uv.lock') }}
293+
restore-keys: |
294+
${{ runner.os }}-uv-shared-
242295
243296
- name: Run Android tests
244297
if: matrix.e2e-tests == 'flutter-android'
@@ -265,28 +318,40 @@ jobs:
265318
with:
266319
xcode-version: ${{ env.XCODE_VERSION }}
267320

268-
- uses: futureware-tech/simulator-action@v3
321+
- uses: futureware-tech/simulator-action@v4
269322
if: matrix.e2e-tests == 'flutter-ios'
270323
with:
271324
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
272325
model: ${{ env.IPHONE_MODEL }}
273326
os_version: ${{ env.IOS_VERSION }}
327+
wait_for_boot: true
328+
shutdown_after_job: false
274329

275-
- name: install dependencies
276-
if: matrix.e2e-tests == 'flutter-ios'
277-
run: brew install ffmpeg
278-
279-
- name: Install IOS drivers and Run Appium
330+
- name: Install Appium and drivers
280331
if: matrix.e2e-tests == 'flutter-ios'
281332
run: |
333+
npm install --location=global appium
282334
appium driver install xcuitest
283335
appium driver install appium-flutter-integration-driver --source npm
284336
appium driver run xcuitest build-wda
285-
nohup appium --allow-insecure=adb_shell --relaxed-security --log-timestamp --log-no-colors 2>&1 > appium_ios.log &
337+
338+
- name: Start Appium server for iOS
339+
if: matrix.e2e-tests == 'flutter-ios'
340+
uses: ./.github/actions/setup-appium-server
341+
with:
342+
port: ${{ env.APPIUM_TEST_SERVER_PORT }}
343+
host: ${{ env.APPIUM_TEST_SERVER_HOST }}
344+
server_args: '--relaxed-security'
345+
log_file: 'appium_ios.log'
286346

287347
- name: Run IOS tests
288348
if: matrix.e2e-tests == 'flutter-ios'
289349
run: |
290350
make install-uv
291351
export PLATFORM=ios
292-
uv run pytest test/functional/flutter_integration/*_test.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
352+
uv run pytest test/functional/flutter_integration/*_test.py \
353+
--doctest-modules \
354+
--junitxml=junit/test-results.xml \
355+
--cov=com \
356+
--cov-report=xml \
357+
--cov-report=html

.github/workflows/unit-test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ jobs:
1919
uses: actions/setup-python@v5
2020
with:
2121
python-version: ${{ matrix.python-version }}
22+
- name: Cache uv modules
23+
uses: actions/cache@v4
24+
with:
25+
path: |
26+
~/.cache/uv
27+
.venv
28+
key: ${{ runner.os }}-uv-shared-${{ hashFiles('**/uv.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-uv-shared-
2231
- name: Install uv
2332
run: make install-uv
2433
- name: Run Checks

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ install-uv:
4040

4141
.PHONY: sync-dev
4242
sync-dev:
43-
uv sync
43+
uv sync --dev
4444

4545
.PHONY: unittest
4646
unittest: ## Run unittest

appium/options/ios/xcuitest/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
from .wda.keychain_path_option import KeychainPathOption
7373
from .wda.max_typing_frequency_option import MaxTypingFrequencyOption
7474
from .wda.mjpeg_server_port_option import MjpegServerPortOption
75+
from .wda.prebuilt_wda_path_option import PrebuiltWdaPathOption
7576
from .wda.process_arguments_option import ProcessArgumentsOption
7677
from .wda.result_bundle_path_option import ResultBundlePathOption
7778
from .wda.screenshot_quality_option import ScreenshotQualityOption
@@ -83,6 +84,7 @@
8384
from .wda.use_native_caching_strategy_option import UseNativeCachingStrategyOption
8485
from .wda.use_new_wda_option import UseNewWdaOption
8586
from .wda.use_prebuilt_wda_option import UsePrebuiltWdaOption
87+
from .wda.use_preinstalled_wda_option import UsePreinstalledWdaOption
8688
from .wda.use_simple_build_test_option import UseSimpleBuildTestOption
8789
from .wda.use_xctestrun_file_option import UseXctestrunFileOption
8890
from .wda.wait_for_idle_timeout_option import WaitForIdleTimeoutOption
@@ -171,6 +173,7 @@ class XCUITestOptions(
171173
KeychainPathOption,
172174
MaxTypingFrequencyOption,
173175
MjpegServerPortOption,
176+
PrebuiltWdaPathOption,
174177
ProcessArgumentsOption,
175178
ResultBundlePathOption,
176179
ScreenshotQualityOption,
@@ -182,6 +185,7 @@ class XCUITestOptions(
182185
UseNativeCachingStrategyOption,
183186
UseNewWdaOption,
184187
UsePrebuiltWdaOption,
188+
UsePreinstalledWdaOption,
185189
UseSimpleBuildTestOption,
186190
UseXctestrunFileOption,
187191
WaitForIdleTimeoutOption,

0 commit comments

Comments
 (0)