Skip to content

[CI][ANDR] Add Gradle plugin to check against non-permitted licenses #10

[CI][ANDR] Add Gradle plugin to check against non-permitted licenses

[CI][ANDR] Add Gradle plugin to check against non-permitted licenses #10

Workflow file for this run

name: android
on:
push:
branches:
- main
pull_request:
# Cancel in-progress CI jobs when a new commit is pushed to a PR.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pre_check:
name: pre_check
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check_changes.outputs.run_tests }}
steps:
# Checkout repo to Github Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: check for relevant changes
id: check_changes
run: |
./ci/check_bazel.sh //examples/android:android_app || ./ci/files_changed.sh .github/workflows/android.yaml || ./ci/files_changed.sh "^platform/jvm/gradle-test-app/.*\.(gradle|kts|kt|xml)$" && ./ci/run_tests.sh
true
build_apk:
runs-on: ubuntu-latest
if: needs.pre_check.outputs.should_run == 'true'
needs: pre_check
steps:
# Checkout repo to Github Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: build apk
timeout-minutes: 30
run: ./bazelw build --config ci --config release-android --fat_apk_cpu=x86_64 //examples/android:android_app
- uses: actions/upload-artifact@v4
with:
name: android_app.apk
path: ./bazel-bin/examples/android/android_app.apk
gradle_tests:
# Requires a "larger runner", for nested virtualization support
runs-on: ubuntu-latest-8-cores
env:
SKIP_PROTO_GEN: 1
if: needs.pre_check.outputs.should_run == 'true'
needs: pre_check
steps:
- name: Checkout project sources
uses: actions/checkout@v4
# 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
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 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: gradle
- name: Setup Rust ARM target
run: rustup update && rustup target add aarch64-linux-android && rustup target add x86_64-linux-android
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: ${{ runner.os }}-avd-api-21-2
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
timeout-minutes: 30
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # pin@v2.32
with:
channel: beta
force-avd-creation: false
api-level: 21
target: default
ram-size: 2048M
arch: x86_64
disk-size: 4096M
profile: Nexus 6
disable-animations: true
emulator-options: -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: echo "Generated AVD snapshot for caching."
- name: Gradle capture-timber unit tests
working-directory: ./platform/jvm
run: ./gradlew capture-timber:testReleaseUnitTest --info
- name: Instrumentation Tests
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # pin@v2.32
with:
channel: beta
force-avd-creation: false
api-level: 21
target: default
ram-size: 2048M
arch: x86_64
disk-size: 4096M
profile: Nexus 6
disable-animations: true
emulator-options: -no-snapshot-save -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: cd platform/jvm && adb uninstall io.bitdrift.gradletestapp.test; adb uninstall io.bitdrift.gradletestapp; cd ../.. && ./tools/android_sdk_wrapper.sh platform/jvm/gradlew -p platform/jvm gradle-test-app:check gradle-test-app:connectedCheck --stacktrace
verify_android_hello_world_per_version:
needs: build_apk
runs-on: ubuntu-latest-8-cores
strategy:
matrix:
api-level: [21, 34]
steps:
# Checkout repo to Github Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# 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
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
- uses: actions/download-artifact@v4
with:
name: android_app.apk
path: .
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: ${{ runner.os }}-avd-api${{ matrix.api-level }}-1
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
timeout-minutes: 30
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b # pin@v2
with:
channel: beta
api-level: ${{ matrix.api-level }}
target: google_apis
ram-size: 2048M
arch: x86_64
disk-size: 4096M
profile: Nexus 6
emulator-options: -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: echo "Generated AVD snapshot for caching."
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
timeout-minutes: 15
with:
force-avd-creation: false
channel: beta
api-level: ${{ matrix.api-level }}
target: google_apis
ram-size: 2048M
arch: x86_64
disk-size: 4096M
profile: Nexus 6
emulator-options: -no-snapshot-save -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: ./ci/verify_android.sh
# This is a noop job that completes once all the jobs spawned by the previous step completes. By blocking PR merges on this
# job completing, we are able to gate it on all the previous jobs without explicitly enumerating them.
verify_android:
runs-on: ubuntu-latest
needs: ["build_apk", "verify_android_hello_world_per_version", "gradle_tests"]
if: always()
steps:
# Checkout repo to Github Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: check result
run: ./ci/check_result.sh ${{ needs.build_apk.result }} && ./ci/check_result.sh ${{ needs.verify_android_hello_world_per_version.result }} && ./ci/check_result.sh ${{ needs.gradle_tests.result }}