From 5388c851e9940a36ed0b2272ec1a518d7da06720 Mon Sep 17 00:00:00 2001 From: Cam Patten <112127155+PamCatten@users.noreply.github.com> Date: Wed, 28 Feb 2024 10:32:13 -0500 Subject: [PATCH] Update coverage.yml --- .github/workflows/coverage.yml | 99 ++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 12bdfcd..3c90e77 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -4,47 +4,66 @@ on: workflow_dispatch: jobs: - build: - + test: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'adopt' - - - name: Setup Android SDK - uses: android-actions/setup-android@v3 + - name: checkout + uses: actions/checkout@v4 + + - name: Enable KVM + 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 + + - name: Gradle cache + uses: gradle/actions/setup-gradle@v3 - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Generate test coverage reports - run: ./gradlew connectedCheck --no-daemon - - - name: Upload coverage reports to GitHub - uses: actions/upload-artifact@v4 - with: - name: report - path: app/build/reports/coverage/androidTest/debug/connected - - - name: Download coverage reports - uses: actions/download-artifact@v4 - with: - name: report - path: app/build/reports/coverage/androidTest/debug/connected + - name: AVD cache + uses: actions/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-33 + + - 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: 33 + 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." - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 - with: - files: "app/build/reports/coverage/androidTest/debug/connected/report.xml" - token: ${{ secrets.CODE_COV }} - slug: PamCatten/hot-stuff - env: - CODECOV_TOKEN: ${{ secrets.CODE_COV }} + - name: run tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 33 + 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 connectedCheck + + - name: Upload coverage reports to GitHub + uses: actions/upload-artifact@v4 + with: + name: report + path: app/build/reports/coverage/androidTest/debug/connected + + - name: Download coverage reports + uses: actions/download-artifact@v4 + with: + name: report + path: app/build/reports/coverage/androidTest/debug/connected + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + files: "app/build/reports/coverage/androidTest/debug/connected/report.xml" + token: ${{ secrets.CODE_COV }} + slug: PamCatten/hot-stuff + env: + CODECOV_TOKEN: ${{ secrets.CODE_COV }}