diff --git a/.github/workflows/android_ci.yml b/.github/workflows/android_ci.yml new file mode 100644 index 00000000..d98126e1 --- /dev/null +++ b/.github/workflows/android_ci.yml @@ -0,0 +1,127 @@ +name: Android CI +on: + pull_request: + branches: + - main + types: [opened, reopened, synchronize] + +permissions: + pull-requests: write + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + name: Run Ktlint and Detekt + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Prepare App + uses: ./.github/composite/prepareApp + + - name: Run Ktlint + run: ./gradlew lintKotlin + + - name: Run Detekt + run: ./gradlew detekt + + test: + runs-on: ubuntu-latest + name: Run Tests + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Prepare App + uses: ./.github/composite/prepareApp + + - name: Run Unit Tests + run: ./gradlew test + + collect_coverage: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Prepare App + uses: ./.github/composite/prepareApp + + - name: Get Coverage + run: ./gradlew koverReport + + - name: Run File-wise Coverage Parser Script + run: python3 scripts/coverage_parser.py + + build: + runs-on: ubuntu-latest + name: build app + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Prepare App + uses: ./.github/composite/prepareApp + + - name: Build App + run: ./gradlew assembleDebug + + - name: Upload Debug APK + uses: actions/upload-artifact@v4 + if: success() + with: + name: latest-apk + path: "app/build/outputs/apk/conjugate/debug/app-conjugate-debug.apk" + + instrumentation_test: + runs-on: ubuntu-latest + strategy: + matrix: + flavor: [Conjugate, Keyboards] + fail-fast: false + name: Run Android Instrumentation Tests (${{ matrix.flavor }}) + timeout-minutes: 40 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Prepare App + uses: ./.github/composite/prepareApp + + - name: Enable KVM Group Permissions + 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: Pre-build Android Test APKs + run: ./gradlew assemble${{ matrix.flavor }}Debug assemble${{ matrix.flavor }}DebugAndroidTest + + - name: Run UI Tests on Emulator + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + target: google_apis + arch: x86_64 + profile: Nexus 6 + ram-size: 2048M + heap-size: 512M + disk-size: 6000M + emulator-options: "-no-window -no-audio -no-boot-anim -camera-back none -camera-front none -gpu swiftshader_indirect -no-snapshot -wipe-data -accel on" + disable-animations: true + force-avd-creation: false + script: | + adb wait-for-device + adb shell input keyevent 82 + ./gradlew connected${{ matrix.flavor }}DebugAndroidTest --stacktrace