From da7da8296c7ff63fb018432f2737f9af5b4783cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Zolnai?= Date: Fri, 12 Apr 2024 14:17:44 +0200 Subject: [PATCH] More tryfixes --- .github/workflows/check.yaml | 92 +++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 34 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index c44a8982..989034a6 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -5,7 +5,7 @@ on: [ pull_request ] jobs: build: name: build - runs-on: macos-latest # Needs to be macos for running AVD on Github + runs-on: ubuntu-latest # Needs to be macos for running AVD on Github env: SKIP_ICS_OPENVPN_BUILD: > --build-cache @@ -74,41 +74,65 @@ jobs: ./gradlew app:assembleBasicRelease app:assembleBasicDebugAndroidTest \ --build-cache --warning-mode all - # Based on https://github.com/marketplace/actions/android-emulator-runner - - name: AVD cache - uses: actions/cache@v3 - id: avd-cache - with: - path: | + # Setup the runner in the KVM group to enable HW Accleration for the emulator. + # see https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/ + - name: Enable KVM group perms + shell: bash + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + # Get the AVD if it's already cached. + - name : AVD cache + uses : actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + id : restore-avd-cache + with : + path : | ~/.android/avd/* ~/.android/adb* - key: avd-${{ matrix.api-level }} + key : avd-${{ matrix.api-level }} - - 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: ${{ matrix.api-level }} - arch: x86_64 - force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: false - script: echo "Generated AVD snapshot for caching." + # If the AVD cache didn't exist, create an AVD + - name : create AVD and generate snapshot for caching + if : steps.restore-avd-cache.outputs.cache-hit != 'true' + uses : reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 # v2 + with : + api-level : ${{ inputs.api-level }} + arch : x86_64 + disable-animations : false + emulator-boot-timeout : 12000 + emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + force-avd-creation : false + profile : Galaxy Nexus + ram-size : 4096M + script : echo "Generated AVD snapshot." - - name: Run tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: ${{ matrix.api-level }} - arch: x86_64 - disable-animations: true - disk-size: 4000M - heap-size: 600M - script: "./gradlew app:connectedCheck" + # If we just created an AVD because there wasn't one in the cache, then cache that AVD. + - name : cache new AVD before tests + if : steps.restore-avd-cache.outputs.cache-hit != 'true' + id : save-avd-cache + uses : actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + with : + path : | + ~/.android/avd/* + ~/.android/adb* + key : avd-${{ matrix.api-level }} - - name: Store test reports - uses: actions/upload-artifact@v4 - with: - name: test-reports - path: '**/build/reports/androidTests' - retention-days: 7 - if: always() \ No newline at end of file + - name : Run tests + uses : reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 # v2 + with : + api-level : ${{ matrix.api-level }} + arch : x86_64 + disable-animations : true + emulator-options : -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + force-avd-creation : false + profile : Galaxy Nexus + script: "./gradlew :app:connectedBasicDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.package=nl.eduvpn.app.service $SKIP_ICS_OPENVPN_BUILD" + + - name : Upload results + if : ${{ always() }} + uses : actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3 + with : + name : instrumentation-test-results + path : ./**/build/reports/androidTests/connected/** \ No newline at end of file