Skip to content

Commit 045bd6b

Browse files
authored
Fix CI emulator tests (#1176)
- The recent change to `macos-14` means that we can't use x64 emulator (as currently set). Ideally we would just use ARM64 emulators, but that is blocked by ReactiveCircus/android-emulator-runner#350 though. - Instead I've refactored the CI setup: - Moved most things to run `ubuntu-latest`. We can use the new nested-virt KVM support to make the emulator fast there. - We still use `macos-14` but only for iOS builds in a separate job. This is similar to what I do in Tivi. - Add some hierarchy to the jobs, so that `publish` only happens when all of the other jobs pass. - Benchmark tests do not work (by default) on emulators, which is why they've been failing for a while. We can suppress that error and get them to run but there's little benefit, so it's better to just disable them when running on an emulator.
1 parent fa114cc commit 045bd6b

File tree

2 files changed

+79
-24
lines changed

2 files changed

+79
-24
lines changed

.github/workflows/ci.yml

+77-24
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ concurrency:
1818

1919
jobs:
2020
build:
21-
# Necessary to run full tests to cover iOS too
22-
runs-on: macos-14
21+
runs-on: ubuntu-latest
2322
steps:
2423
- name: Checkout
2524
uses: actions/checkout@v4
@@ -32,15 +31,6 @@ jobs:
3231
distribution: 'zulu'
3332
java-version: '21'
3433

35-
- uses: ruby/setup-ruby@v1
36-
with:
37-
bundler-cache: true
38-
ruby-version: '3.2.2'
39-
40-
- uses: maxim-lobanov/setup-xcode@v1
41-
with:
42-
xcode-version: '15.2'
43-
4434
- name: Setup Gradle cache
4535
uses: gradle/gradle-build-action@v2
4636
with:
@@ -53,7 +43,6 @@ jobs:
5343
./gradlew --continue --no-configuration-cache \
5444
check \
5545
:samples:star:apk:assembleDebug \
56-
:samples:counter:linkReleaseFrameworkIosX64 \
5746
detektMain \
5847
detektTest \
5948
assembleAndroidTest
@@ -63,14 +52,6 @@ jobs:
6352
run: |
6453
./gradlew :samples:star:jvmJar -Pcircuit.buildDesktop
6554
66-
- run: brew install swiftlint
67-
68-
- name: Run lint on iOS samples
69-
run: bundle exec fastlane ios lint
70-
71-
- name: Build iOS samples
72-
run: bundle exec fastlane ios build
73-
7455
# Defer these until after the above run, no need to waste resources running them if there are other failures first
7556
- name: Run instrumentation tests via emulator.wtf (main repo only)
7657
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
@@ -79,6 +60,12 @@ jobs:
7960
EW_API_TOKEN: ${{ secrets.EMULATOR_WTF_TOKEN }}
8061
run: ./gradlew testReleaseWithEmulatorWtf
8162

63+
- name: Enable KVM group perms
64+
run: |
65+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
66+
sudo udevadm control --reload-rules
67+
sudo udevadm trigger --name-match=kvm
68+
8269
# Forks cannot run emulator.wtf tests due to not being able to use repo secrets, so for them
8370
# we run the tests via the android-emulator-runner action instead
8471
- name: Run instrumentation tests via local emulator (from forks only)
@@ -92,7 +79,9 @@ jobs:
9279
disable-animations: true
9380
disk-size: 6000M
9481
heap-size: 600M
95-
script: ./gradlew ciConnectedCheck --daemon
82+
script: |
83+
# Disable benchmark tests as they do not work on emulators
84+
./gradlew ciConnectedCheck -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=none
9685
9786
- name: (Fail-only) Upload reports
9887
if: failure()
@@ -102,9 +91,49 @@ jobs:
10291
path: |
10392
**/build/reports/**
10493
105-
- name: Publish snapshot (main branch only)
106-
if: github.repository == 'slackhq/circuit' && github.ref == 'refs/heads/main'
107-
run: ./gradlew publish -PmavenCentralUsername=${{ secrets.SONATYPEUSERNAME }} -PmavenCentralPassword=${{ secrets.SONATYPEPASSWORD }} --no-configuration-cache
94+
build-ios:
95+
runs-on: macos-14
96+
97+
steps:
98+
- name: Checkout
99+
uses: actions/checkout@v4
100+
with:
101+
lfs: 'true'
102+
103+
- name: Install JDK
104+
uses: actions/setup-java@v4
105+
with:
106+
distribution: 'zulu'
107+
java-version: '21'
108+
109+
- uses: ruby/setup-ruby@v1
110+
with:
111+
bundler-cache: true
112+
ruby-version: '3.2.2'
113+
114+
- uses: maxim-lobanov/setup-xcode@v1
115+
with:
116+
xcode-version: '15.2'
117+
118+
- name: Setup Gradle cache
119+
uses: gradle/gradle-build-action@v2
120+
with:
121+
gradle-home-cache-cleanup: true
122+
cache-read-only: false
123+
124+
- run: brew install swiftlint
125+
126+
- name: Run lint on iOS samples
127+
run: bundle exec fastlane ios lint
128+
129+
- name: Run iOS Simulator tests
130+
id: gradle-ios-tests
131+
run: |
132+
./gradlew --continue --no-configuration-cache \
133+
iosSimulatorArm64Test
134+
135+
- name: Build iOS samples
136+
run: bundle exec fastlane ios build
108137

109138
snapshots:
110139
runs-on: ubuntu-latest
@@ -139,3 +168,27 @@ jobs:
139168
path: |
140169
**/build/reports/**
141170
**/src/test/snapshots/**/*_compare.png
171+
172+
publish:
173+
runs-on: ubuntu-latest
174+
needs: [build, build-ios, snapshots]
175+
if: github.repository == 'slackhq/circuit' && github.ref == 'refs/heads/main'
176+
177+
steps:
178+
- name: Checkout
179+
uses: actions/checkout@v4
180+
181+
- name: Install JDK
182+
uses: actions/setup-java@v4
183+
with:
184+
distribution: 'zulu'
185+
java-version: '21'
186+
187+
- name: Setup Gradle cache
188+
uses: gradle/gradle-build-action@v2
189+
with:
190+
gradle-home-cache-cleanup: true
191+
cache-read-only: false
192+
193+
- name: Publish snapshot (main branch only)
194+
run: ./gradlew publish -PmavenCentralUsername=${{ secrets.SONATYPEUSERNAME }} -PmavenCentralPassword=${{ secrets.SONATYPEPASSWORD }} --no-configuration-cache

gradle.properties

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ dependency.analysis.compatibility=NONE
3939
kotlin.mpp.stability.nowarn=true
4040
kotlin.mpp.androidSourceSetLayoutVersion=2
4141
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
42+
# Ignore disabled targets (i.e iOS on Linux)
43+
kotlin.native.ignoreDisabledTargets=true
4244

4345
# https://kotlinlang.org/docs/ksp-multiplatform.html#avoid-the-ksp-configuration-on-ksp-1-0-1
4446
systemProp.allowAllTargetConfiguration=false

0 commit comments

Comments
 (0)