Skip to content

Commit 6c00ca9

Browse files
refactor: consolidate Android and iOS CI workflows into unified configurations
1 parent 5f9c5b0 commit 6c00ca9

7 files changed

Lines changed: 391 additions & 310 deletions

File tree

.github/workflows/android.yml

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
name: Android Build & Test
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
DEVICE_API_LEVEL: '34'
8+
DEVICE_ARCH: 'x86_64'
9+
DEVICE_TARGET: 'google_apis'
10+
AVD_NAME: 'Pixel_API_34'
11+
12+
jobs:
13+
# Job 1: Build APK
14+
build:
15+
name: Build APK
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 30
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
22+
23+
- name: Setup Project
24+
uses: ./.github/actions/setup-node-yarn
25+
26+
- name: Setup Java
27+
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e
28+
with:
29+
distribution: 'zulu'
30+
java-version: '17'
31+
32+
- name: Setup Android SDK
33+
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407
34+
35+
- name: Cache APK build output
36+
id: cache-apk
37+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
38+
with:
39+
path: example/android/app/build/outputs/apk/debug/app-debug.apk
40+
key: ${{ runner.os }}-apk-${{ hashFiles('android/**/*.{java,kt,xml}', 'example/android/**/*.{java,kt,xml,gradle}', 'src/**/*.{js,jsx,ts,tsx}', 'package.json', 'yarn.lock') }}
41+
42+
- name: Cache NDK
43+
id: cache-ndk
44+
if: steps.cache-apk.outputs.cache-hit != 'true'
45+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
46+
with:
47+
path: /usr/local/lib/android/sdk/ndk/27.3.13750724
48+
key: ${{ runner.os }}-ndk-27.3.13750724
49+
50+
- name: Install NDK
51+
if: steps.cache-apk.outputs.cache-hit != 'true' && steps.cache-ndk.outputs.cache-hit != 'true'
52+
run: echo "y" | ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;27.3.13750724"
53+
54+
- name: Cache Gradle
55+
if: steps.cache-apk.outputs.cache-hit != 'true'
56+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
57+
with:
58+
path: |
59+
~/.gradle/caches
60+
~/.gradle/wrapper
61+
example/android/.gradle
62+
example/android/app/.cxx
63+
example/android/app/build/intermediates
64+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'android/build.gradle', 'example/android/app/build.gradle') }}
65+
restore-keys: |
66+
${{ runner.os }}-gradle-
67+
68+
- name: Build APK with Gradle
69+
if: steps.cache-apk.outputs.cache-hit != 'true'
70+
run: ./gradlew assembleDebug
71+
working-directory: example/android
72+
73+
- name: Upload APK artifact
74+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874
75+
with:
76+
name: android-apk
77+
path: example/android/app/build/outputs/apk/debug/app-debug.apk
78+
retention-days: 1
79+
80+
# Job 2: Setup AVD (runs in parallel with build)
81+
prepare-device:
82+
name: Prepare Emulator
83+
runs-on: ubuntu-latest
84+
timeout-minutes: 15
85+
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
89+
90+
- name: Setup Java
91+
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e
92+
with:
93+
distribution: 'zulu'
94+
java-version: '17'
95+
96+
- name: Setup Android SDK
97+
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407
98+
99+
- name: Enable KVM
100+
run: |
101+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
102+
sudo udevadm control --reload-rules
103+
sudo udevadm trigger --name-match=kvm
104+
ls /dev/kvm
105+
106+
- name: AVD cache
107+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
108+
id: avd-cache
109+
with:
110+
path: |
111+
~/.android/avd/*
112+
~/.android/adb*
113+
key: avd-${{ env.DEVICE_API_LEVEL }}-${{ env.DEVICE_ARCH }}
114+
115+
- name: Create AVD and generate snapshot for caching
116+
if: steps.avd-cache.outputs.cache-hit != 'true'
117+
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
118+
with:
119+
api-level: ${{ env.DEVICE_API_LEVEL }}
120+
target: ${{ env.DEVICE_TARGET }}
121+
arch: ${{ env.DEVICE_ARCH }}
122+
ram-size: 4096M
123+
disk-size: 6G
124+
force-avd-creation: false
125+
avd-name: ${{ env.AVD_NAME }}
126+
disable-animations: true
127+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -memory 4096
128+
script: echo "Generated AVD snapshot for caching."
129+
130+
# Job 3: Run tests (waits for both build and device setup)
131+
test:
132+
name: Run Tests
133+
runs-on: ubuntu-latest
134+
needs: [build, prepare-device]
135+
timeout-minutes: 30
136+
137+
steps:
138+
- name: Checkout
139+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
140+
141+
- name: Setup Project
142+
uses: ./.github/actions/setup-node-yarn
143+
144+
- name: Setup Java
145+
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e
146+
with:
147+
distribution: 'zulu'
148+
java-version: '17'
149+
150+
- name: Setup Android SDK
151+
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407
152+
153+
- name: Enable KVM
154+
run: |
155+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
156+
sudo udevadm control --reload-rules
157+
sudo udevadm trigger --name-match=kvm
158+
ls /dev/kvm
159+
160+
# Download pre-built APK from build job
161+
- name: Download APK artifact
162+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
163+
with:
164+
name: android-apk
165+
path: example/android/app/build/outputs/apk/debug/
166+
167+
# Restore AVD from cache (created in prepare-device job)
168+
- name: AVD cache
169+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
170+
id: avd-cache
171+
with:
172+
path: |
173+
~/.android/avd/*
174+
~/.android/adb*
175+
key: avd-${{ env.DEVICE_API_LEVEL }}-${{ env.DEVICE_ARCH }}
176+
177+
# Run tests with emulator
178+
- name: Run Harness E2E tests
179+
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
180+
with:
181+
working-directory: example
182+
api-level: ${{ env.DEVICE_API_LEVEL }}
183+
target: ${{ env.DEVICE_TARGET }}
184+
arch: ${{ env.DEVICE_ARCH }}
185+
ram-size: 4096M
186+
force-avd-creation: false
187+
avd-name: ${{ env.AVD_NAME }}
188+
disable-animations: true
189+
emulator-boot-timeout: 900
190+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -memory 4096
191+
script: |
192+
adb install -r "./android/app/build/outputs/apk/debug/app-debug.apk"
193+
yarn harness:android

.github/workflows/build-android.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/workflows/build-ios.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,12 @@ jobs:
88
name: Lint
99
uses: ./.github/workflows/lint.yml
1010

11-
build-android:
12-
name: Build Android
13-
uses: ./.github/workflows/build-android.yml
11+
android:
12+
name: Android Build & Test
13+
needs: lint
14+
uses: ./.github/workflows/android.yml
1415

15-
build-ios:
16-
name: Build iOS
17-
uses: ./.github/workflows/build-ios.yml
18-
19-
test-android-harness:
20-
name: Test Android Harness
21-
needs: [lint, build-android]
22-
uses: ./.github/workflows/test-android-harness.yml
23-
24-
test-ios-harness:
25-
name: Test iOS Harness
26-
needs: [lint, build-ios]
27-
uses: ./.github/workflows/test-ios-harness.yml
16+
ios:
17+
name: iOS Build & Test
18+
needs: lint
19+
uses: ./.github/workflows/ios.yml

0 commit comments

Comments
 (0)