added tests #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run JUnit and Android Instrumented Tests | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| unit_tests: | |
| name: Unit Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' # only temurin accepted | |
| java-version: '17' | |
| # cache gradle dependencies for faster build next time | |
| - name: Cache gradle | |
| uses: gradle/gradle-build-action@v2 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Begin unit tests | |
| run: ./gradlew testDebugUnitTest | |
| - name: Upload unit test reports | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: unit_test_repots | |
| path: app/build/reports | |
| android_tests: | |
| name: Run Android Instrumented Tests | |
| runs-on: ubuntu-latest | |
| needs: unit_tests # runs only when unit_tests runs successfully | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install emulator | |
| run: | | |
| echo "KVM setup" | |
| sudo apt-get update | |
| sudo apt-get install -y qemu-kvm libvirt-daemon-system | |
| - name: Setup JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' # only temurin accepted | |
| java-version: '17' | |
| # cache gradle dependencies for faster build next time | |
| - name: Cache gradle | |
| uses: gradle/gradle-build-action@v2 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Run instrumentation tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 30 # as of April 2026 api 30 and 29 is the latest stable | |
| arch: x86_64 | |
| target: google_apis | |
| profile: Nexus 5 # use stable device like Nexus 5 or Pixle (not variant of Pixel like Pixel 8 Pixel 9 etc.) | |
| disable-animations: true | |
| script: ./gradlew connectedDebugAndroidTest --stacktrace | |
| - name: Upload android instrumented test reports | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: android_test_reports | |
| path: app/build/reports |