-
Notifications
You must be signed in to change notification settings - Fork 5
89 lines (73 loc) · 2.92 KB
/
android-tests.yml
File metadata and controls
89 lines (73 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Android Instrumented Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: # Allow manual triggering
jobs:
instrumented-tests:
runs-on: macos-latest # macOS runner for hardware acceleration
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run unit tests
run: ./gradlew :android:testDebugUnitTest
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: ReactiveCircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Created AVD snapshot"
- name: Run instrumented tests with coverage
uses: ReactiveCircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
./gradlew :android:connectedDebugAndroidTest
# Find coverage data (EC files)
COVERAGE_DATA=$(find android/build -name "*.ec" | head -n 1)
if [ -n "$COVERAGE_DATA" ]; then
echo "Found coverage data: $COVERAGE_DATA"
# Download JaCoCo CLI
mkdir -p tools
curl -L "https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.10/org.jacoco.cli-0.8.10-nodeps.jar" -o tools/jacoco-cli.jar
# Create report directory
mkdir -p android/build/reports/jacoco-android/html
# Generate HTML report
java -jar tools/jacoco-cli.jar report "$COVERAGE_DATA" \
--classfiles android/build/tmp/kotlin-classes/debug \
--sourcefiles android/src/main/java \
--html android/build/reports/jacoco-android/html \
--xml android/build/reports/jacoco-android/report.xml
fi
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: android/build/reports/jacoco-android
retention-days: 7