Skip to content

Commit 6e53043

Browse files
fix: streamline Android and iOS CI workflows by consolidating jobs and enhancing caching mechanisms
1 parent 6c00ca9 commit 6e53043

2 files changed

Lines changed: 38 additions & 187 deletions

File tree

.github/workflows/android.yml

Lines changed: 29 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ env:
1010
AVD_NAME: 'Pixel_API_34'
1111

1212
jobs:
13-
# Job 1: Build APK
14-
build:
15-
name: Build APK
13+
android:
14+
name: Android Build & Test
1615
runs-on: ubuntu-latest
17-
timeout-minutes: 30
16+
timeout-minutes: 60
1817

1918
steps:
2019
- name: Checkout
@@ -32,13 +31,31 @@ jobs:
3231
- name: Setup Android SDK
3332
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407
3433

34+
- name: Enable KVM
35+
run: |
36+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
37+
sudo udevadm control --reload-rules
38+
sudo udevadm trigger --name-match=kvm
39+
ls /dev/kvm
40+
41+
# Check caches first
3542
- name: Cache APK build output
3643
id: cache-apk
3744
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
3845
with:
3946
path: example/android/app/build/outputs/apk/debug/app-debug.apk
4047
key: ${{ runner.os }}-apk-${{ hashFiles('android/**/*.{java,kt,xml}', 'example/android/**/*.{java,kt,xml,gradle}', 'src/**/*.{js,jsx,ts,tsx}', 'package.json', 'yarn.lock') }}
4148

49+
- name: AVD cache
50+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
51+
id: avd-cache
52+
with:
53+
path: |
54+
~/.android/avd/*
55+
~/.android/adb*
56+
key: avd-${{ env.DEVICE_API_LEVEL }}-${{ env.DEVICE_ARCH }}
57+
58+
# Build dependencies (only if APK not cached)
4259
- name: Cache NDK
4360
id: cache-ndk
4461
if: steps.cache-apk.outputs.cache-hit != 'true'
@@ -65,53 +82,13 @@ jobs:
6582
restore-keys: |
6683
${{ runner.os }}-gradle-
6784
85+
# Build APK (only if not cached)
6886
- name: Build APK with Gradle
6987
if: steps.cache-apk.outputs.cache-hit != 'true'
7088
run: ./gradlew assembleDebug
7189
working-directory: example/android
7290

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-
91+
# Create AVD (only if not cached, runs after build)
11592
- name: Create AVD and generate snapshot for caching
11693
if: steps.avd-cache.outputs.cache-hit != 'true'
11794
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
@@ -127,53 +104,6 @@ jobs:
127104
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -memory 4096
128105
script: echo "Generated AVD snapshot for caching."
129106

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-
177107
# Run tests with emulator
178108
- name: Run Harness E2E tests
179109
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
@@ -191,3 +121,9 @@ jobs:
191121
script: |
192122
adb install -r "./android/app/build/outputs/apk/debug/app-debug.apk"
193123
yarn harness:android
124+
125+
# Cleanup
126+
- name: Stop Gradle Daemon
127+
if: always()
128+
working-directory: example/android
129+
run: ./gradlew --stop

.github/workflows/ios.yml

Lines changed: 9 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ env:
99
USE_CCACHE: 1
1010

1111
jobs:
12-
# Job 1: Build iOS App
13-
build:
14-
name: Build iOS App
12+
ios:
13+
name: iOS Build & Test
1514
runs-on: macos-latest
16-
timeout-minutes: 40
15+
timeout-minutes: 60
1716
env:
1817
DEVELOPER_DIR: /Applications/Xcode_26.1.app/Contents/Developer
1918

@@ -34,13 +33,15 @@ jobs:
3433
bundler-cache: true
3534
working-directory: example
3635

36+
# Check if app is cached
3737
- name: Cache iOS build artifacts
3838
id: cache-ios-app
3939
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
4040
with:
4141
path: example/ios/build/Build/Products/Debug-iphonesimulator/MendixNativeExample.app
4242
key: ios-app-${{ runner.os }}-${{ hashFiles('example/ios/Podfile.lock', 'example/ios/**/*.{swift,h,m,mm}', 'ios/**/*.{swift,h,m,mm}', 'src/**/*.{js,jsx,ts,tsx}', 'package.json', 'yarn.lock') }}
4343

44+
# Build dependencies (only if app not cached)
4445
- name: Cache DerivedData
4546
if: steps.cache-ios-app.outputs.cache-hit != 'true'
4647
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
@@ -69,6 +70,7 @@ jobs:
6970
bundle install
7071
cd ios && bundle exec pod install
7172
73+
# Build iOS app (only if not cached)
7274
- name: Build iOS app for simulator
7375
if: steps.cache-ios-app.outputs.cache-hit != 'true'
7476
working-directory: example/ios
@@ -82,96 +84,7 @@ jobs:
8284
-derivedDataPath build \
8385
build
8486
85-
- name: Upload iOS app artifact
86-
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874
87-
with:
88-
name: ios-app
89-
path: example/ios/build/Build/Products/Debug-iphonesimulator/MendixNativeExample.app
90-
retention-days: 1
91-
92-
# Job 2: Setup Simulator (runs in parallel with build)
93-
prepare-device:
94-
name: Prepare Simulator
95-
runs-on: macos-latest
96-
timeout-minutes: 10
97-
env:
98-
DEVELOPER_DIR: /Applications/Xcode_26.1.app/Contents/Developer
99-
100-
steps:
101-
- name: Checkout
102-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
103-
104-
- name: Setup Xcode
105-
run: sudo xcode-select -s /Applications/Xcode_26.1.app
106-
107-
- name: Setup iOS Simulator
108-
uses: futureware-tech/simulator-action@dab10d813144ef59b48d401cd95da151222ef8cd
109-
with:
110-
model: ${{ env.DEVICE_MODEL }}
111-
os: iOS
112-
os_version: ${{ env.IOS_VERSION }}
113-
wait_for_boot: true
114-
erase_before_boot: false
115-
116-
- name: Get booted simulator UDID
117-
id: sim-udid
118-
run: |
119-
UDID=$(xcrun simctl list devices booted | grep -o '[A-F0-9]\{8\}-[A-F0-9]\{4\}-[A-F0-9]\{4\}-[A-F0-9]\{4\}-[A-F0-9]\{12\}' | head -n 1)
120-
echo "UDID=$UDID"
121-
echo "udid=$UDID" >> $GITHUB_OUTPUT
122-
123-
- name: Save simulator UDID to artifact
124-
run: |
125-
echo "${{ steps.sim-udid.outputs.udid }}" > simulator-udid.txt
126-
127-
- name: Upload simulator UDID artifact
128-
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874
129-
with:
130-
name: simulator-udid
131-
path: simulator-udid.txt
132-
retention-days: 1
133-
134-
# Job 3: Run tests (waits for both build and device setup)
135-
test:
136-
name: Run Tests
137-
runs-on: macos-latest
138-
needs: [build, prepare-device]
139-
timeout-minutes: 30
140-
env:
141-
DEVELOPER_DIR: /Applications/Xcode_26.1.app/Contents/Developer
142-
143-
steps:
144-
- name: Checkout
145-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
146-
147-
- name: Setup Project
148-
uses: ./.github/actions/setup-node-yarn
149-
150-
- name: Setup Xcode
151-
run: sudo xcode-select -s /Applications/Xcode_26.1.app
152-
153-
# Download pre-built iOS app from build job
154-
- name: Download iOS app artifact
155-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
156-
with:
157-
name: ios-app
158-
path: example/ios/build/Build/Products/Debug-iphonesimulator/MendixNativeExample.app
159-
160-
# Download simulator UDID from prepare-device job
161-
- name: Download simulator UDID artifact
162-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
163-
with:
164-
name: simulator-udid
165-
path: .
166-
167-
- name: Read simulator UDID
168-
id: sim-udid
169-
run: |
170-
UDID=$(cat simulator-udid.txt)
171-
echo "UDID=$UDID"
172-
echo "udid=$UDID" >> $GITHUB_OUTPUT
173-
174-
# Boot the simulator (it may have been shut down between jobs)
87+
# Setup simulator (after build)
17588
- name: Setup iOS Simulator
17689
uses: futureware-tech/simulator-action@dab10d813144ef59b48d401cd95da151222ef8cd
17790
with:
@@ -181,10 +94,12 @@ jobs:
18194
wait_for_boot: true
18295
erase_before_boot: false
18396

97+
# Install app on simulator
18498
- name: Install app on simulator
18599
run: |
186100
xcrun simctl install booted example/ios/build/Build/Products/Debug-iphonesimulator/MendixNativeExample.app
187101
102+
# Run tests
188103
- name: Run Harness E2E tests
189104
working-directory: example
190105
run: yarn harness:ios

0 commit comments

Comments
 (0)