-
Notifications
You must be signed in to change notification settings - Fork 26
324 lines (318 loc) · 13.3 KB
/
android-build-test.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
name: Android Build & Test
on:
push:
branches: [ master, submission-v* ]
pull_request:
types: [ opened, synchronize, reopened ]
env:
GCLOUD_BUCKET_PATH: gs://mobile-app-build-290400_github-actions/build/${{ github.run_number }}
jobs:
build-android-image:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/mlcommons/mobile_app_open-android
flavor: latest=true
tags: type=raw,value=${{ github.run_number }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: flutter/android/docker
file: flutter/android/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-android-apk:
needs: build-android-image
runs-on: ubuntu-22.04
container:
image: ghcr.io/mlcommons/mobile_app_open-android:${{ github.run_number }}
timeout-minutes: 120
env:
BAZEL_OUTPUT_ROOT_ARG: "--output_user_root=/tmp/bazel_output"
BAZEL_CACHE_ARG: "--disk_cache=/tmp/bazel_cache"
FLUTTER_BUILD_NUMBER: ${{ github.run_number }}
FIREBASE_ANDROID_API_KEY: ${{ secrets.FIREBASE_ANDROID_API_KEY }}
FIREBASE_ANDROID_APP_ID: ${{ secrets.FIREBASE_ANDROID_APP_ID }}
FIREBASE_PROJECT_ID: mobile-app-build-290400
FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}
FIREBASE_DATABASE_URL: ${{ secrets.FIREBASE_DATABASE_URL }}
FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
SIGNING_FOR_RELEASE: true
SIGNING_STORE_FILE: /tmp/mlperf-keystore.jks
SIGNING_STORE_FILE_BASE64: ${{ secrets.SIGNING_STORE_FILE_BASE64 }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
SIGNING_KEY_ALIAS: upload
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
steps:
- uses: actions/checkout@v4
# Preinstalled tools from host at `/opt/hostedtoolcache` is not needed since we run commands inside our own Docker container.
# `/opt/hostedtoolcache` is mounted to `/__t`. We delete it to free up disk space.
- name: Free up disk space
run: |
echo BEFORE:
df -h
rm -rf /__t/*
echo AFTER:
df -h
- name: Configure Git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Create keystore file
run: |
echo "$SIGNING_STORE_FILE_BASE64" | base64 -d > "$SIGNING_STORE_FILE"
echo e4699f58310b85cbcb9e835e569e7e17 "$SIGNING_STORE_FILE" | md5sum --check -
- name: Set up authentication for Google Cloud SDK
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_ACCOUNT_MOBILE_APP_BUILD }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: '>= 363.0.0'
project_id: mobile-app-build-290400
- name: Download Samsung libraries
env:
SAMSUNG_LIB: samsung_libs_v4.0_20240409
run: |
gsutil cp gs://mobile-app-build-290400_github-actions/lib/v4.0/${SAMSUNG_LIB}.zip /tmp/ && \
unzip /tmp/${SAMSUNG_LIB}.zip -d /tmp/${SAMSUNG_LIB} && \
rm /tmp/${SAMSUNG_LIB}.zip && \
mkdir -p mobile_back_samsung/samsung/lib/internal && \
mv /tmp/${SAMSUNG_LIB}/* mobile_back_samsung/samsung/lib/internal/
- name: Download QTI libraries
env:
QTI_LIB: qaisw-2.20.0.240223_linux
run: |
gsutil cp gs://mobile-app-build-290400_github-actions/lib/v4.0/${QTI_LIB}.zip /tmp/ && \
unzip /tmp/${QTI_LIB}.zip -d /tmp/${QTI_LIB} && \
rm /tmp/${QTI_LIB}.zip && \
mkdir -p mobile_back_qti/${QTI_LIB} && \
mv /tmp/${QTI_LIB}/* mobile_back_qti/${QTI_LIB}/
- name: Cache bazel
uses: actions/cache@v4
with:
path: /tmp/bazel_cache
key: ${{ runner.os }}-bazel_cache-${{ hashFiles('**/BUILD', '**/WORKSPACE') }}
restore-keys: ${{ runner.os }}-bazel_cache-
- name: Run Flutter unit tests
run: |
make flutter/prepare && make flutter/test/unit
- name: Build and upload test APK for TFLite
env:
OFFICIAL_BUILD: false
PERF_TEST: true
WITH_TFLITE: 1
run: |
make flutter/android/release flutter/android/apk flutter/android/test-apk
gsutil mv output/android-apks/test-main.apk $GCLOUD_BUCKET_PATH/test-main-tflite.apk
gsutil mv output/android-apks/test-helper.apk $GCLOUD_BUCKET_PATH/test-helper-tflite.apk
- name: Build and upload test APK for Pixel
env:
OFFICIAL_BUILD: false
PERF_TEST: true
WITH_TFLITE: 0
WITH_PIXEL: 1
run: |
make flutter/android/release flutter/android/apk flutter/android/test-apk
gsutil mv output/android-apks/test-main.apk $GCLOUD_BUCKET_PATH/test-main-pixel.apk
gsutil mv output/android-apks/test-helper.apk $GCLOUD_BUCKET_PATH/test-helper-pixel.apk
- name: Build and upload test APK for QTI
env:
OFFICIAL_BUILD: false
PERF_TEST: true
WITH_TFLITE: 0
WITH_QTI: 1
run: |
make flutter/android/release flutter/android/apk flutter/android/test-apk
gsutil mv output/android-apks/test-main.apk $GCLOUD_BUCKET_PATH/test-main-qti.apk
gsutil mv output/android-apks/test-helper.apk $GCLOUD_BUCKET_PATH/test-helper-qti.apk
- name: Build and upload test APK for MediaTek
env:
OFFICIAL_BUILD: false
PERF_TEST: true
WITH_TFLITE: 0
WITH_MEDIATEK: 1
run: |
make flutter/android/release flutter/android/apk flutter/android/test-apk
gsutil mv output/android-apks/test-main.apk $GCLOUD_BUCKET_PATH/test-main-mtk.apk
gsutil mv output/android-apks/test-helper.apk $GCLOUD_BUCKET_PATH/test-helper-mtk.apk
- name: Build and upload test APK for Samsung
env:
OFFICIAL_BUILD: false
PERF_TEST: true
WITH_TFLITE: 0
WITH_SAMSUNG: 1
run: |
make flutter/android/release flutter/android/apk flutter/android/test-apk
gsutil mv output/android-apks/test-main.apk $GCLOUD_BUCKET_PATH/test-main-samsung.apk
gsutil mv output/android-apks/test-helper.apk $GCLOUD_BUCKET_PATH/test-helper-samsung.apk
- name: Build and upload test APK for all backends
env:
OFFICIAL_BUILD: false
PERF_TEST: true
WITH_TFLITE: 1
WITH_PIXEL: 1
WITH_MEDIATEK: 1
WITH_QTI: 1
WITH_SAMSUNG: 1
WITH_APPLE: 0
run: |
make flutter/android/release flutter/android/apk flutter/android/test-apk
gsutil mv output/android-apks/test-main.apk $GCLOUD_BUCKET_PATH/test-main-unified.apk
gsutil mv output/android-apks/test-helper.apk $GCLOUD_BUCKET_PATH/test-helper-unified.apk
- name: Build Android release APK with all backends
env:
OFFICIAL_BUILD: true
FIREBASE_CRASHLYTICS_ENABLED: true
WITH_TFLITE: 1
WITH_PIXEL: 1
WITH_MEDIATEK: 1
WITH_QTI: 1
WITH_SAMSUNG: 1
WITH_APPLE: 0
run: |
make flutter/android/release
gsutil cp flutter/build/app/outputs/bundle/release/app-release.aab $GCLOUD_BUCKET_PATH/app-release.aab
gsutil cp flutter/build/app/outputs/flutter-apk/app-release.apk $GCLOUD_BUCKET_PATH/app-release.apk
- name: Archive APK with TFLite backend
uses: actions/upload-artifact@v4
with:
name: android-apk-tflite-${{ github.run_number }}
path: output/android-apks/*-t-${{ github.run_number }}.apk
retention-days: 28
if-no-files-found: error
- name: Archive APK with Pixel backend
uses: actions/upload-artifact@v4
with:
name: android-apk-pixel-${{ github.run_number }}
path: output/android-apks/*-g-${{ github.run_number }}.apk
retention-days: 28
if-no-files-found: error
- name: Archive APK with QTI backend
uses: actions/upload-artifact@v4
with:
name: android-apk-qti-${{ github.run_number }}
path: output/android-apks/*-q-${{ github.run_number }}.apk
retention-days: 28
if-no-files-found: error
- name: Archive APK with MediaTek backend
uses: actions/upload-artifact@v4
with:
name: android-apk-mtk-${{ github.run_number }}
path: output/android-apks/*-m-${{ github.run_number }}.apk
retention-days: 28
if-no-files-found: error
- name: Archive APK with Samsung backend
uses: actions/upload-artifact@v4
with:
name: android-apk-samsung-${{ github.run_number }}
path: output/android-apks/*-s-${{ github.run_number }}.apk
retention-days: 28
if-no-files-found: error
- name: Archive APK with unified backend
uses: actions/upload-artifact@v4
with:
name: android-apk-unified-${{ github.run_number }}
path: output/android-apks/*-qsmgt-${{ github.run_number }}.apk
retention-days: 28
if-no-files-found: error
- name: Archive AAB with unified backend
uses: actions/upload-artifact@v4
with:
name: android-aab-unified-${{ github.run_number }}
path: output/android-apks/*-qsmgt-${{ github.run_number }}.aab
retention-days: 28
if-no-files-found: error
test-android-apk-unified:
needs: build-android-apk
runs-on: ubuntu-22.04
timeout-minutes: 60
env:
MAIN_APK_NAME: test-main-unified-${{ github.run_number }}.apk
HELPER_APK_NAME: test-helper-unified-${{ github.run_number }}.apk
steps:
- uses: actions/checkout@v4
- name: Set up authentication for Google Cloud SDK
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_ACCOUNT_MOBILE_APP_BUILD }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: '>= 363.0.0'
- name: Download test APK
run: |
gsutil cp $GCLOUD_BUCKET_PATH/test-main-unified.apk /tmp/$MAIN_APK_NAME
gsutil cp $GCLOUD_BUCKET_PATH/test-helper-unified.apk /tmp/$HELPER_APK_NAME
- name: Upload main app
run: |
curl -u "${{ secrets.BROWSERSTACK_CREDENTIALS }}" \
-X POST "https://api-cloud.browserstack.com/app-automate/flutter-integration-tests/v2/android/app" \
-F "file=@/tmp/$MAIN_APK_NAME" \
-F "custom_id=$MAIN_APK_NAME"
- name: Upload test suite
run: |
curl -u "${{ secrets.BROWSERSTACK_CREDENTIALS }}" \
-X POST "https://api-cloud.browserstack.com/app-automate/flutter-integration-tests/v2/android/test-suite" \
-F "file=@/tmp/$HELPER_APK_NAME" \
-F "custom_id=$HELPER_APK_NAME"
- name: Trigger App Automate
env:
BROWSERSTACK_CREDENTIALS: ${{ secrets.BROWSERSTACK_CREDENTIALS }}
BROWSERSTACK_APP: ${{ env.MAIN_APK_NAME }}
BROWSERSTACK_TEST_SUITE: ${{ env.HELPER_APK_NAME }}
BROWSERSTACK_BUILD_TAG: ${{ github.run_number }}
BROWSERSTACK_DEVICES: >-
["Samsung Galaxy M32-11.0",
"Samsung Galaxy S24-14.0",
"Samsung Galaxy S24 Ultra-14.0",
"Samsung Galaxy Tab S10 Plus-14.0",
"Google Pixel 9 Pro-15.0"]
run: |
bash .github/workflows/scripts/browserstack-app-automate.sh
deploy-playstore:
needs:
- build-android-apk
- test-android-apk-unified
runs-on: ubuntu-22.04
# if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- name: Set up authentication for Google Cloud SDK
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_ACCOUNT_MOBILE_APP_BUILD }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: '>= 363.0.0'
project_id: mobile-app-build-290400
- name: Download Android release app
run: |
gsutil cp $GCLOUD_BUCKET_PATH/app-release.aab /tmp/app-release.aab
- name: Upload Android release app to Google Play
uses: r0adkll/upload-google-play@v1
with:
releaseFiles: /tmp/app-release.aab
packageName: org.mlcommons.android.mlperfbench
serviceAccountJsonPlainText: ${{ secrets.GCLOUD_SERVICE_ACCOUNT_MOBILE_APP_BUILD }}
track: internal # "alpha", "beta", "internal" or "production"
status: draft
changesNotSentForReview: ${{ vars.CHANGES_NOT_SENT_FOR_REVIEW }}