-
-
Notifications
You must be signed in to change notification settings - Fork 92
258 lines (245 loc) · 10.3 KB
/
android-build.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: build # used as the badge name
on:
push:
branches: ['*']
tags: ['*']
pull_request:
types: [opened, synchronize]
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEYSTORE_ALIAS: upload
KEYSTORE_ALIAS_PASSWORD: ${{ secrets.KEYSTORE_ALIAS_PASSWORD }}
AndroidAutoIdrive_SpotifyApiKey: ${{ secrets.ANDROIDAUTOIDRIVE_SPOTIFYAPIKEY }}
AndroidAutoIdrive_SentryDsn: ${{ secrets.ANDROIDAUTOIDRIVE_SENTRYDSN }}
AndroidAutoIdrive_GmapsApiKey: ${{ secrets.ANDROIDAUTOIDRIVE_GMAPSAPIKEY }}
AndroidAutoIdrive_MapboxAccessToken: ${{ secrets.ANDROIDAUTOIDRIVE_MAPBOXACCESSTOKEN }}
AndroidAutoIdrive_MapboxDownloadToken: ${{ secrets.ANDROIDAUTOIDRIVE_MAPBOXDOWNLOADTOKEN }}
jobs:
unitTest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
map: [Nomap, Gmap, Mapbox]
analytics: [Nonalytics, Sentry]
hasSecret:
- ${{ github.repository == 'BimmerGestalt/AAIdrive' && github.event_name == 'push' }}
exclude: # don't run Mapbox tests if we are in a context that doesn't have the Mapbox secret
- hasSecret: false
map: Mapbox # Mapbox requires secrets to build
steps:
- name: Checkout the project
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Prepare cached external dependencies
uses: actions/cache@v4
with:
key: aaidrive_external_${{ hashFiles('.github/actions/download-externals-action/download.sh') }}
path: |
external
- name: Download build dependencies
uses: ./.github/actions/download-externals-action
# disabled for being flaky
#- name: Validate Gradle Wrapper
# uses: gradle/wrapper-validation-action@v1
- name: Build the project
run: ./gradlew compile${{ matrix.map }}${{ matrix.analytics }}FullDebugKotlin --stacktrace
- name: Run unit tests
run: ./gradlew test${{ matrix.map }}${{ matrix.analytics }}FullDebugUnitTestCoverage
- name: Upload CodeCov report
if: github.event.pull_request.title != 'New Crowdin updates' && github.event.ref != 'refs/heads/l10n_main' # don't upload coverage for Crowdin pushes
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
with:
files: app/build/reports/jacoco/jacoco.xml
flags: unittests
instrumentedTest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
map: [Nomap, Gmap, Mapbox]
hasSecret:
- ${{ github.repository == 'BimmerGestalt/AAIdrive' && github.event_name == 'push' }}
exclude: # don't run Gmap tests if we are in a context that doesn't have the gmap secret
- hasSecret: false
map: Gmap
- hasSecret: false
map: Mapbox # Mapbox requires secrets to build
steps:
- 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: Checkout the project
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Prepare cached external dependencies
uses: actions/cache@v4
with:
key: aaidrive_external_${{ hashFiles('.github/actions/download-externals-action/download.sh') }}
path: |
external
- name: Download build dependencies
uses: ./.github/actions/download-externals-action
- name: Build the project
run: ./gradlew compile${{ matrix.map }}NonalyticsFullDebugKotlin --stacktrace
- name: Prepare emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 28
emulator-build: 7425822
target: google_apis
script: adb install external/BMW_Connected_v3.1.1.3078_apkpure.com.apk
- name: Run instrumented tests
uses: reactivecircus/android-emulator-runner@v2
with:
force-avd-creation: false
api-level: 28
emulator-build: 7425822
target: google_apis
script: >-
adb logcat -c && timeout 30m ./gradlew connected${{ matrix.map }}NonalyticsFullDebugAndroidTestCoverage --stacktrace ||
(adb logcat -d && exit 1)
- name: Upload CodeCov report
if: matrix.map == 'Nomap' && github.event.pull_request.title != 'New Crowdin updates' && github.event.ref != 'refs/heads/l10n_main' # don't upload Gmap test results, which don't run during PRs
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
with:
files: app/build/reports/jacoco/jacoco.xml
# flags: instrumentedtests
# android connectedTests don't leave the app or files installed after the test
# so we have to invoke it manually
- name: Generate screenshots
uses: reactivecircus/android-emulator-runner@v2
with:
force-avd-creation: false
api-level: 28
emulator-build: 7425822
target: google_apis
script: >-
adb logcat -c && ./gradlew install${{ matrix.map }}NonalyticsFullDebug --stacktrace &&
./gradlew install${{ matrix.map }}NonalyticsFullDebugAndroidTest --stacktrace &&
( timeout 30m adb shell am instrument -w -e class me.hufman.androidautoidrive.MainScreenshotTest,me.hufman.androidautoidrive.WelcomeScreenshotTest me.hufman.androidautoidrive.test/me.hufman.androidautoidrive.DexOpenerAndroidJUnitRunner ||
timeout 30m adb shell am instrument -w -e class me.hufman.androidautoidrive.MainScreenshotTest,me.hufman.androidautoidrive.WelcomeScreenshotTest me.hufman.androidautoidrive.test/me.hufman.androidautoidrive.DexOpenerAndroidJUnitRunner ) &&
./gradlew fetchScreenshots --stacktrace || adb logcat -d
- name: Package screenshots
uses: actions/upload-artifact@v3
if: matrix.map == 'Nomap'
with:
retention-days: 7
name: screenshots
path: |
app/build/reports/androidTests/connected/screenshots/*
package:
# Only build on the main repo, which has the secrets configured
if: github.repository == 'BimmerGestalt/AAIdrive' && github.event_name == 'push'
needs: [unitTest] # wait for the tests to succeed
runs-on: ubuntu-latest
steps:
- name: Checkout the project
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Prepare cached external dependencies
uses: actions/cache@v4
with:
key: aaidrive_external_${{ hashFiles('.github/actions/download-externals-action/download.sh') }}
path: |
external
- name: Download build dependencies
uses: ./.github/actions/download-externals-action
- name: Extract signing key
run: "echo ${{ secrets.KEYSTORE_BASE64 }} | base64 -d > keystore.jks"
- name: Build nomap artifacts
run: ./gradlew assembleNomap --stacktrace
- name: Build mapbox artifacts
run: ./gradlew assembleMapbox --stacktrace
- name: Calculate APK hashes
run: "find app/build/outputs/apk -name '*.apk' -execdir sha1sum {} \\;"
- name: Confirm APK hashes
run: "find app/build/outputs/apk -name '*.sha1' -exec cat {} \\; -execdir sha1sum -c {} \\;"
- name: Upload APKs
uses: actions/upload-artifact@v3
with:
retention-days: 7
name: apk
path: |
app/build/outputs/apk/nomapNonalyticsFull/release/*apk
app/build/outputs/apk/nomapNonalyticsFull/release/*apk.sha1
app/build/outputs/apk/nomapSentryFull/release/*apk
app/build/outputs/apk/nomapSentryFull/release/*apk.sha1
app/build/outputs/apk/mapboxNonalyticsFull/release/*apk
app/build/outputs/apk/mapboxNonalyticsFull/release/*apk.sha1
app/build/outputs/apk/mapboxSentryFull/release/*apk
app/build/outputs/apk/mapboxSentryFull/release/*apk.sha1
upload_s3:
if: github.event_name == 'push'
needs: package
runs-on: ubuntu-latest
steps:
- name: Download project artifacts
uses: actions/download-artifact@v3
with:
name: apk
- name: Determine branch name
run: echo "BRANCH_NAME=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV
- name: Stage upload directory
run: |
mkdir dist
cp nomapNonalyticsFull/release/*apk dist/androidautoidrive-latest-${BRANCH_NAME}-nomap-nonalytics-release.apk
cp nomapSentryFull/release/*apk dist/androidautoidrive-latest-${BRANCH_NAME}-nomap-sentry-release.apk
cp mapboxNonalyticsFull/release/*apk dist/androidautoidrive-latest-${BRANCH_NAME}-mapbox-nonalytics-release.apk
cp mapboxSentryFull/release/*apk dist/androidautoidrive-latest-${BRANCH_NAME}-mapbox-sentry-release.apk
- name: Upload to S3
uses: shallwefootball/s3-upload-action@v1.3.0
with:
source_dir: dist
destination_dir: aaidrive/builds
aws_bucket: bimmergestalt
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
upload_release:
if: startsWith(github.ref, 'refs/tags/')
needs: package
runs-on: ubuntu-latest
steps:
- name: Download project artifacts
uses: actions/download-artifact@v2
with:
name: apk
- name: Stage upload directory
run: |
mkdir dist
cp */release/*apk* dist/
- name: Upload to Github release
uses: svenstaro/upload-release-action@v2
with:
tag: ${{ github.ref }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: dist/*
overwrite: true