Skip to content

Commit 111caef

Browse files
Extract shared
1 parent 2136665 commit 111caef

File tree

4 files changed

+157
-45
lines changed

4 files changed

+157
-45
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: 82 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1111
cancel-in-progress: true
1212

13+
env:
14+
APPIUM_TEST_SERVER_PORT: '4723'
15+
APPIUM_TEST_SERVER_HOST: '127.0.0.1'
16+
1317
jobs:
1418
ios_test:
1519
strategy:
@@ -28,8 +32,6 @@ jobs:
2832
IOS_VERSION: '18.5'
2933
IPHONE_MODEL: 'iPhone 16 Plus'
3034
PREBUILT_WDA_PATH: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app
31-
APPIUM_TEST_SERVER_PORT: '4723'
32-
APPIUM_TEST_SERVER_HOST: '127.0.0.1'
3335

3436
steps:
3537
- uses: actions/checkout@v4
@@ -54,41 +56,17 @@ jobs:
5456
wait_for_boot: true
5557
shutdown_after_job: false
5658

57-
- name: Start Appium server
59+
- name: Install Appium and drivers
5860
run: |
5961
npm install -g appium
6062
appium driver install xcuitest
61-
nohup appium server \
62-
--port=$APPIUM_TEST_SERVER_PORT \
63-
--address=$APPIUM_TEST_SERVER_HOST \
64-
--relaxed-security \
65-
--log-no-colors \
66-
--log-timestamp \
67-
--keep-alive-timeout 1200 \
68-
2>&1 > appium.log &
69-
70-
TIMEOUT_SEC=25
71-
INTERVAL_SEC=1
72-
73-
start_time=$(date +%s)
74-
while true; do
75-
current_time=$(date +%s)
76-
elapsed=$((current_time - start_time))
77-
78-
if nc -z $APPIUM_TEST_SERVER_HOST $APPIUM_TEST_SERVER_PORT; then
79-
echo "Appium server is running after $elapsed seconds"
80-
cat appium.log
81-
exit 0
82-
fi
83-
84-
if [[ "$elapsed" -ge "$TIMEOUT_SEC" ]]; then
85-
echo "${elapsed} seconds timeout reached: Appium server is NOT running"
86-
exit 1
87-
fi
8863
89-
echo "Waiting $elapsed seconds for Appium server to start..."
90-
sleep "$INTERVAL_SEC"
91-
done
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'
9270

9371
- name: Downloading prebuilt WDA
9472
run: |
@@ -99,6 +77,16 @@ jobs:
9977
with:
10078
python-version: 3.12
10179

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+
10290
- name: Install uv
10391
run: make install-uv
10492

@@ -148,13 +136,19 @@ jobs:
148136
with:
149137
node-version: 'lts/*'
150138

151-
# Start Appium
152-
- run: npm install -g appium
153-
- run: |
139+
- name: Install Appium and drivers
140+
run: |
141+
npm install -g appium
154142
appium driver install uiautomator2
155143
appium driver install espresso
156144
appium plugin install execute-driver
157-
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'
158152

159153
- name: Enable KVM group perms
160154
run: |
@@ -193,6 +187,11 @@ jobs:
193187
api-level: ${{ env.API_LEVEL }}
194188
arch: ${{ env.ARCH }}
195189
script: |
190+
# Cache uv modules
191+
mkdir -p ~/.cache/uv
192+
if [ -d ~/.cache/uv ]; then
193+
echo "uv cache directory exists"
194+
fi
196195
make install-uv
197196
uv run pytest ${{ matrix.test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
198197
target: google_apis
@@ -263,15 +262,32 @@ jobs:
263262
with:
264263
node-version: 'lts/*'
265264

266-
- name: Install Appium
267-
run: npm install --location=global appium
268-
269-
- name: Install Android drivers and Run Appium
265+
- name: Install Appium and drivers
270266
if: matrix.e2e-tests == 'flutter-android'
271267
run: |
268+
npm install --location=global appium
272269
appium driver install uiautomator2
273270
appium driver install appium-flutter-integration-driver --source npm
274-
nohup appium --allow-insecure=adb_shell --relaxed-security --log-timestamp --log-no-colors 2>&1 > appium_flutter_android.log &
271+
272+
- name: Start Appium server for Android
273+
if: matrix.e2e-tests == 'flutter-android'
274+
uses: ./.github/actions/setup-appium-server
275+
with:
276+
port: ${{ env.APPIUM_TEST_SERVER_PORT }}
277+
host: ${{ env.APPIUM_TEST_SERVER_HOST }}
278+
server_args: '--relaxed-security'
279+
log_file: 'appium_flutter_android.log'
280+
281+
- name: Cache uv modules for Flutter Android
282+
if: matrix.e2e-tests == 'flutter-android'
283+
uses: actions/cache@v4
284+
with:
285+
path: |
286+
~/.cache/uv
287+
.venv
288+
key: ${{ runner.os }}-uv-shared-${{ hashFiles('**/uv.lock') }}
289+
restore-keys: |
290+
${{ runner.os }}-uv-shared-
275291
276292
- name: Run Android tests
277293
if: matrix.e2e-tests == 'flutter-android'
@@ -304,18 +320,40 @@ jobs:
304320
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
305321
model: ${{ env.IPHONE_MODEL }}
306322
os_version: ${{ env.IOS_VERSION }}
323+
wait_for_boot: true
324+
shutdown_after_job: false
307325

308326
- name: install dependencies
309327
if: matrix.e2e-tests == 'flutter-ios'
310328
run: brew install ffmpeg
311329

312-
- name: Install IOS drivers and Run Appium
330+
- name: Install Appium and drivers
313331
if: matrix.e2e-tests == 'flutter-ios'
314332
run: |
333+
npm install --location=global appium
315334
appium driver install xcuitest
316335
appium driver install appium-flutter-integration-driver --source npm
317336
appium driver run xcuitest build-wda
318-
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'
346+
347+
- name: Cache uv modules for Flutter iOS
348+
if: matrix.e2e-tests == 'flutter-ios'
349+
uses: actions/cache@v4
350+
with:
351+
path: |
352+
~/.cache/uv
353+
.venv
354+
key: ${{ runner.os }}-uv-shared-${{ hashFiles('**/uv.lock') }}
355+
restore-keys: |
356+
${{ runner.os }}-uv-shared-
319357
320358
- name: Run IOS tests
321359
if: matrix.e2e-tests == 'flutter-ios'

.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

0 commit comments

Comments
 (0)