-
-
Notifications
You must be signed in to change notification settings - Fork 423
139 lines (124 loc) · 4.39 KB
/
functional-test.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
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Functional Tests
on:
pull_request:
branches:
- master
paths-ignore:
- 'docs/**'
- '*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CI: true
SHOW_XCODE_LOG: true
APPIUM_TEST_SERVER_PORT: '4567'
APPIUM_TEST_SERVER_HOST: '127.0.0.1'
jobs:
build:
# https://github.com/actions/runner-images/tree/main/images/macos
strategy:
matrix:
e2eRoot:
- basic
- device
- driver
- web
- long
xcodeVersion: ['14.3.1', '15.4']
include:
- xcodeVersion: '14.3.1'
iosVersion: '16.4'
deviceName: 'iPhone 14'
tvosVersion: '16.4'
tvosDeviceName: 'Apple TV'
platform: macos-13
- xcodeVersion: '15.4'
iosVersion: '17.5'
deviceName: 'iPhone 15'
skipTvOs: true
platform: macos-14
fail-fast: false
runs-on: ${{ matrix.platform }}
name: e2e
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "${{ matrix.xcodeVersion }}"
- run: xcrun simctl list devices available
name: List Installed Simulators
- run: |
brew install xq
xcrun simctl list runtimes
xcrun --sdk iphonesimulator --show-sdk-version
name: List Runtimes
- name: Prepare iOS simulator
id: prepareSimulator
uses: futureware-tech/simulator-action@v3
with:
model: "${{ matrix.deviceName }}"
os_version: "${{ matrix.iosVersion }}"
shutdown_after_job: false
- run: xcrun simctl bootstatus ${{ steps.prepareSimulator.outputs.udid }} -b
name: Wait for Simulator to finish booting
- run: |
npm install --no-save mjpeg-consumer
npm install mocha-multi-reporters --save-dev
export cwd=$(pwd)
pushd "$cwd"
cd ~
npm install -g appium
appium driver install --source=local "$cwd"
appium driver doctor xcuitest
appium driver run xcuitest build-wda --sdk=${{ matrix.iosVersion }} --name="${{ matrix.deviceName }}"
echo "Starting Appium server on $APPIUM_TEST_SERVER_HOST:$APPIUM_TEST_SERVER_PORT"
nohup appium server \
--port=$APPIUM_TEST_SERVER_PORT \
--address=$APPIUM_TEST_SERVER_HOST \
--relaxed-security \
--keep-alive-timeout 1200 2>&1 > "$cwd/appium.log" &
sleep 5
popd
cat appium.log
name: Prepare the server
- run: |
if ! nc -z $APPIUM_TEST_SERVER_HOST $APPIUM_TEST_SERVER_PORT; then
echo "Appium server is still not listening at $APPIUM_TEST_SERVER_HOST:$APPIUM_TEST_SERVER_PORT"
cat appium.log
exit 1
fi
export DEVICE_NAME="${{ matrix.deviceName }}"
export PLATFORM_VERSION="${{ matrix.iosVersion }}"
export RESULTS_XML=test-results.xml
echo "{\"reporterEnabled\": \"spec, xunit\", \"xunitReporterOptions\": {\"output\": \"$RESULTS_XML\"}}" > reporter_config.json
ARGS=("./test/functional/${{ matrix.e2eRoot }}" --exit --timeout 10m --reporter mocha-multi-reporters --reporter-options configFile=reporter_config.json)
if [[ "${{ matrix.e2eRoot }}" == basic ]]; then
ARGS+=(--grep XCUITestDriver)
fi
if ! npx mocha "${ARGS[@]}"; then
tests=$(cat "$RESULTS_XML" | xq --xpath '//testsuite/@tests')
errors=$(cat "$RESULTS_XML" | xq --xpath '//testsuite/@errors')
skipped=$(cat "$RESULTS_XML" | xq --xpath '//testsuite/@skipped')
failures=$(cat "$RESULTS_XML" | xq --xpath '//testsuite/@failures')
threshold=$(( (failures + errors) * 100 / (tests - skipped) ))
cat "$RESULTS_XML"
if [[ $threshold -gt 8 ]]; then
echo "${threshold}% of tests failed"
exit 1
else
echo "${threshold}% of tests failed. This is (probably) fine"
fi
fi
name: Run functional tests
- name: Save server output
if: ${{ always() }}
uses: actions/upload-artifact@master
with:
name: appium_e2eRoot_${{ matrix.e2eRoot }}_xCodev${{ matrix.xcodeVersion }}_iOSv${{ matrix.iosVersion }}.log
path: appium.log