CI #576
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
pull_request: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
test: | |
name: Instrumented Tests, SDK ${{ matrix.api-level }} | |
runs-on: macos-12 | |
strategy: | |
fail-fast: false | |
matrix: | |
api-level: | |
- 23 # Android 5, minSdkVersion | |
- 27 # Android 8, has caused problems in the past | |
# Fails intermittently, most likely due to system dialog of "App X isn't responding, do you want to close it?" | |
# See here: https://stackoverflow.com/a/54203607/1233767 | |
#- 30 # Android 11 - latest where tests pass | |
#- 33 # Android 13 - targetSdkVersion | |
# Fails currently, need to debug before we can upgrade | |
# - 34 # Android 14, latest public release | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Cache steps all from the example at https://github.com/ReactiveCircus/android-emulator-runner | |
- name: Restore Gradle cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} | |
# You can use sdkmanager --list to locate available packages. | |
# In our case, API=27 with google_apis is only available with x86, but | |
# later APIs (33,34) do not have x86 | |
- name: Set AVD Architecture Based on API Level | |
run: echo "ARCH=$(if [ ${{ matrix.api-level }} -eq 27 ]; then echo 'x86'; else echo 'x86_64'; fi)" >> $GITHUB_ENV | |
- name: Create AVD and generate snapshot for caching | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
arch: ${{ env.ARCH }} | |
cores: 3 | |
force-avd-creation: true | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -grpc 8554 -verbose -timezone America/New_York | |
disable-animations: true | |
target: google_apis | |
ndk: 26.1.10909125 | |
pre-emulator-launch-script: | | |
cat ~/.android/avd/test.avd/config.ini || true | |
cat ~/.android/avd/test.avd/hardware-qemu.ini || true | |
script: echo "Generated AVD snapshot for caching." | |
- name: Set Java 17 | |
run: | | |
echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV | |
- name: Copy iNat config files | |
run: | | |
sed -E 's/<!-- *</</' iNaturalist/src/main/res/values/config.example.xml | sed -E 's/> *-->/>/' > iNaturalist/src/main/res/values/config.xml | |
cp iNaturalist/google-services.example.json iNaturalist/google-services.json | |
# Do this in a distinct step so we get separate timing information | |
- name: Compile | |
run: ./gradlew assembleDebug assembleAndroidTest | |
- name: Run instrumented tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
timeout-minutes: 30 | |
with: | |
api-level: ${{ matrix.api-level }} | |
arch: ${{ env.ARCH }} | |
cores: 3 | |
force-avd-creation: false | |
emulator-options: -no-cache -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -grpc 8554 -verbose -timezone America/New_York | |
disable-animations: true | |
target: google_apis | |
ndk: 26.1.10909125 | |
pre-emulator-launch-script: | | |
cat ~/.android/avd/test.avd/config.ini || true | |
cat ~/.android/avd/test.avd/hardware-qemu.ini || true | |
script: | | |
mkdir screenshots | |
$ANDROID_HOME/platform-tools/adb exec-out screencap -p > screenshots/0-early-boot.png | |
sleep 120 | |
$ANDROID_HOME/platform-tools/adb exec-out screencap -p > screenshots/1-late-boot.png | |
$ANDROID_HOME/platform-tools/adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS | |
sleep 30 | |
$ANDROID_HOME/platform-tools/adb exec-out screencap -p > screenshots/2-pretest.png | |
./gradlew connectedCheck | |
$ANDROID_HOME/platform-tools/adb exec-out screencap -p > screenshots/3-posttest.png | |
- name: Store Build Reports | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: Build Reports - SDK ${{ matrix.api-level }} ${{ env.ARCH }} | |
path: | | |
iNaturalist/build/reports | |
smoothrescale/build/reports | |
library/build/reports | |
urlImageViewHelper/build/reports | |
screenshots | |
- name: Store APK | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: APK - SDK ${{ matrix.api-level }} ${{ env.ARCH }} | |
path: iNaturalist/build/outputs/apk | |
notify: | |
name: Notify Slack | |
needs: test | |
if: ${{ success() || failure() }} | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: iRoachie/[email protected] | |
if: env.SLACK_WEBHOOK_URL != null | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_BUILDS_WEBHOOK_URL }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |