Skip to content

Release 7.1.0

Release 7.1.0 #53

Workflow file for this run

name: Android CI
on:
push:
paths:
- '*.gradle.kts'
- '*.properties'
- gradle/**
- app/**
# Cancel in-progress or pending jobs if a new run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
debug:
# Skip job if the HEAD commit message ends with the appropriate opt-out phrase
if: ${{ !endsWith(github.event.head_commit.message, '[ci skip-debug]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'temurin'
- uses: gradle/actions/setup-gradle@v5
with:
gradle-home-cache-cleanup: true
- name: Build debug and run unit tests
run: ./gradlew assembleDebug testDebug
# Format: `<branch_or_tag_name>_<sha>` or `<pr_number>/merge_<sha>`
- name: Get ref with short sha
id: ref-sha-suffix
run: |
sha_short=$(git rev-parse --short "$GITHUB_SHA")
echo "REF_SHA=${GITHUB_REF_NAME}_$sha_short" >> "$GITHUB_OUTPUT"
# Makes it easier for the team to test, if needed
- name: Upload debug APK to Discord
# Not sure if it's needed, but just in case: run this step only if it's our own repo
if: github.repository == 'oxygen-updater/oxygen-updater'
run: |
sha_short=$(git rev-parse --short "$GITHUB_SHA")
file='./app/build/outputs/apk/debug/app-debug.apk'
filename="oxygen-updater-debug_${{ steps.ref-sha-suffix.outputs.REF_SHA }}.apk"
curl -sS -X POST -F "file=@$file;filename=\"$filename\"" ${{ secrets.DISCORD_WEBHOOK_APKS }} > /dev/null || true
- name: Upload unit test results
if: always()
uses: actions/upload-artifact@v6
with:
name: test-results_${{ steps.ref-sha-suffix.outputs.REF_SHA }}
compression-level: 9
path: |
app/build/reports/tests/*
app/build/test-results/*
# Must be a separate job because we're utilizing matrices
instrumentation:
# Skip job if the HEAD commit message ends with the appropriate opt-out phrase
if: ${{ !endsWith(github.event.head_commit.message, '[ci skip-instrumentation]') }}
runs-on: ubuntu-latest
strategy:
# Let other tests continue if any matrix job fails
fail-fast: false
matrix:
# Should ideally be min (23) & target SDK (36), but:
# - API 21 always fails with `InstallException: INSTALL_FAILED_DEXOPT`.
# - ATDs are supported only from API 30 — 35
api-level: [ 23, 35 ]
env:
# Used in `reactivecircus/android-emulator-runner` steps. Default:
# `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
# However, specifying `-no-snapshot` disables the Quick Boot feature completely
# and doesn't load or save the emulator state. Because we're caching the AVD,
# we need a clean snapshot, so we need to exclude it from our defaults.
EMULATOR_OPTIONS: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'temurin'
- uses: gradle/actions/setup-gradle@v5
with:
gradle-home-cache-cleanup: true
- name: Create dummy google-services.json
run: |
cat <<'EOF' > app/google-services.json
${{ secrets.FILE_GOOGLE_SERVICES_JSON_FOR_INSTRUMENTATION }}
EOF
# Since 17th Jan 2024, public repository workflows run on larger Linux VMs with HW acceleration
# https://github.com/reactivecircus/android-emulator-runner#running-hardware-accelerated-emulators-on-linux-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
# Use Automated Test Devices on API 30 — 33 for better runtime performance
# https://developer.android.com/studio/test/gradle-managed-devices#gmd-atd
- name: Determine emulator target
id: determine-target
env:
API_LEVEL: ${{ matrix.api-level }}
run: |
TARGET="google_apis"
if [ "$API_LEVEL" -ge "30" ]; then
TARGET="google_atd"
fi
echo "TARGET=$TARGET" >> "$GITHUB_OUTPUT"
- name: AVD cache
uses: actions/cache@v5
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ steps.determine-target.outputs.TARGET }}
- 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 }}
target: ${{ steps.determine-target.outputs.TARGET }}
arch: x86_64
force-avd-creation: false
# `-no-snapshot` must not be provided here
emulator-options: ${{ env.EMULATOR_OPTIONS }}
script: echo "Generated AVD snapshot for caching"
- name: Run instrumentation tests (${{ matrix.api-level }}; ${{ steps.determine-target.outputs.TARGET }})
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ steps.determine-target.outputs.TARGET }}
arch: x86_64
force-avd-creation: false
# `-no-snapshot-save` is important here because we intend to use an existing AVD/snapshot
emulator-options: ${{ env.EMULATOR_OPTIONS }} -no-snapshot-save
# instrumentation == debug, except with minification disabled and jacoco coverage enabled
script: ./gradlew connectedInstrumentationAndroidTest
- name: Upload androidTest results
if: always()
uses: actions/upload-artifact@v6
with:
# API-TARGET for uniqueness across matrix
name: androidTest-results_${{ matrix.api-level }}-${{ steps.determine-target.outputs.TARGET }}
compression-level: 9
path: |
app/build/reports/androidTests/*
app/build/outputs/androidTest-results/*