Skip to content

Commit

Permalink
ci: enable KVM for faster emulator (#2390) (#2428)
Browse files Browse the repository at this point in the history
* ci: enable KVM for faster emulator

* ci: upgrade actions to v4

* ci: fix wrong action name

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Yamil Medina <[email protected]>
  • Loading branch information
3 people authored Jan 30, 2024
1 parent 6b3352f commit bf8db0b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 39 deletions.
65 changes: 36 additions & 29 deletions .github/workflows/gradle-android-instrumented-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: ./.github/workflows/codestyle.yml
gradle-run-tests:
needs: [ detekt ]
runs-on: buildjet-4vcpu-ubuntu-2204
runs-on: ubuntu-22.04
strategy:
matrix:
api-level: [ 30 ]
Expand All @@ -25,8 +25,14 @@ jobs:
with:
fetch-depth: 0

- name: Enable KVM group perms # For a faster emulator
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: Set up JDK
uses: buildjet/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand All @@ -42,36 +48,37 @@ jobs:
run: |
./gradlew :samples:compileDebugSources
# - name: AVD cache
# uses: actions/cache@v3
# id: avd-cache
# with:
# path: |
# ~/.android/avd/*
# ~/.android/adb*
# 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.27.0
# with:
# api-level: ${{ matrix.api-level }}
# force-avd-creation: false
# target: google_apis
# emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# cores: 4
# ram-size: 4096M
# heap-size: 2048M
# disable-animations: false
# script: echo "Generated AVD snapshot for caching."
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
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 }}
force-avd-creation: false
target: google_apis
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
cores: 2
ram-size: 4096M
heap-size: 2048M
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Android Instrumentation Tests
uses: reactivecircus/android-emulator-runner@v2.27.0
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
target: google_apis
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
cores: 4
cores: 2
ram-size: 4096M
heap-size: 2048M
script: ./gradlew connectedAndroidOnlyAffectedTest
Expand All @@ -81,14 +88,14 @@ jobs:

- name: Archive Test Reports
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-reports
path: ./**/build/reports/tests/**

- name: Archive Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
Expand Down Expand Up @@ -117,7 +124,7 @@ jobs:

steps:
- name: Download tests results
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: test-results
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/gradle-android-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ jobs:

- name: Archive Test Reports
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-reports
path: ./**/build/reports/tests/**

- name: Archive Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:

steps:
- name: Download tests results
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: test-results
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/gradle-ios-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ jobs:

- name: Archive Test Reports
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-reports
path: ./**/build/reports/tests/**

- name: Archive Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:

steps:
- name: Download tests results
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: test-results
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/gradle-jvm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ jobs:
- name: Archive Test Reports
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-reports
path: ./**/build/reports/tests/**

- name: Archive Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-results
path: ./**/build/test-results/**/*.xml
Expand All @@ -89,7 +89,7 @@ jobs:
files: "build/reports/kover/report.xml"

- name: Archive Kover report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: kover-report
path: build/reports/kover/report.xml
Expand All @@ -108,7 +108,7 @@ jobs:

steps:
- name: Download tests results
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
continue-on-error: true
- name: Display structure of downloaded files
run: ls -R
Expand Down

0 comments on commit bf8db0b

Please sign in to comment.