|
1 | 1 | name: Development tests |
2 | 2 | on: push |
3 | 3 | jobs: |
| 4 | + compile: |
| 5 | + name: Compile and cache |
| 6 | + runs-on: ubuntu-latest |
| 7 | + steps: |
| 8 | + - uses: actions/checkout@v4 |
| 9 | + - uses: actions/setup-java@v4 |
| 10 | + with: |
| 11 | + distribution: temurin |
| 12 | + java-version: 21 |
| 13 | + |
| 14 | + # See https://community.gradle.org/github-actions/docs/setup-gradle/ for more information |
| 15 | + - uses: gradle/actions/setup-gradle@v4 # creates build cache when on main branch |
| 16 | + with: |
| 17 | + cache-encryption-key: ${{ secrets.gradle_encryption_key }} |
| 18 | + gradle-home-cache-cleanup: true # clean up unused files |
| 19 | + dependency-graph: generate-and-submit # submit Github Dependency Graph info |
| 20 | + |
| 21 | + - run: ./gradlew --build-cache --configuration-cache compileDebugSources |
| 22 | + |
4 | 23 | test: |
| 24 | + needs: compile |
5 | 25 | name: Tests without emulator |
6 | 26 | runs-on: ubuntu-latest |
7 | 27 | steps: |
8 | | - - uses: actions/checkout@v2 |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + - uses: actions/setup-java@v4 |
9 | 30 | with: |
10 | | - submodules: true |
11 | | - - uses: actions/setup-java@v2 |
| 31 | + distribution: temurin |
| 32 | + java-version: 21 |
| 33 | + - uses: gradle/actions/setup-gradle@v4 |
12 | 34 | with: |
13 | | - distribution: 'temurin' |
14 | | - java-version: 11 |
15 | | - cache: 'gradle' |
16 | | - - uses: gradle/wrapper-validation-action@v1 |
| 35 | + cache-encryption-key: ${{ secrets.gradle_encryption_key }} |
| 36 | + cache-read-only: true |
17 | 37 |
|
18 | | - - name: Check |
19 | | - run: ./gradlew check |
20 | | - - name: Archive results |
21 | | - uses: actions/upload-artifact@v2 |
22 | | - with: |
23 | | - name: test-results |
24 | | - path: | |
25 | | - build/outputs/lint* |
26 | | - build/reports |
| 38 | + - name: Run lint and unit tests |
| 39 | + run: ./gradlew --build-cache --configuration-cache lintDebug testDebugUnitTest |
27 | 40 |
|
28 | 41 | test_on_emulator: |
| 42 | + needs: compile |
29 | 43 | name: Tests with emulator |
30 | | - runs-on: privileged |
31 | | - container: |
32 | | - image: ghcr.io/bitfireat/docker-android-ci:main |
33 | | - options: --privileged |
34 | | - env: |
35 | | - ANDROID_HOME: /sdk |
36 | | - ANDROID_AVD_HOME: /root/.android/avd |
| 44 | + runs-on: ubuntu-latest |
| 45 | + strategy: |
| 46 | + matrix: |
| 47 | + api-level: [ 31 ] |
37 | 48 | steps: |
38 | | - - uses: actions/checkout@v2 |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + - uses: actions/setup-java@v4 |
| 51 | + with: |
| 52 | + distribution: temurin |
| 53 | + java-version: 21 |
| 54 | + - uses: gradle/actions/setup-gradle@v4 |
39 | 55 | with: |
40 | | - submodules: true |
41 | | - - uses: gradle/wrapper-validation-action@v1 |
| 56 | + cache-encryption-key: ${{ secrets.gradle_encryption_key }} |
| 57 | + cache-read-only: true |
| 58 | + |
| 59 | + - name: Enable KVM group perms |
| 60 | + run: | |
| 61 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 62 | + sudo udevadm control --reload-rules |
| 63 | + sudo udevadm trigger --name-match=kvm |
42 | 64 |
|
43 | | - - name: Cache APKs and gradle dependencies |
44 | | - uses: actions/cache@v2 |
| 65 | + - name: Cache AVD and APKs |
| 66 | + uses: actions/cache@v4 |
| 67 | + id: avd-cache |
45 | 68 | with: |
46 | | - key: ${{ runner.os }}-1 |
47 | 69 | path: | |
| 70 | + ~/.android/avd/* |
| 71 | + ~/.android/adb* |
48 | 72 | ~/.apk |
49 | | - ~/.gradle/caches |
50 | | - ~/.gradle/wrapper |
| 73 | + key: avd-${{ matrix.api-level }} |
51 | 74 |
|
52 | | - - name: Start emulator |
53 | | - run: start-emulator.sh |
54 | | - - name: Install task apps |
55 | | - run: | |
56 | | - mkdir .apk && cd .apk |
57 | | - wget -cq -O org.dmfs.tasks.apk https://f-droid.org/archive/org.dmfs.tasks_80800.apk && adb install org.dmfs.tasks.apk |
58 | | - wget -cq -O org.tasks.apk https://f-droid.org/archive/org.tasks_120400.apk && adb install org.tasks.apk |
59 | | - wget -cq -O at.techbee.jtx.apk https://f-droid.org/archive/at.techbee.jtx_100140002.apk && adb install at.techbee.jtx.apk |
60 | | - cd .. |
61 | | - - name: Run connected tests |
62 | | - run: ./gradlew connectedCheck -Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.FlakyTest |
63 | | - - name: Archive results |
64 | | - uses: actions/upload-artifact@v2 |
| 75 | + - name: Create AVD and generate snapshot for caching |
| 76 | + if: steps.avd-cache.outputs.cache-hit != 'true' |
| 77 | + uses: reactivecircus/android-emulator-runner@v2 |
65 | 78 | with: |
66 | | - name: test-results |
67 | | - path: | |
68 | | - build/reports |
| 79 | + api-level: ${{ matrix.api-level }} |
| 80 | + arch: x86_64 |
| 81 | + force-avd-creation: false |
| 82 | + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 83 | + disable-animations: false |
| 84 | + script: echo "Generated AVD snapshot for caching." |
| 85 | + |
| 86 | + - name: Install task apps and run tests |
| 87 | + uses: reactivecircus/android-emulator-runner@v2 |
| 88 | + env: |
| 89 | + version_at_techbee_jtx: v2.9.0 |
| 90 | + version_org_tasks: 131104 |
| 91 | + version_org_dmfs_tasks: 82200 |
| 92 | + with: |
| 93 | + api-level: ${{ matrix.api-level }} |
| 94 | + arch: x86_64 |
| 95 | + force-avd-creation: false |
| 96 | + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 97 | + disable-animations: true |
| 98 | + script: | |
| 99 | + mkdir .apk && cd .apk |
| 100 | + (wget -cq -O org.dmfs.tasks.apk https://f-droid.org/repo/org.dmfs.tasks_${{ env.version_org_dmfs_tasks }}.apk || wget -cq -O org.dmfs.tasks.apk https://f-droid.org/archive/org.dmfs.tasks_${{ env.version_org_dmfs_tasks }}.apk) && adb install org.dmfs.tasks.apk |
| 101 | + (wget -cq -O org.tasks.apk https://f-droid.org/repo/org.tasks_${{ env.version_org_tasks }}.apk || wget -cq -O org.tasks.apk https://f-droid.org/archive/org.tasks_${{ env.version_org_tasks }}.apk) && adb install org.tasks.apk |
| 102 | + (wget -cq -O at.techbee.jtx.apk https://github.com/TechbeeAT/jtxBoard/releases/download/${{ env.version_at_techbee_jtx }}/jtxBoard-${{ env.version_at_techbee_jtx }}.apk) && adb install at.techbee.jtx.apk |
| 103 | + cd .. |
| 104 | + ./gradlew --build-cache --configuration-cache connectedCheck -Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.FlakyTest |
0 commit comments