Skip to content

Commit

Permalink
164 - Target Android 11 and other build changes (#194)
Browse files Browse the repository at this point in the history
Target SDK ~29~ → 30 (Android 11) and minor improvements

* Upgrade targeted SDK
* Skip upload of APKs for `webview-armeabi-v7a` arch not used
* Allow `abi` argument to be overwritten in ui tests.
* `make assemble-all` only assemble release versions
* Only build when pushing to master or pull requests
* Don't build the repo if only `**.md` files are pushed
* Disable for now demo app publishing (demo.dev.medicmobile.org is unmaintained)
* Disabling instrumentation test momentarily
  • Loading branch information
mrsarm authored Jul 19, 2021
1 parent ce90c39 commit 762259d
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 44 deletions.
92 changes: 73 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
name: Build and test

on: [push, pull_request]
on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

jobs:

build:

name: Build
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2

- name: Checkout
uses: actions/checkout@v2

- name: Test
run: make test

- name: Set up ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Set up fastlane
run: gem install fastlane --no-document --quiet

- name: Unpack secrets
env:
ANDROID_SECRETS_KEY: ${{ secrets.ANDROID_SECRETS_KEY }}
ANDROID_SECRETS_IV: ${{ secrets.ANDROID_SECRETS_IV }}
run: |
openssl aes-256-cbc -K $ANDROID_SECRETS_KEY -iv $ANDROID_SECRETS_IV -in secrets.tar.gz.enc -out ./secrets.tar.gz -d
tar -xf ./secrets.tar.gz
- name: Assemble unbranded
uses: maierj/[email protected]
env:
Expand All @@ -34,20 +51,57 @@ jobs:
lane: build
options: '{ "flavor": "unbranded" }'

instrumentation-tests:
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: test unbranded
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86
script: make test-ui
- name: run tests on gamma
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86
script: make test-ui-gamma
# instrumentation-tests:
#
# name: Instrumentation tests
# runs-on: macos-latest
# steps:
#
# - name: Checkout
# uses: actions/checkout@v2
#
# - name: Gradle cache
# uses: actions/cache@v2
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper
# key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
#
# - name: AVD cache
# uses: actions/cache@v2
# 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:
# api-level: 29
# target: google_apis
# 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 test-ui on unbranded
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 29
# target: google_apis
# force-avd-creation: false
# emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# script: make test-ui
#
# - name: Run test-ui on gamma
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 29
# target: google_apis
# force-avd-creation: false
# emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# script: make test-ui-gamma
23 changes: 15 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
name: Build
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up ruby
Expand All @@ -41,11 +42,12 @@ jobs:
with:
lane: build
options: '{ "flavor": "medicmobilegamma" }'
- name: Assemble demo
uses: maierj/[email protected]
with:
lane: build
options: '{ "flavor": "medicmobiledemo" }'
# demo app is disabled for now
#- name: Assemble demo
# uses: maierj/[email protected]
# with:
# lane: build
# options: '{ "flavor": "medicmobiledemo" }'
- name: Assemble bracuganda
uses: maierj/[email protected]
with:
Expand Down Expand Up @@ -191,16 +193,21 @@ jobs:
with:
lane: build
options: '{ "flavor": "itech_aurum" }'
- name: Assemble itech_aurum
- name: Assemble itech_malawi
uses: maierj/[email protected]
with:
lane: build
options: '{ "flavor": "itech_malawi" }'

- name: GitHub release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: build/outputs/apk/**/*.apk
# APKs for webview-armeabi-v7a are not uploaded
files: |
build/outputs/apk/**/*-xwalk-arm64-v8a-release.apk
build/outputs/apk/**/*-xwalk-armeabi-v7a-release.apk
build/outputs/apk/**/*-webview-arm64-v8a-release.apk
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ADB = ${ANDROID_HOME}/platform-tools/adb
GRADLE = ./gradlew
GRADLE_OPTS = --daemon --parallel
flavor = UnbrandedWebview
abi = x86

ifdef ComSpec # Windows
# Use `/` for all paths, except `.\`
Expand Down Expand Up @@ -33,7 +34,7 @@ clean-apks:
assemble:
${GRADLE} ${GRADLE_OPTS} assemble${flavor}
assemble-all:
${GRADLE} ${GRADLE_OPTS} assemble
${GRADLE} ${GRADLE_OPTS} assembleRelease
assemble-all-debug:
${GRADLE} ${GRADLE_OPTS} assembleDebug

Expand All @@ -51,6 +52,6 @@ lint:
test: lint
${GRADLE} ${GRADLE_OPTS} test
test-ui:
${GRADLE} connectedUnbrandedWebviewDebugAndroidTest -Pabi=x86 --stacktrace
${GRADLE} connectedUnbrandedWebviewDebugAndroidTest -Pabi=${abi} --stacktrace
test-ui-gamma:
${GRADLE} connectedMedicmobilegammaWebviewDebugAndroidTest -Pabi=x86 --stacktrace
${GRADLE} connectedMedicmobilegammaWebviewDebugAndroidTest -Pabi=${abi} --stacktrace
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Earlier releases are no longer accepted by the Google Play Store.

### Changes

- [improvement] [cht-android#106](https://github.com/medic/cht-android/issues/106): Update target SDK version to 29 for Play Store compliance
- [improvement] [cht-android#106](https://github.com/medic/cht-android/issues/106): Update target SDK version to 29 for Play Store compliance.

## 0.5.0

Expand Down Expand Up @@ -118,7 +118,7 @@ See the [Makefile](./Makefile) for more details.

The command above builds and assembles the _debug_ and _release_ APKs of the Unbranded Webview version of the app.

Each APK will be generated and stored in `build/outputs/apk/[flavor][Engine]/[debug|release]/`, for example after assembling the _Medicmobiledemo Webview_ flavor with `make flavor=MedicmobiledemoWebview assemble`, the _release_ versions of the APKs generated are stored in `build/outputs/apk/medicmobiledemoWebview/release/`.
Each APK will be generated and stored in `build/outputs/apk/[flavor][Engine]/[debug|release]/`, for example after assembling the _Simprints Webview_ flavor with `make flavor=SimprintsWebview assemble`, the _release_ versions of the APKs generated are stored in `build/outputs/apk/simprintsWebview/release/`.

To assemble other flavors, use the following command: `make flavour=[Flavor][Engine] assemble`. See the [Flavor selection](#flavor-selection) section for more details about `make` commands.

Expand Down Expand Up @@ -162,32 +162,32 @@ To build and deploy APKs for all configured brands:

To add a new brand:

1. add `productFlavors { <new_brand> { ... } }` in `build.gradle`
2. add icons, strings etc. in `src/<new_brand>`
3. to enable automated deployments, add the `new_brand` to `.github/workflows/publish.yml`
1. add `productFlavors { <new_brand> { ... } }` in `build.gradle`.
2. add icons, strings etc. in `src/<new_brand>`.
3. to enable automated deployments, add the `new_brand` to `.github/workflows/publish.yml`.


# Releasing

## Alpha for release testing

1. Make sure all issues for this release have passed AT and been merged into `master`
1. Make sure all issues for this release have passed AT and been merged into `master`.
2. Create a git tag starting with `v` and ending with the alpha version, e.g. `v1.2.3-alpha.1` and push the tag to GitHub.
3. Creating this tag will trigger [GitHub Action](https://github.com/medic/cht-android/actions) to build, sign, and properly version the build. The release-ready APKs are available for side-loading from [GitHub Releases](https://github.com/medic/cht-android/releases).
4. Announce the release in #quality-assurance
4. Announce the release in #quality-assurance.

## Final for users

1. Create a git tag starting with `v`, e.g. `v1.2.3` and push the tag to GitHub.
2. The exact same process as Step 3 above.
3. Publish the unbranded, demo, simprints, and gamma flavors to the Play Store.
3. Publish the unbranded, simprints, and gamma flavors to the Play Store.
4. Announce the release on the [CHT forum](https://forum.communityhealthtoolkit.org), under the "Product - Releases" category.
5. Each flavor is then individually released to users via "Release Management" in the Google Play Console. Once a flavor has been tested and is ready to go live, click Release to Production
5. Each flavor is then individually released to users via "Release Management" in the Google Play Console. Once a flavor has been tested and is ready to go live, click Release to Production.


# Copyright

Copyright 2013-2021 Medic Mobile, Inc. <[email protected]>
Copyright 2013-2021 Medic Mobile, Inc. <[email protected]>.


# License
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def getVersionName = {
}

android {
compileSdkVersion 29
compileSdkVersion 30
buildToolsVersion '30.0.3'
packagingOptions {
exclude 'META-INF/LICENSE'
Expand All @@ -70,7 +70,7 @@ android {
defaultConfig {
versionName getVersionName()
archivesBaseName = "${project.name}-${versionName}"
targetSdkVersion 29
targetSdkVersion 30
// When upgrading targetSdkVersion, check that the app menu still works on newer devices.
//for espresso tests
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testLoginScreen() throws Exception {
0)))
.atPosition(2);
linearLayout.perform(click());
Thread.sleep(12000);//TODO: use better ways to handle delays
Thread.sleep(7000);//TODO: use better ways to handle delays

ViewInteraction webView = onView(
allOf(withId(R.id.wbvMain),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void testLoginScreen() throws Exception {
0)))
.atPosition(2);
linearLayout.perform(click());
Thread.sleep(12000); //TODO: use better ways to handle delays
Thread.sleep(7000); //TODO: use better ways to handle delays

ViewInteraction webView = onView(
allOf(withId(R.id.wbvMain),
Expand Down

0 comments on commit 762259d

Please sign in to comment.