diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 273ef26b..8fbc48f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -182,18 +182,24 @@ jobs: run: | make dist/aw-android.apk - - name: Upload artifact + - name: Upload release APK uses: actions/upload-artifact@v3 with: name: aw-android path: dist/aw-android*.apk - - name: Upload artifact + - name: Upload debug APKs uses: actions/upload-artifact@v3 with: name: apks path: dist/apk/ + - name: Upload JNI libs + uses: actions/upload-artifact@v3 + with: + name: jniLibs + path: mobile/src/main/jniLibs/ + test-e2e: needs: [build] name: Test E2E ${{ matrix.android_avd }} #-${{ matrix.os }}-eAPI-${{ matrix.android_emu_version }}-java-${{ matrix.java_version }}-node-${{ matrix.node_version }} @@ -220,15 +226,21 @@ jobs: with: submodules: 'recursive' - # Will download all artifacts to path - - name: Download build artifacts + - name: Download debug APKs uses: actions/download-artifact@v3 with: name: apks - path: dist/apk + path: mobile/build/outputs/apk - name: Display structure of downloaded files - working-directory: dist - run: ls -R + run: cd mobile/build/outputs/apk && ls -R + + - name: Download JNI libs + uses: actions/download-artifact@v3 + with: + name: jniLibs + path: mobile/src/main/jniLibs + - name: Display structure of downloaded files + run: cd mobile/src/main/jniLibs && ls -R # # # Below code is majorly from https://github.com/actions/runner-images/issues/6152#issuecomment-1243718140 - name: Create Android emulator @@ -318,16 +330,26 @@ jobs: # # $ANDROID_HOME/tools/emulator -port 18725 -verbose -no-audio -gpu swiftshader_indirect -logcat *:v @$MATRIX_AVD & # ffmpeg -f avfoundation -i 0 -t 120 out$SUFFIX.mov & - - name: Test App + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java_version }} + + # Android SDK & NDK + - name: Set up Android SDK + uses: android-actions/setup-android@v2 + - name: Install NDK + run: | + sdkmanager "ndk;${{ matrix.ndk_version }}" + ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ matrix.ndk_version }}" + ls $ANDROID_NDK_HOME + echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV + + - name: Run E2E tests timeout-minutes: 20 id: test run: | - adb install dist/apk/debug/mobile-debug.apk - adb install dist/apk/androidTest/debug/mobile-debug-androidTest.apk - adb shell pm list instrumentation - adb shell am instrument -w \ - -e class net.activitywatch.android.ScreenshotTest \ - net.activitywatch.android.debug.test/androidx.test.runner.AndroidJUnitRunner + make test-e2e - name: Output and save logcat to file if: ${{ success() || steps.test.conclusion == 'failure'}} diff --git a/Makefile b/Makefile index cb4f5ec8..3c44e832 100644 --- a/Makefile +++ b/Makefile @@ -29,19 +29,26 @@ test-unit: ./gradlew test test-e2e: - # Run only screenshot test, for now + @# Run only screenshot test, for now ./gradlew connectedAndroidTest \ -Pandroid.testInstrumentationRunnerArguments.class=net.activitywatch.android.ScreenshotTest test-e2e-adb: - # Requires that you have a device connected with the necessary APKs installed - # Alternative to using gradle, if you don't want to rebuild. - # Run only screenshot test, for now - adb shell pm list instrumentation + @# Requires that you have a device connected with the necessary APKs installed + @# Alternative to using gradle, if you don't want to rebuild. + @# + @# To list instrumentation tests, run: + @# adb shell pm list instrumentation + @# + @# Run only screenshot test, for now adb shell am instrument -w \ -e class net.activitywatch.android.ScreenshotTest net.activitywatch.android.debug.test/androidx.test.runner.AndroidJUnitRunner +install-apk-debug: $(APKDIR)/debug/mobile-debug.apk + adb install $(APKDIR)/debug/mobile-debug.apk + adb install $(APKDIR)/debug/mobile-debug-androidTest.apk + # APK targets $(APKDIR)/release/mobile-release-unsigned.apk: TERM=xterm ./gradlew assembleRelease