Skip to content

Commit 008672c

Browse files
committed
[#70] Enforce CI environment on API 27, due to crash on arm64
1 parent 6dae82a commit 008672c

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

.github/workflows/dropshots-screenshot-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
with:
8888
api-level: ${{ matrix.api-level }}
8989
target: google_apis
90-
arch: x86_64
90+
arch: ${{ matrix.api-level == 27 && 'x86_64' || (runner.arch == 'ARM64' && 'arm64-v8a' || 'x86_64') }}
9191
ram-size: 3072M
9292
heap-size: 1024M
9393
force-avd-creation: false
@@ -101,7 +101,7 @@ jobs:
101101
with:
102102
api-level: ${{ matrix.api-level }}
103103
target: google_apis
104-
arch: x86_64
104+
arch: ${{ matrix.api-level == 27 && 'x86_64' || (runner.arch == 'ARM64' && 'arm64-v8a' || 'x86_64') }}
105105
ram-size: 3072M
106106
heap-size: 1024M
107107
force-avd-creation: false
@@ -151,17 +151,17 @@ jobs:
151151
ls -la || echo "No files found"
152152
153153
- name: Upload screenshots artifact
154-
uses: actions/upload-artifact@v4
155154
if: always()
155+
uses: actions/upload-artifact@v4
156156
with:
157157
name: screenshots-api-${{ matrix.api-level }}
158158
path: screenshots/
159159
retention-days: 7
160160
compression-level: 6
161161

162162
- name: Upload test reports
163-
uses: actions/upload-artifact@v4
164163
if: always()
164+
uses: actions/upload-artifact@v4
165165
with:
166166
name: test-reports-api-${{ matrix.api-level }}
167167
path: |

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
# https://docs.gradle.org/current/userguide/build_environment.html#sec:configuring_jvm_memory
1717
org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -Dlint.nullness.ignore-deprecated=true
1818

19+
# Android Test Optimizations for Dropshots
20+
android.testInstrumentationRunnerArguments.clearPackageData=true
21+
android.testInstrumentationRunnerArguments.disableAnalytics=true
22+
1923
# https://docs.gradle.org/current/userguide/build_cache.html
2024
org.gradle.caching=true
2125

scripts/run-screenshot-tests.sh

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,15 @@ check_system_requirements() {
135135
print_status "Checking system requirements..."
136136

137137
# Check available memory (at least 4GB recommended)
138-
local available_memory=$(free -m | awk 'NR==2{printf "%.0f", $7/1024}')
138+
local available_memory=0
139+
if command -v free &> /dev/null; then
140+
# Linux
141+
available_memory=$(free -m | awk 'NR==2{printf "%.0f", $7/1024}')
142+
elif command -v vm_stat &> /dev/null; then
143+
# macOS
144+
available_memory=$(vm_stat | awk '/free/ {gsub(/\./, "", $3); printf "%.0f", $3/1024/1024}')
145+
fi
146+
139147
if [[ $available_memory -lt 4 ]]; then
140148
print_warning "Low available memory: ${available_memory}GB (4GB+ recommended)"
141149
fi
@@ -182,15 +190,31 @@ create_avd() {
182190

183191
print_status "Creating AVD: $avd_name"
184192

193+
# Detect architecture
194+
local arch=""
195+
if [[ "$(uname -m)" == "arm64" ]]; then
196+
arch="arm64-v8a"
197+
else
198+
arch="x86_64"
199+
fi
200+
201+
# Determine system image type based on API level and architecture
202+
local system_image=""
203+
if [[ $api_level -eq 27 ]]; then
204+
system_image="system-images;android-${api_level};default;${arch}"
205+
else
206+
system_image="system-images;android-${api_level};google_apis;${arch}"
207+
fi
208+
185209
# Download SDK image (if needed)
186-
print_status "Downloading system image for API $api_level..."
187-
sdkmanager "system-images;android-${api_level};google_apis;x86_64"
210+
print_status "Downloading system image for API $api_level ($arch)..."
211+
sdkmanager "$system_image"
188212

189213
# Create AVD
190214
print_status "Creating AVD with system image..."
191215
echo "no" | avdmanager create avd \
192216
-n "$avd_name" \
193-
-k "system-images;android-${api_level};google_apis;x86_64" \
217+
-k "$system_image" \
194218
-d "pixel_xl" \
195219
--force
196220

@@ -279,12 +303,12 @@ collect_screenshots() {
279303

280304
# Clean up filenames
281305
cd "$output_dir"
282-
for file in *.png 2>/dev/null; do
306+
for file in *.png; do
283307
if [[ -f "$file" && "$file" != *"api$api_level"* ]]; then
284308
base_name="${file%.png}"
285309
mv "$file" "${base_name}_api${api_level}.png" 2>/dev/null || true
286310
fi
287-
done
311+
done 2>/dev/null || true
288312
cd - > /dev/null
289313

290314
local count=$(find "$output_dir" -name "*.png" 2>/dev/null | wc -l)

0 commit comments

Comments
 (0)