Skip to content

Release APK Minification and Shrinking #10671

Release APK Minification and Shrinking

Release APK Minification and Shrinking #10671

Workflow file for this run

# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: CI
on:
workflow_dispatch:
pull_request:
branches: [ main ]
merge_group:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FHIRCORE_USERNAME: ${{ secrets.FHIRCORE_USERNAME }}
FHIRCORE_ACCESS_TOKEN: ${{ secrets.FHIRCORE_ACCESS_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
MAPBOX_SDK_TOKEN: ${{ secrets.MAPBOX_SDK_TOKEN }}
jobs:
engine-tests:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [34]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
distribution: temurin
java-version: 17
- name: Enable KVM
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: Add empty local.properties
run: touch local.properties
working-directory: android
- name: Add empty keystore.properties
run: touch keystore.properties
working-directory: android
- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: android
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties && cat ~/.gradle/gradle.properties
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Spotless check engine module
run: ./gradlew -PlocalPropertiesFile=local.properties :engine:spotlessCheck :engine:ktlintCheck --stacktrace
working-directory: android
- name: Load AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run Engine module unit and instrumentation tests and generate coverage report
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew -PlocalPropertiesFile=local.properties :engine:clean :engine:fhircoreJacocoReport --stacktrace
- name: Upload Test reports
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: engine-test-reports
path: android/engine/build/reports
- name: Upload Engine module test coverage report to Codecov
if: matrix.api-level == 34 # Only upload coverage on API level 34
working-directory: android
run: bash <(curl -s https://codecov.io/bash) -F engine -f "engine/build/reports/jacoco/fhircoreJacocoReport/fhircoreJacocoReport.xml"
geowidget-tests:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [34]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
distribution: temurin
java-version: 17
- name: Enable KVM
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: Add empty local.properties
run: touch local.properties
working-directory: android
- name: Add empty keystore.properties
run: touch keystore.properties
working-directory: android
- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: android
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties && cat ~/.gradle/gradle.properties
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Spotless check geowidget module
run: ./gradlew -PlocalPropertiesFile=local.properties :geowidget:spotlessCheck --stacktrace
working-directory: android
- name: Load AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run Geowidget module unit and instrumentation tests and generate coverage report
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew -PlocalPropertiesFile=local.properties :geowidget:clean :geowidget:fhircoreJacocoReport --stacktrace
- name: Upload Test reports
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: geowidget-test-reports
path: android/geowidget/build/reports
- name: Upload Geowidget module test coverage report to Codecov
if: matrix.api-level == 34 # Only upload coverage on API level 34
working-directory: android
run: bash <(curl -s https://codecov.io/bash) -F geowidget -f "geowidget/build/reports/jacoco/fhircoreJacocoReport/fhircoreJacocoReport.xml"
quest-tests:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [34]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
distribution: temurin
java-version: 17
- name: Enable KVM
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: Add empty local.properties
run: touch local.properties
working-directory: android
- name: Add empty keystore.properties
run: touch keystore.properties
working-directory: android
- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: android
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties && cat ~/.gradle/gradle.properties
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Spotless check quest application
run: ./gradlew -PlocalPropertiesFile=local.properties :quest:spotlessCheck --stacktrace :quest:ktlintCheck --stacktrace
working-directory: android
- name: Load AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run Quest module unit and instrumentation tests and generate unit tests coverage report
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew clean -PlocalPropertiesFile=local.properties :quest:fhircoreJacocoReport --info -Pandroid.testInstrumentationRunnerArguments.notPackage=org.smartregister.fhircore.quest.performance
- name: Run Quest module unit and instrumentation tests and generate aggregated coverage report (Disabled)
if: false
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
run: |
set -e
./gradlew -PlocalPropertiesFile=local.properties :quest:clean
./gradlew -PlocalPropertiesFile=local.properties :quest:assembleOpensrpDebugAndroidTest --stacktrace
/Users/martin/Library/Android/sdk/platform-tools/adb install quest/build/outputs/apk/androidTest/opensrp/debug/quest-opensrp-debug-androidTest.apk
./gradlew -PlocalPropertiesFile=local.properties :quest:assembleOpensrpDebug --stacktrace
/Users/martin/Library/Android/sdk/platform-tools/adb install quest/build/outputs/apk/opensrp/debug/quest-opensrp-debug.apk
/Users/martin/Library/Android/sdk/platform-tools/adb shell am instrument -w \
--no-window-animation \
-e coverage "true" \
-e debug false \
org.smartregister.opensrp.test/org.smartregister.fhircore.quest.QuestTestRunner
/Users/martin/Library/Android/sdk/platform-tools/adb shell run-as org.smartregister.opensrp \
cat "/data/user/0/org.smartregister.opensrp/files/coverage.ec" > quest/coverage.ec
./gradlew -PlocalPropertiesFile=local.properties :quest:fhircoreJacocoReport --stacktrace
- name: Upload Test reports
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: quest-test-reports
path: android/quest/build/reports
- name: Upload Quest module test coverage report to Codecov
if: matrix.api-level == 34 # Only upload coverage on API level 34
working-directory: android
run: bash <(curl -s https://codecov.io/bash) -F quest -f "quest/build/reports/jacoco/fhircoreJacocoReport/fhircoreJacocoReport.xml"