77 branches : [ "**" ]
88
99jobs :
10- build :
10+ build-and-unit-tests :
1111 runs-on : ubuntu-latest
12- strategy :
13- matrix :
14- api-level : [ 34 ]
15-
1612 steps :
17- - uses : actions/checkout@v4
13+ - uses : actions/checkout@v5
1814
1915 - name : Set up JDK
20- uses : actions/setup-java@v4
16+ uses : actions/setup-java@v5
2117 with :
2218 distribution : ' temurin'
2319 java-version : ' 17'
2420
2521 - name : Setup Gradle
2622 uses : gradle/actions/setup-gradle@v4
2723
24+ - name : Gradle cache
25+ uses : gradle/actions/setup-gradle@v4
26+
2827 - name : Grant execute permission for gradlew
2928 run : chmod +x gradlew
3029
@@ -37,45 +36,81 @@ jobs:
3736 - name : Run Unit Tests
3837 run : ./gradlew test
3938
40- # - name: Enable KVM
41- # run: |
42- # echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
43- # sudo udevadm control --reload-rules
44- # sudo udevadm trigger --name-match=kvm
45- #
46- # - name: AVD cache
47- # uses: actions/cache@v4
48- # id: avd-cache
49- # with:
50- # path: |
51- # ~/.android/avd/*
52- # ~/.android/adb*
53- # key: avd-${{ matrix.api-level }}
54- #
55- # - name: create AVD and generate snapshot for caching
56- # if: steps.avd-cache.outputs.cache-hit != 'true'
57- # uses: reactivecircus/android-emulator-runner@v2
58- # with:
59- # api-level: ${{ matrix.api-level }}
60- # arch: x86_64
61- # target: default
62- # force-avd-creation: false
63- # disable-animations: false
64- # script: echo "Generated AVD snapshot for caching."
65- #
66- # - name: Run Instrumentation Tests
67- # uses: reactivecircus/android-emulator-runner@v2
68- # with:
69- # api-level: ${{ matrix.api-level }}
70- # arch: x86_64
71- # target: default
72- # force-avd-creation: false
73- # emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-front emulated -camera-back emulated
74- # disable-animations: true
75- # script: |
76- # adb wait-for-device
77- # adb shell input keyevent 82
78- # ./gradlew connectedOssDebugAndroidTest --continue
39+ instrumentation-tests :
40+ needs : build-and-unit-tests
41+ runs-on : ubuntu-latest
42+ strategy :
43+ matrix :
44+ api-level : [ 29, 33, 36 ]
45+ image-target : [ google_apis ]
46+ steps :
47+ - uses : actions/checkout@v5
48+
49+ - name : Set up JDK
50+ uses : actions/setup-java@v5
51+ with :
52+ distribution : ' temurin'
53+ java-version : ' 17'
54+
55+ - name : Setup Gradle
56+ uses : gradle/actions/setup-gradle@v4
57+
58+ - name : Grant execute permission for gradlew
59+ run : chmod +x gradlew
60+
61+ - name : Enable KVM
62+ run : |
63+ echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
64+ sudo udevadm control --reload-rules
65+ sudo udevadm trigger --name-match=kvm
66+
67+ - name : AVD cache
68+ uses : actions/cache@v4
69+ id : avd-cache
70+ with :
71+ path : |
72+ ~/.android/avd/*
73+ ~/.android/adb*
74+ key : avd-${{ matrix.api-level }}-{{ matrix.image-target }}
75+
76+ - name : create AVD and generate snapshot for caching
77+ if : steps.avd-cache.outputs.cache-hit != 'true'
78+ uses : reactivecircus/android-emulator-runner@v2
79+ with :
80+ api-level : ${{ matrix.api-level }}
81+ target : ${{ matrix.image-target }}
82+ arch : x86_64
83+ force-avd-creation : false
84+ emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
85+ disable-animations : false
86+ script : echo "Generated AVD snapshot for caching."
87+
88+ - name : Run Instrumentation Tests
89+ uses : reactivecircus/android-emulator-runner@v2
90+ with :
91+ api-level : ${{ matrix.api-level }}
92+ target : ${{ matrix.image-target }}
93+ force-avd-creation : false
94+ emulator-options : -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
95+ disable-animations : true
96+ arch : x86_64
97+ script : ./gradlew connectedCheck
98+
99+ - name : Collect logcat
100+ if : failure()
101+ run : |
102+ adb logcat -d > logcat.txt || true
103+ mkdir -p artifacts
104+ mv logcat.txt artifacts/ || true
105+ find app/build/reports -maxdepth 4 -type f -print0 | xargs -0 -I{} cp --parents {} artifacts/ || true
106+ find app/build/outputs/androidTest-results -maxdepth 6 -type f -print0 | xargs -0 -I{} cp --parents {} artifacts/ || true
107+
108+ - name : Upload test artifacts
109+ if : always()
110+ uses : actions/upload-artifact@v4
111+ with :
112+ name : android-test-artifacts
113+ path : artifacts
79114
80115 - name : Upload Test Reports
81116 if : failure()
0 commit comments