Skip to content

ci: run E2E test with gradle #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 36 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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'}}
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down