-
Notifications
You must be signed in to change notification settings - Fork 5
147 lines (129 loc) · 4.62 KB
/
Copy pathe2e-appium-browserstack.yml
File metadata and controls
147 lines (129 loc) · 4.62 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Appium E2E Tests on BrowserStack
on:
pull_request:
branches:
- 'release/**'
types: [opened, synchronize, reopened, ready_for_review]
schedule:
- cron: '0 4 * * 0-3'
workflow_dispatch:
inputs:
branch:
description: 'Branch to run tests against'
required: false
default: 'develop'
jobs:
build-apk:
runs-on: ubuntu-latest
outputs:
app_url: ${{ steps.upload.outputs.app_url }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch || (github.event_name == 'schedule' && 'develop') || github.ref }}
- name: Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO }}
- name: Free Up Space
run: |
echo "Disk space before cleanup:"
df -h
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo apt-get clean
echo "Disk space after cleanup:"
df -h
- name: Cache Dependencies
id: cache-dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches/
~/.gradle/wrapper/
~/.gradle/daemon/
node_modules
key: dependencies-cache-${{ hashFiles('package-lock.json') }}
restore-keys: |
dependencies-cache-
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install Dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: npm ci
- name: Build APK
env:
SENTRY_DISABLE_AUTO_UPLOAD: 'true'
EXPO_PUBLIC_E2E_TEST: 'true'
MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
COMAPEO_METRICS_URL: ${{ vars.COMAPEO_METRICS_URL }}
COMAPEO_METRICS_API_KEY: ${{ secrets.COMAPEO_METRICS_API_KEY }}
run: |
npm run extract-messages
npx expo prebuild -p android
eas build --platform android --profile test --local
- name: Find Built APK
id: find-apk
run: echo "APK_PATH=$(ls -t build-*.apk | head -n 1)" >> $GITHUB_ENV
- name: Upload APK to BrowserStack
id: upload
run: |
APP_URL=$(curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@$APK_PATH" | jq -r '.app_url')
echo "app_url=$APP_URL" >> $GITHUB_ENV
echo "app_url=$APP_URL" >> $GITHUB_OUTPUT
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
run-e2e-tests:
runs-on: ubuntu-latest
needs: build-apk
concurrency:
group: browserstack-devices
cancel-in-progress: false
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch || (github.event_name == 'schedule' && 'develop') || github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Set Metadata for Build Context
run: |
echo "GITHUB_SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "GITHUB_PR_TITLE=${{ github.event.pull_request.title || github.event_name }}" >> $GITHUB_ENV
- name: Run Webdriver IO E2E Tests on BrowserStack
uses: nick-fields/retry@v3
with:
timeout_minutes: 20
max_attempts: 3
command: |
set -o pipefail
mkdir -p test-results
npx wdio run wdio.ci.config.js --spec ./tests/e2e/specs/ | tee test-results/spec-log.txt
env:
BROWSERSTACK_APP_URL: ${{ needs.build-apk.outputs.app_url }}
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
GITHUB_SHORT_SHA: ${{ env.GITHUB_SHORT_SHA }}
GITHUB_PR_TITLE: ${{ env.GITHUB_PR_TITLE }}
- name: Upload Spec Reporter Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: spec-reporter-logs-${{ github.event.pull_request.number || github.run_number }}
path: test-results/spec-log.txt