-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (151 loc) · 6.38 KB
/
e2e-react-native.yml
File metadata and controls
168 lines (151 loc) · 6.38 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
name: React Native E2E
on:
workflow_call:
inputs:
matrix-include:
description: 'JSON array of {platform, device, os} objects'
type: string
default: '[{"platform":"android","device":"max","os":"ubuntu-24.04"},{"platform":"ios","device":"max","os":"macos-26"},{"platform":"web","device":"none","os":"ubuntu-24.04"}]'
timeout-minutes:
description: 'Job timeout in minutes'
type: number
default: 45
artifact-prefix:
description: 'Prefix for artifact names'
type: string
default: 'react-native'
jobs:
react-native-e2e:
name: React Native E2E - ${{ matrix.platform }}-${{ matrix.device }}
runs-on: ${{ matrix.os }}
timeout-minutes: ${{ inputs.timeout-minutes }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(inputs.matrix-include) }}
steps:
- uses: actions/checkout@v6
- name: Setup Node.js with cache
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: examples/react-native/package-lock.json
- name: Cache node_modules
uses: actions/cache@v5
with:
path: examples/react-native/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('examples/react-native/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Enable KVM (Android only)
if: matrix.platform == 'android'
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: Setup Gradle cache (Android only)
if: matrix.platform == 'android'
uses: actions/cache@v5
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.gradle/configuration-cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Select pinned Xcode (iOS only)
if: matrix.platform == 'ios' && matrix.device == 'max'
run: |
XCODE_VERSION=$(jq -r '.env.IOS_XCODE_VERSION' plugins/ios/plugin.json)
XCODE_APP=$(ls -d /Applications/Xcode_${XCODE_VERSION}*.app 2>/dev/null | head -1)
if [ -z "$XCODE_APP" ]; then
XCODE_APP="/Applications/Xcode.app"
fi
echo "Selecting: $XCODE_APP"
sudo xcode-select -s "$XCODE_APP/Contents/Developer"
xcodebuild -version
xcrun simctl list runtimes | grep -i ios
- name: Setup CocoaPods cache (iOS only)
if: matrix.platform == 'ios'
uses: actions/cache@v5
with:
path: |
~/.cocoapods/repos
~/Library/Caches/CocoaPods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Setup Xcode build cache (iOS only)
if: matrix.platform == 'ios'
uses: actions/cache@v5
with:
path: |
~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-xcode-${{ hashFiles('**/*.xcodeproj/**', '**/*.xcworkspace/**') }}
restore-keys: |
${{ runner.os }}-xcode-
- name: Free disk space (Android only)
if: matrix.platform == 'android'
run: |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc \
/usr/local/share/powershell /usr/local/share/chromium \
/usr/local/share/boost /opt/hostedtoolcache
sudo apt-get clean
df -h /
- name: Install Devbox
uses: jetify-com/devbox-install-action@v0.15.0
with:
enable-cache: true
- name: Rewrite plugin URLs to local
run: bash scripts/dev/rewrite-plugin-urls.sh --to-local examples/
- name: Run React Native E2E test
id: e2e
working-directory: examples/react-native
run: |
START=$SECONDS
set +e
if [ "${{ matrix.platform }}" = "android" ]; then
devbox run --pure -e IOS_SKIP_SETUP=1 -e EMU_HEADLESS=1 -e ANDROID_DEVICES=${{ matrix.device }} test:e2e:android
elif [ "${{ matrix.platform }}" = "ios" ]; then
devbox run --pure -e ANDROID_SKIP_SETUP=1 -e SIM_HEADLESS=1 -e IOS_DEVICES=${{ matrix.device }} test:e2e:ios
elif [ "${{ matrix.platform }}" = "web" ]; then
devbox run --pure -e ANDROID_SKIP_SETUP=1 -e IOS_SKIP_SETUP=1 test:e2e:web
fi
E2E_EXIT=$?
set -e
echo "e2e_duration=$(( SECONDS - START ))" >> "$GITHUB_OUTPUT"
exit $E2E_EXIT
- name: Write timing summary
if: always()
run: |
DURATION="${{ steps.e2e.outputs.e2e_duration }}"
RESULT="${{ steps.e2e.outcome }}"
PLATFORM="${{ matrix.platform }}"
DEVICE="${{ matrix.device }}"
MINUTES=$(( ${DURATION:-0} / 60 ))
SECS=$(( ${DURATION:-0} % 60 ))
mkdir -p examples/react-native/reports
cat > examples/react-native/reports/timing-${PLATFORM}.json <<TJSON
{"platform":"react-native-${PLATFORM}","device":"${DEVICE}","e2e_seconds":${DURATION:-0},"result":"${RESULT}","run_id":"${{ github.run_id }}"}
TJSON
echo "## React Native E2E Timing - ${PLATFORM}-${DEVICE}" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Metric | Value |" >> "$GITHUB_STEP_SUMMARY"
echo "|--------|-------|" >> "$GITHUB_STEP_SUMMARY"
echo "| Platform | ${PLATFORM} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Device | ${DEVICE} |" >> "$GITHUB_STEP_SUMMARY"
echo "| E2E duration | ${MINUTES}m ${SECS}s |" >> "$GITHUB_STEP_SUMMARY"
echo "| Result | ${RESULT} |" >> "$GITHUB_STEP_SUMMARY"
- name: Upload reports and logs
if: always()
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.artifact-prefix }}-${{ matrix.platform }}-${{ matrix.device }}-reports
path: |
examples/react-native/reports/
examples/react-native/android/app/build/outputs/
examples/react-native/ios/build/
~/Library/Logs/CoreSimulator/
retention-days: 7