Skip to content

Commit

Permalink
Merge pull request #1323 from hamiltont/chore/update-toolchain
Browse files Browse the repository at this point in the history
Update Toolchain & CI/CD
  • Loading branch information
budowski authored Jan 19, 2024
2 parents cae852a + c18b705 commit fa7727d
Show file tree
Hide file tree
Showing 31 changed files with 414 additions and 236 deletions.
85 changes: 68 additions & 17 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,69 +8,120 @@ on:
jobs:
test:
name: Instrumented Tests, SDK ${{ matrix.api-level }}
runs-on: macos-11
runs-on: macos-12
strategy:
fail-fast: false
matrix:
api-level:
- 23 # Android 5, minSdkVersion
- 27 # Android 8, has caused problems in the past
# SDK 29 causes frequent problems with the emulator, not sure why.
# Hoping SDK 30 is close enough
# - 29 # Android 10, targetSdkVersion
- 30 # Android 11, latest public release
- 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@v3
uses: actions/checkout@v4

# Cache steps all from the example at https://github.com/ReactiveCircus/android-emulator-runner
- name: Gradle cache
- 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') }}

- name: AVD cache
# 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: Restore AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-20220105-1
key: avd-${{ matrix.api-level }}-${{ env.ARCH }}-20231227

- 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 }}
arch: ${{ env.ARCH }}
cores: 3
force-avd-creation: true
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
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: 22.1.7171670
# I think this might be a quick fix for intermittent build failures waiting for the emaultor to boot
emulator-build: 7425822
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 11
run: |
echo "JAVA_HOME=$JAVA_HOME_11_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-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-options: -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: 22.1.7171670
script: ./gradlew connectedCheck -x :smoothrescale:connectedDebugAndroidTest
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
Expand Down
14 changes: 10 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
}


}

allprojects {
Expand All @@ -24,3 +22,11 @@ allprojects {
resolutionStrategy.force 'com.android.support:support-annotations:25.0.1'
}
}

// Global properties used in all build.gradle files
ext {
minSdkVersion = 23
targetSdkVersion = 33
compileSdkVersion = 33
}

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Thu Dec 31 15:04:40 EST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
Loading

0 comments on commit fa7727d

Please sign in to comment.