-
Notifications
You must be signed in to change notification settings - Fork 2
228 lines (205 loc) Β· 9.5 KB
/
Copy pathreact-native-sdk-e2e.yml
File metadata and controls
228 lines (205 loc) Β· 9.5 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# Local E2E tests for the React Native example app (Android + iOS).
# Mirrors frontegg-android-kotlin's demo-e2e.yml and frontegg-ios-swift's
# demo-e2e.yml: builds the example app, boots a device/simulator, runs the
# instrumented tests, and reports results as PR checks.
#
# The previous cross-repo call to e2e-system-tests was never functional
# (0-second failure on every run since the workflow was created) due to
# GitHub's private-repo reusable-workflow access restrictions. This replaces
# it with self-contained local suites that actually run.
name: React Native SDK E2E
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
permissions:
contents: read
checks: write
jobs:
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Android β UiAutomator on an API 34 emulator
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
android-e2e:
name: Android E2E
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install JS dependencies
run: |
yarn install --frozen-lockfile
cd example && yarn install --frozen-lockfile
- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('example/android/**/*.gradle*', 'example/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Build debug APK + androidTest APK
working-directory: example/android
run: |
chmod +x gradlew
./gradlew :app:assembleDebug :app:assembleDebugAndroidTest --no-daemon
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-api34-google_apis-x86_64-pixel6-v1
- name: Create AVD snapshot if cache missing
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
arch: x86_64
target: google_apis
profile: pixel_6
cores: 4
ram-size: 4096M
heap-size: 1024M
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: echo "AVD snapshot generated"
- name: Run E2E tests on emulator
uses: reactivecircus/android-emulator-runner@v2
env:
LOGIN_EMAIL: ${{ secrets.E2E_LOGIN_EMAIL }}
LOGIN_PASSWORD: ${{ secrets.E2E_LOGIN_PASSWORD }}
LOGIN_WRONG_PASSWORD: ${{ secrets.E2E_LOGIN_WRONG_PASSWORD }}
TENANT_NAME_1: ${{ secrets.E2E_TENANT_NAME_1 }}
TENANT_NAME_2: ${{ secrets.E2E_TENANT_NAME_2 }}
GOOGLE_EMAIL: ${{ secrets.E2E_GOOGLE_EMAIL }}
GOOGLE_PASSWORD: ${{ secrets.E2E_GOOGLE_PASSWORD }}
with:
api-level: 34
arch: x86_64
target: google_apis
profile: pixel_6
cores: 4
ram-size: 4096M
heap-size: 1024M
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
working-directory: example/android
script: |
adb shell input keyevent 82
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
adb shell settings put global hide_error_dialogs 1
sleep 5
for attempt in 1 2 3; do echo "Android E2E attempt $attempt"; if ./gradlew :app:connectedDebugAndroidTest --no-daemon -Pandroid.testInstrumentationRunnerArguments.LOGIN_EMAIL="$LOGIN_EMAIL" -Pandroid.testInstrumentationRunnerArguments.LOGIN_PASSWORD="$LOGIN_PASSWORD" -Pandroid.testInstrumentationRunnerArguments.LOGIN_WRONG_PASSWORD="$LOGIN_WRONG_PASSWORD" -Pandroid.testInstrumentationRunnerArguments.TENANT_NAME_1="$TENANT_NAME_1" -Pandroid.testInstrumentationRunnerArguments.TENANT_NAME_2="$TENANT_NAME_2" -Pandroid.testInstrumentationRunnerArguments.GOOGLE_EMAIL="$GOOGLE_EMAIL" -Pandroid.testInstrumentationRunnerArguments.GOOGLE_PASSWORD="$GOOGLE_PASSWORD"; then exit 0; fi; echo "Android E2E attempt $attempt failed (likely emulator/launcher flake); retrying"; adb shell am force-stop com.frontegg.demo || true; adb shell settings put global hide_error_dialogs 1 || true; sleep 5; done; exit 1
- name: Collect JUnit reports
if: always()
run: |
mkdir -p e2e-artifacts
find example/android -path "*/androidTest-results/*" -name "*.xml" -exec cp -f {} e2e-artifacts/ \; 2>/dev/null || true
find example/android -path "*/build/outputs/*" -name "TEST-*.xml" -exec cp -f {} e2e-artifacts/ \; 2>/dev/null || true
- name: Publish JUnit report
uses: mikepenz/action-junit-report@v5
if: always()
with:
report_paths: e2e-artifacts/*.xml
check_name: Android E2E
- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: android-e2e-results
path: e2e-artifacts/
if-no-files-found: ignore
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# iOS β XCUITest on an iPhone simulator (macOS runner)
# Mirrors frontegg-ios-swift's demo-e2e.yml.
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ios-e2e:
name: iOS E2E
runs-on: macos-15
timeout-minutes: 60
env:
LOGIN_EMAIL: ${{ secrets.E2E_LOGIN_EMAIL }}
LOGIN_PASSWORD: ${{ secrets.E2E_LOGIN_PASSWORD }}
LOGIN_WRONG_PASSWORD: ${{ secrets.E2E_LOGIN_WRONG_PASSWORD }}
TENANT_NAME_1: ${{ secrets.E2E_TENANT_NAME_1 }}
TENANT_NAME_2: ${{ secrets.E2E_TENANT_NAME_2 }}
GOOGLE_EMAIL: ${{ secrets.E2E_GOOGLE_EMAIL }}
GOOGLE_PASSWORD: ${{ secrets.E2E_GOOGLE_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install JS dependencies
run: |
yarn install --frozen-lockfile
cd example && yarn install --frozen-lockfile
- name: Install CocoaPods dependencies
working-directory: example/ios
run: pod install --repo-update
- name: Build for testing
working-directory: example/ios
run: |
set -o pipefail
xcodebuild \
build-for-testing \
-workspace ReactNativeExample.xcworkspace \
-scheme ReactNativeExample \
-configuration Release \
-destination "platform=iOS Simulator,name=iPhone 16" \
-derivedDataPath "$RUNNER_TEMP/DerivedData" \
CODE_SIGNING_ALLOWED=NO \
2>&1 | tee "$RUNNER_TEMP/build.log"
- name: Run UI tests
working-directory: example/ios
run: |
set -o pipefail
# Exclude the real social-login test from CI: it drives a real
# ASWebAuthenticationSession that can't complete headlessly on a simulator.
# This mirrors the frontegg-ios-swift SDK E2E, which runs the
# "hosted:no-social" suite and excludes real system-web-auth social login.
xcodebuild \
test-without-building \
-workspace ReactNativeExample.xcworkspace \
-scheme ReactNativeExample \
-configuration Release \
-only-testing:ReactNativeExampleUITests \
-skip-testing:ReactNativeExampleUITests/LoginViaGoogleTest \
-destination "platform=iOS Simulator,name=iPhone 16" \
-derivedDataPath "$RUNNER_TEMP/DerivedData" \
-resultBundlePath "$RUNNER_TEMP/ios-e2e.xcresult" \
-parallel-testing-enabled NO \
2>&1 | tee "$RUNNER_TEMP/test.log"
- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: ios-e2e-results
path: |
${{ runner.temp }}/build.log
${{ runner.temp }}/test.log
${{ runner.temp }}/ios-e2e.xcresult
if-no-files-found: ignore