Skip to content

feat: download all resources (models, dataset) on-demand #258

feat: download all resources (models, dataset) on-demand

feat: download all resources (models, dataset) on-demand #258

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 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-tflite:
needs: build-android-apk
runs-on: ubuntu-22.04
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: Trigger Firebase Test Lab for [Google Pixel 6](oriole)
run: |
gcloud firebase test android run \
--type instrumentation \
--app $GCLOUD_BUCKET_PATH/test-main-tflite.apk \
--test $GCLOUD_BUCKET_PATH/test-helper-tflite.apk \
--timeout 30m \
--num-flaky-test-attempts ${{ vars.NUM_FLAKY_TEST_ATTEMPTS }} \
--device model=oriole,version=31,locale=en,orientation=portrait \
--client-details=buildNumber=${{ github.run_number }}
test-android-apk-pixel:
needs: build-android-apk
runs-on: ubuntu-22.04
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: Trigger Firebase Test Lab for [Google Pixel 6](oriole)
run: |
gcloud firebase test android run \
--type instrumentation \
--app $GCLOUD_BUCKET_PATH/test-main-pixel.apk \
--test $GCLOUD_BUCKET_PATH/test-helper-pixel.apk \
--timeout 30m \
--num-flaky-test-attempts ${{ vars.NUM_FLAKY_TEST_ATTEMPTS }} \
--device model=oriole,version=32,locale=en,orientation=portrait \
--client-details=buildNumber=${{ github.run_number }}
test-android-apk-qti:
needs: build-android-apk
runs-on: ubuntu-22.04
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: Trigger Firebase Test Lab for [Samsung Galaxy S22 Ultra](b0q)
run: |
gcloud firebase test android run \
--type instrumentation \
--app $GCLOUD_BUCKET_PATH/test-main-qti.apk \
--test $GCLOUD_BUCKET_PATH/test-helper-qti.apk \
--timeout 30m \
--num-flaky-test-attempts ${{ vars.NUM_FLAKY_TEST_ATTEMPTS }} \
--device model=b0q,version=33,locale=en,orientation=portrait \
--client-details=buildNumber=${{ github.run_number }}
test-android-apk-mtk:
needs: build-android-apk
runs-on: ubuntu-22.04
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: Trigger Firebase Test Lab for [OnePlus DN2103](OP515BL1)
run: |
gcloud firebase test android run \
--type instrumentation \
--app $GCLOUD_BUCKET_PATH/test-main-mtk.apk \
--test $GCLOUD_BUCKET_PATH/test-helper-mtk.apk \
--timeout 30m \
--num-flaky-test-attempts ${{ vars.NUM_FLAKY_TEST_ATTEMPTS }} \
--device model=OP515BL1,version=33,locale=en,orientation=portrait \
--client-details=buildNumber=${{ github.run_number }}
deploy-playstore:
needs:
- build-android-apk
- test-android-apk-tflite
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 }}