From b7be459537d560f764f1f99b6cfe210613d543ab Mon Sep 17 00:00:00 2001 From: Alinson Xavier Date: Wed, 1 Jan 2020 18:34:28 -0600 Subject: [PATCH] Create main GitHub Actions workflow --- .github/workflows/main.yml | 25 ++++++++++++++++++++++++ android/build.sh | 39 +++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..5c9ca62c9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,25 @@ +name: Build & Test + +on: [push] + +jobs: + build: + runs-on: macOS-latest + steps: + - uses: actions/checkout@v1 + - name: Install Java Development Kit 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build APK & Run small tests + run: android/build.sh build + - name: Run medium tests + uses: ReactiveCircus/android-emulator-runner@v2.2.0 + with: + api-level: 29 + script: android/build.sh medium-tests + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: Build + path: android/uhabits-android/build/outputs/ diff --git a/android/build.sh b/android/build.sh index 782360fa0..ca01806f5 100755 --- a/android/build.sh +++ b/android/build.sh @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License along # with this program. If not, see . +cd "$(dirname "$0")" + ADB="${ANDROID_HOME}/platform-tools/adb" EMULATOR="${ANDROID_HOME}/tools/emulator" GRADLE="./gradlew --stacktrace" @@ -155,10 +157,17 @@ run_instrumented_tests() { -w ${PACKAGE_NAME}.test/android.support.test.runner.AndroidJUnitRunner \ | tee ${OUTPUTS_DIR}/instrument.txt - mkdir -p ${OUTPUTS_DIR}/code-coverage/connected/ - $ADB pull /data/user/0/${PACKAGE_NAME}/files/coverage.ec \ - ${OUTPUTS_DIR}/code-coverage/connected/ \ - || log_error "COVERAGE REPORT NOT AVAILABLE" + if grep FAILURES $OUTPUTS_DIR/instrument.txt; then + log_error "Some instrumented tests failed" + fetch_images + fetch_logcat + exit 1 + fi + + #mkdir -p ${OUTPUTS_DIR}/code-coverage/connected/ + #$ADB pull /data/user/0/${PACKAGE_NAME}/files/coverage.ec \ + # ${OUTPUTS_DIR}/code-coverage/connected/ \ + # || log_error "COVERAGE REPORT NOT AVAILABLE" } parse_instrumentation_results() { @@ -173,16 +182,8 @@ generate_coverage_badge() { python3 tools/coverage-badge/badge.py -i $CORE_REPORT -o ${OUTPUTS_DIR}/coverage-badge } -fetch_artifacts() { - log_info "Fetching generated artifacts" - mkdir -p ${OUTPUTS_DIR}/failed - $ADB pull /mnt/sdcard/test-screenshots/ ${OUTPUTS_DIR}/failed - $ADB pull /storage/sdcard/test-screenshots/ ${OUTPUTS_DIR}/failed - $ADB pull /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ ${OUTPUTS_DIR}/failed -} - fetch_logcat() { - log_info "Fetching logcat to ${OUTPUTS_DIR}/logcat.txt" + log_info "Fetching logcat" $ADB logcat -d > ${OUTPUTS_DIR}/logcat.txt } @@ -201,14 +202,9 @@ uninstall_test_apk() { } fetch_images() { - rm -rf tmp/test-screenshots > /dev/null - mkdir -p tmp/ - $ADB pull /mnt/sdcard/test-screenshots/ tmp/ - $ADB pull /storage/sdcard/test-screenshots/ tmp/ - $ADB pull /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ tmp/ - - $ADB shell rm -r /mnt/sdcard/test-screenshots/ - $ADB shell rm -r /storage/sdcard/test-screenshots/ + log_info "Fetching images" + rm -rf $OUTPUTS_DIR/test-screenshots + $ADB pull /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ $OUTPUTS_DIR $ADB shell rm -r /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ } @@ -226,7 +222,6 @@ run_tests() { install_test_apk run_instrumented_tests $SIZE parse_instrumentation_results - fetch_artifacts fetch_logcat uninstall_test_apk }