Repository navigation
132 lines (125 loc) · 4.82 KB
/
Copy pathappium-e2e.yml
File metadata and controls
132 lines (125 loc) · 4.82 KB
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
name: Appium E2E Tests
on:
workflow_call:
inputs:
platform:
description: 'Target platform: android or ios'
required: true
type: string
app-artifact:
description: 'Name of the uploaded artifact containing the app binary'
required: true
type: string
app-filename:
description: 'Filename of the app binary inside the artifact'
required: true
type: string
sdk-type:
description: 'SDK type: react-native, flutter, capacitor, unity, cordova, dotnet, ios, or android'
required: true
type: string
device:
description: 'BrowserStack device name'
required: false
type: string
os-version:
description: 'Device OS version'
required: false
type: string
build-name:
description: 'Label for the BrowserStack session'
required: false
type: string
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Download app artifact
uses: actions/download-artifact@v8
with:
name: ${{ inputs.app-artifact }}
- name: Checkout sdk-shared (for test files)
uses: actions/checkout@v6
with:
repository: OneSignal/sdk-shared
path: _sdk-shared
- name: Set up Vite+
uses: voidzero-dev/setup-vp@v1
with:
working-directory: _sdk-shared/appium
cache: true
run-install: true
- name: Upload app to BrowserStack
id: bs-upload
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
APP_FILENAME: ${{ inputs.app-filename }}
run: |
RESPONSE=$(curl -s -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@${APP_FILENAME}")
APP_URL=$(echo "$RESPONSE" | jq -r '.app_url')
if [ "$APP_URL" = "null" ] || [ -z "$APP_URL" ]; then
echo "::error::Failed to upload app to BrowserStack: $RESPONSE"
exit 1
fi
echo "app-url=$APP_URL" >> "$GITHUB_OUTPUT"
echo "Uploaded app to BrowserStack: $APP_URL"
- name: Run Appium tests
working-directory: _sdk-shared/appium
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
BROWSERSTACK_APP_URL: ${{ steps.bs-upload.outputs.app-url }}
SDK_TYPE: ${{ inputs.sdk-type }}
PLATFORM: ${{ inputs.platform }}
DEVICE: ${{ inputs.device }}
OS_VERSION: ${{ inputs.os-version }}
BUILD_NAME: ${{ inputs.build-name }}
ONESIGNAL_APP_ID: ${{ vars.APPIUM_ONESIGNAL_APP_ID }}
ONESIGNAL_API_KEY: ${{ secrets.APPIUM_ONESIGNAL_API_KEY }}
# Retry only on BrowserStack session-creation failures (queue
# timeouts, parallel-limit hits, transient hub errors). Real test
# failures still fail the job on the first attempt.
run: |
set +e
MAX_ATTEMPTS=10
WDIO_TIMEOUT="25m"
if [ "$PLATFORM" = "ios" ]; then
WDIO_TIMEOUT="60m"
fi
for attempt in $(seq 1 "$MAX_ATTEMPTS"); do
echo "::group::Appium attempt $attempt of $MAX_ATTEMPTS"
LOG_FILE="$RUNNER_TEMP/wdio-attempt-$attempt.log"
timeout --signal=TERM --kill-after=30s "$WDIO_TIMEOUT" \
vpx wdio run "wdio.${PLATFORM}.conf.ts" 2>&1 | tee "$LOG_FILE"
STATUS=${PIPESTATUS[0]}
echo "::endgroup::"
if [ "$STATUS" -eq 0 ]; then
exit 0
fi
if [ "$STATUS" -eq 124 ]; then
SLEEP=$((30 * attempt))
echo "WDIO did not complete within ${WDIO_TIMEOUT}; retrying in ${SLEEP}s..."
sleep "$SLEEP"
continue
fi
if grep -qE 'Failed to create a session|aborted due to timeout when running .*\/session|PARALLEL_TEST_LIMIT_REACHED|All parallel tests are currently in use' "$LOG_FILE"; then
SLEEP=$((30 * attempt))
echo "Session-creation failure detected; retrying in ${SLEEP}s..."
sleep "$SLEEP"
continue
fi
echo "Test failure (not a session-creation error); not retrying."
exit "$STATUS"
done
echo "::error::Exhausted $MAX_ATTEMPTS attempts due to session-creation failures."
exit 1
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: appium-results-${{ inputs.platform }}-${{ inputs.sdk-type }}
path: _sdk-shared/appium/results/
if-no-files-found: ignore