Skip to content

Commit 8843535

Browse files
authored
chore(🐙): add testing to the CI (#321)
1 parent b452de8 commit 8843535

1 file changed

Lines changed: 119 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 119 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090

9191
build-android:
9292
if: github.event_name == 'workflow_dispatch' && github.event.inputs.build_android == 'true'
93-
runs-on: macos-latest
93+
runs-on: ubuntu-latest
9494
env:
9595
TURBO_CACHE_DIR: .turbo/android
9696
steps:
@@ -102,6 +102,17 @@ jobs:
102102
with:
103103
github_token: ${{ secrets.GITHUB_TOKEN }}
104104

105+
- name: Free disk space
106+
uses: jlumbroso/free-disk-space@main
107+
with:
108+
tool-cache: false
109+
android: false
110+
dotnet: true
111+
haskell: true
112+
large-packages: true
113+
docker-images: true
114+
swap-storage: true
115+
105116
- name: Cache turborepo for Android
106117
uses: actions/cache@v4
107118
with:
@@ -110,16 +121,7 @@ jobs:
110121
restore-keys: |
111122
${{ runner.os }}-turborepo-android
112123
113-
- name: Check turborepo cache for Android
114-
run: |
115-
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
116-
117-
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
118-
echo "turbo_cache_hit=1" >> $GITHUB_ENV
119-
fi
120-
121124
- name: Install JDK
122-
if: env.turbo_cache_hit != 1
123125
uses: actions/setup-java@v3
124126
with:
125127
distribution: 'zulu'
@@ -135,15 +137,13 @@ jobs:
135137
run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV
136138

137139
- name: Finalize Android SDK
138-
if: env.turbo_cache_hit != 1
139140
run: |
140141
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
141142
142143
- name: Install Android SDK
143144
run: echo "sdk.dir=$ANDROID_HOME" > $GITHUB_WORKSPACE/apps/example/android/local.properties
144145

145146
- name: Cache Gradle
146-
if: env.turbo_cache_hit != 1
147147
uses: actions/cache@v4
148148
with:
149149
path: |
@@ -157,9 +157,93 @@ jobs:
157157
env:
158158
JAVA_OPTS: "-XX:MaxHeapSize=6g"
159159
run: |
160-
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --force
160+
yarn turbo run build:android --concurrency 1
161+
162+
- name: Cache apk
163+
uses: actions/cache/save@v4
164+
env:
165+
cache-name: cache-apk
166+
with:
167+
path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk
168+
key: apk-${{ github.sha }}
161169

162-
build-ios:
170+
- name: Upload Android APK artifact
171+
uses: actions/upload-artifact@v4
172+
with:
173+
name: android-example-apk
174+
path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk
175+
176+
test-android:
177+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.build_android == 'true'
178+
needs: build-android
179+
runs-on: ubuntu-latest
180+
timeout-minutes: 60
181+
env:
182+
TURBO_CACHE_DIR: .turbo/android
183+
steps:
184+
- name: Checkout
185+
uses: actions/checkout@v4
186+
187+
- name: Setup
188+
uses: ./.github/actions/setup
189+
with:
190+
github_token: ${{ secrets.GITHUB_TOKEN }}
191+
192+
- name: Setup Android SDK
193+
uses: android-actions/setup-android@v3
194+
195+
- name: Install Android SDK tools
196+
run: |
197+
echo "ANDROID_HOME=$ANDROID_HOME" >> $GITHUB_ENV
198+
echo "$ANDROID_HOME/cmdline-tools/latest/bin" >> $GITHUB_PATH
199+
echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH
200+
echo "$ANDROID_HOME/emulator" >> $GITHUB_PATH
201+
202+
- name: Enable KVM group perms
203+
run: |
204+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
205+
sudo udevadm control --reload-rules
206+
sudo udevadm trigger --name-match=kvm
207+
208+
- name: Restore APK
209+
id: cache-apk
210+
uses: actions/cache/restore@v4
211+
with:
212+
path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk
213+
key: apk-${{ github.sha }}
214+
215+
- name: Start Package Manager
216+
working-directory: apps/example
217+
run: E2E=true yarn start &
218+
219+
- name: Run Android Emulator Tests
220+
uses: reactivecircus/android-emulator-runner@v2
221+
with:
222+
api-level: 30
223+
arch: x86_64
224+
profile: Nexus 5X
225+
force-avd-creation: true
226+
emulator-options: -no-snapshot-save -no-window -gpu swangle_indirect -noaudio -no-boot-anim
227+
disable-animations: true
228+
script: |
229+
# Wait for Metro bundler
230+
sleep 10
231+
232+
# Install and launch app
233+
adb install -r apps/example/android/app/build/outputs/apk/debug/app-debug.apk
234+
adb shell monkey -p com.microsoft.reacttestapp 1
235+
236+
# Run tests
237+
cd packages/webgpu && CI=true yarn test
238+
239+
- name: Upload test snapshots on failure
240+
uses: actions/upload-artifact@v4
241+
if: failure()
242+
with:
243+
path: packages/webgpu/src/__tests__/snapshots/
244+
name: tests-snapshots-android
245+
246+
build-test-ios:
163247
if: github.event_name == 'workflow_dispatch' && github.event.inputs.build_ios == 'true'
164248
runs-on: macos-latest
165249
env:
@@ -189,9 +273,28 @@ jobs:
189273
echo "turbo_cache_hit=1" >> $GITHUB_ENV
190274
fi
191275
276+
- name: Install CocoaPods
277+
working-directory: apps/example/ios
278+
run: pod install
279+
280+
- name: Start Package Manager
281+
working-directory: apps/example
282+
run: E2E=true yarn start &
283+
192284
- name: Build example for iOS
193-
run: |
194-
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
285+
working-directory: apps/example
286+
run: yarn ios --simulator 'iPhone 16 Pro'
287+
288+
- name: Run e2e tests
289+
working-directory: packages/webgpu
290+
run: CI=true E2E=true yarn test
291+
292+
- name: Upload test snapshots on failure
293+
uses: actions/upload-artifact@v4
294+
if: failure()
295+
with:
296+
path: packages/webgpu/src/__tests__/snapshots/
297+
name: tests-snapshots-ios
195298

196299
# Note: This job is disabled by default until RNTA supports 0.81
197300
# Enable it manually via workflow_dispatch when needed

0 commit comments

Comments
 (0)