Android CI #8
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: Android CI | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| schedule: | |
| # Run weekly on Sundays at 3 AM UTC | |
| - cron: '0 3 * * 0' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| api-level: [21, 26, 30, 33] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: 17 | |
| - name: Cache Gradle dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build debug APK | |
| run: ./gradlew --no-daemon assembleDebug | |
| - name: Run unit tests | |
| run: ./gradlew --no-daemon testDebug | |
| - name: Enable KVM group perms | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Run instrumented tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| target: default | |
| arch: x86_64 | |
| profile: Nexus 6 | |
| script: ./gradlew --no-daemon connectedDebugAndroidTest | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-api-${{ matrix.api-level }} | |
| path: | | |
| app/build/test-results/ | |
| app/build/reports/androidTests/ | |
| retention-days: 7 | |
| build-matrix: | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| build-type: [debug, release] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: 17 | |
| - name: Cache Gradle dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build ${{ matrix.build-type }} APK | |
| run: ./gradlew --no-daemon clean assemble${{ matrix.build-type == 'debug' && 'Debug' || 'Release' }} | |
| - name: Upload ${{ matrix.build-type }} APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mgit-${{ matrix.build-type }}-apk | |
| path: app/build/outputs/apk/${{ matrix.build-type }}/*.apk | |
| retention-days: 30 |