-
Notifications
You must be signed in to change notification settings - Fork 57
135 lines (123 loc) · 5.21 KB
/
CI.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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
- 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: Restore AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
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 -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 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 -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-22.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 }}