Skip to content

Commit

Permalink
Add CI workflow for building and testing the app
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
  • Loading branch information
chenxiaolong committed Jul 20, 2024
1 parent d786387 commit 543c58e
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
on:
push:
branches:
- master
pull_request:
jobs:
build-app:
name: Build app
runs-on: ubuntu-latest
env:
androidApi: 34
androidArch: x86_64
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: true

- name: Validate gradle wrapper checksum
uses: gradle/actions/wrapper-validation@v3

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
cache: gradle

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Install gomobile
shell: bash
run: |-
version=$(grep golang.org/x/mobile rcbridge/go.mod | awk '{print $2}')
go install golang.org/x/mobile/cmd/gobind@"${version}"
go install golang.org/x/mobile/cmd/gomobile@"${version}"
- name: Get NDK version
id: get_version
shell: bash
run: |
sed -nr 's/^\s*(ndkVersion)\s*(=)\s"(.+)".*$/\1\2\3/p' \
app/build.gradle.kts \
>> "${GITHUB_OUTPUT}"
- 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-${{ env.androidApi }}-${{ env.androidArch }}-${{ steps.get_version.outputs.ndkVersion }}

- name: Create AVD snapshot
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.androidApi }}
arch: ${{ env.androidArch }}
ndk: ${{ steps.get_version.outputs.ndkVersion }}
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: Build and test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.androidApi }}
arch: ${{ env.androidArch }}
ndk: ${{ steps.get_version.outputs.ndkVersion }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
# Debug build only since release builds require a signing key
script: ./gradlew --no-daemon build connectedDebugAndroidTest -x assembleRelease

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true

0 comments on commit 543c58e

Please sign in to comment.