generated from vividus-framework/vividus-starter
-
Notifications
You must be signed in to change notification settings - Fork 316
126 lines (108 loc) · 4.16 KB
/
mobile-test-run.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Mobile Demo Test Run
env:
DEVICE_NAME: vividus-test-device
ANDROID_EMU_ABI: x86
ANDROID_EMU_TARGET: android-29
ANDROID_EMU_TAG: default
IOS_DEVICE_TYPE_ID: iPhone 14 Pro Max
on:
workflow_dispatch:
schedule:
- cron: '30 4 * * MON-FRI'
push:
branches:
- main
paths:
- '**/mobile_app/**'
- '**/android/**'
- '**/ios/**'
- '.github/workflows/mobile-test-run.yml'
pull_request:
branches:
- main
paths:
- '**/mobile_app/**'
- '**/android/**'
- '**/ios/**'
- '.github/workflows/mobile-test-run.yml'
jobs:
mobile-test-run:
runs-on: macos-latest
strategy:
matrix:
platform: [Android, iOS]
fail-fast: false
steps:
- name: Checkout (including submodules)
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache tests history
uses: pat-s/[email protected]
with:
path: output/history
key: tests-history-cache
restore-keys: |
tests-history-cache
- name: Spin-up Android emulator
if: matrix.platform == 'Android'
run: |
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;$ANDROID_EMU_TARGET;$ANDROID_EMU_TAG;$ANDROID_EMU_ABI"
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n "$DEVICE_NAME" -k "system-images;$ANDROID_EMU_TARGET;$ANDROID_EMU_TAG;$ANDROID_EMU_ABI" --force
echo $ANDROID_HOME/emulator/emulator -list-avds
$ANDROID_HOME/platform-tools/adb start-server
echo "Starting emulator"
nohup $ANDROID_HOME/emulator/emulator -avd "$DEVICE_NAME" -no-snapshot -delay-adb > /dev/null 2>&1 &
$ANDROID_HOME/platform-tools/adb wait-for-device
$ANDROID_HOME/platform-tools/adb devices -l
echo "Emulator started"
- name: Spin-up iOS simulator
if: matrix.platform == 'iOS'
run: xcrun simctl create "$DEVICE_NAME" "$IOS_DEVICE_TYPE_ID" | xargs xcrun simctl boot
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Install Appium
run: npm i -g [email protected]
- name: Install XCUITest driver
if: matrix.platform == 'iOS'
run: appium driver install xcuitest
- name: Install UiAutomator2 driver
if: matrix.platform == 'Android'
run: appium driver install uiautomator2
- name: Start appium server
run: appium --relaxed-security --log-timestamp --log appium.log &
- name: Run iOS tests
if: matrix.platform == 'iOS'
run: |
./gradlew runStories -Pvividus.configuration.suites=mobile_app/ios \
-Pvividus.configuration.profiles=mobile_app/local2,mobile_app/ios \
-Pvividus.allure.history-directory=output/history/ios \
-Pvividus.selenium.grid.capabilities.showXcodeLog=true \
-Pvividus.selenium.grid.capabilities.wdaLaunchTimeout=360000 \
-Pvividus.selenium.grid.capabilities.appium\:simulatorStartupTimeout=600000 \
-Pvividus.selenium.grid.capabilities.udid="$(xcrun simctl list | grep "$DEVICE_NAME" | sed 's/[^(]*(\([^()]*\)).*/\1/g')" \
-Pvividus.selenium.grid.capabilities.deviceName="$DEVICE_NAME"
- name: Run Android tests
if: matrix.platform == 'Android'
run: |
./gradlew runStories -Pvividus.configuration.suites=mobile_app/android \
-Pvividus.configuration.profiles=mobile_app/local2,mobile_app/android \
-Pvividus.allure.history-directory=output/history/android \
-Pvividus.selenium.grid.capabilities.deviceName="$DEVICE_NAME"
- name: Publish ${{ matrix.platform }} tests report
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform }} tests report
path: output/reports/allure
- name: Print appium logs
if: always()
run: cat ./appium.log