@@ -79,17 +79,36 @@ jobs:
7979 - name : Checkout code
8080 uses : actions/checkout@v4
8181
82- - name : Setup KVM
83- shell : bash
82+ - name : Enable KVM
8483 run : |
85- # check if virtualization is supported...
86- sudo apt install -y --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok
87- # allow access to KVM to run the emulator
88- echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
89- | sudo tee /etc/udev/rules.d/99-kvm4all.rules
84+ echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
9085 sudo udevadm control --reload-rules
9186 sudo udevadm trigger --name-match=kvm
9287
88+ - name : AVD cache
89+ uses : actions/cache@v4
90+ id : avd-cache
91+ with :
92+ path : |
93+ ~/.android/avd/*
94+ ~/.android/adb*
95+ key : avd-api-${{ matrix.api-level }}-${{ matrix.arch }}-${{ matrix.target }}
96+
97+ - name : Create AVD and generate snapshot for caching
98+ if : steps.avd-cache.outputs.cache-hit != 'true'
99+ uses : reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2
100+ with :
101+ api-level : ${{ matrix.api-level }}
102+ target : ${{ matrix.target }}
103+ channel : ${{ matrix.channel }}
104+ arch : ${{ matrix.arch }}
105+ force-avd-creation : false
106+ disable-animations : true
107+ disable-spellchecker : true
108+ emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
109+ disk-size : 4096M
110+ script : echo "Generated AVD snapshot for caching."
111+
93112 - name : Download APK artifact
94113 uses : actions/download-artifact@v5
95114 with :
@@ -104,21 +123,13 @@ jobs:
104123 uses :
reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # [email protected] 105124 with :
106125 api-level : ${{ matrix.api-level }}
107- force-avd-creation : false
108- disable-animations : true
109- disable-spellchecker : true
110126 target : ${{ matrix.target }}
111127 channel : ${{ matrix.channel }}
112128 arch : ${{ matrix.arch }}
113- emulator-options : >
114- -no-window
115- -no-snapshot-save
116- -gpu swiftshader_indirect
117- -noaudio
118- -no-boot-anim
119- -camera-back none
120- -camera-front none
121- -timezone US/Pacific
129+ force-avd-creation : false
130+ disable-animations : true
131+ disable-spellchecker : true
132+ emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save
122133 script : |
123134 adb install -r -d "${{env.APK_NAME}}"
124135 maestro test "${{env.BASE_PATH}}/maestro" --debug-output "${{env.BASE_PATH}}/maestro-logs"
0 commit comments