Skip to content

Commit

Permalink
ci: Improve the tests workflow
Browse files Browse the repository at this point in the history
- Move to ubuntu-latest, for better performance.
- Use NDK and SDK preinstalled on the runner image.
- Cache AVD snapshot.
  • Loading branch information
oleavr committed May 10, 2024
1 parent 4f30dbf commit c5eabe7
Showing 1 changed file with 28 additions and 35 deletions.
63 changes: 28 additions & 35 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: tests
on: [push, pull_request]
jobs:
tests:
runs-on: macos-12
runs-on: ubuntu-latest
strategy:
matrix:
api: [26, 27, 28, 29, 30, 31]
Expand All @@ -15,42 +15,35 @@ jobs:
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 200 # Default is 20
steps:
# can update to a newer version through https://developer.android.com/studio#downloads
- run: curl https://dl.google.com/android/repository/commandlinetools-mac-8512546_latest.zip -o /tmp/sdk.zip
- run: unzip -d /tmp/sdk /tmp/sdk.zip
- run: mkdir -p ~/Library/Android/Sdk/tools
- run: cp -r /tmp/sdk/cmdline-tools/* ~/Library/Android/Sdk/tools

- run: "echo y | ~/Library/Android/Sdk/tools/bin/sdkmanager tools --sdk_root=~/Library/Android/Sdk"
- run: "~/Library/Android/Sdk/tools/bin/sdkmanager platform-tools --sdk_root=~/Library/Android/Sdk"
- run: "~/Library/Android/Sdk/tools/bin/sdkmanager 'ndk;25.1.8937393' --sdk_root=~/Library/Android/Sdk"
- run: "~/Library/Android/Sdk/tools/bin/sdkmanager 'build-tools;33.0.0' --sdk_root=~/Library/Android/Sdk"

- uses: actions/checkout@v3
- run: |
echo "#!/bin/sh" >> /tmp/android_env
echo "export PATH=$PATH:/Users/runner/Library/Android/Sdk/build-tools/33.0.0" >> /tmp/android_env
echo "export ANDROID_SDK_ROOT=/Users/runner/Library/Android/Sdk" >> /tmp/android_env
echo "export ANDROID_API_LEVEL=${{ matrix.api }}" >> /tmp/android_env
case ${{ matrix.arch }} in
arm64-v8a)
echo "export ANDROID_ARCH=arm64" >> /tmp/android_env
echo "export ANDROID_ABI=arm64-v8a" >> /tmp/android_env
;;
x86)
echo "export ANDROID_ARCH=${{ matrix.arch }}" >> /tmp/android_env
echo "export ANDROID_ABI=${{ matrix.arch }}" >> /tmp/android_env
echo "export ANDROID_LIBDIR=/system/lib" >> /tmp/android_env
;;
*)
echo "export ANDROID_ARCH=${{ matrix.arch }}" >> /tmp/android_env
echo "export ANDROID_ABI=${{ matrix.arch }}" >> /tmp/android_env
;;
esac
chmod +x /tmp/android_env
- 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: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api }}
- 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 }}
arch: ${{ matrix.arch }}
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: Run tests in emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api }}
arch: ${{ matrix.arch }}
script: source /tmp/android_env && make check
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: make check

0 comments on commit c5eabe7

Please sign in to comment.