Android CI/CD #28
This file contains 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: dasd | |
on: | |
pull_request: | |
branches: | |
- development | |
- master # Run only for pull requests targeting the develop and master branch | |
types: | |
- synchronize # Trigger when commits are added to the pull request | |
- opened # Trigger when a pull request is first opened | |
- reopened # Trigger when a previously closed pull request is reopened | |
jobs: | |
instrumentation-tests: | |
name: Run Instrumentation Tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
api-level: [ 30 ] | |
target: [ google_apis ] | |
steps: | |
# Checkout the code | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Enable KVM for faster test execution | |
- 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 | |
# Setup or Load the cached gradle | |
- name: Gradle cache | |
uses: gradle/actions/setup-gradle@v3 | |
# Load the AVD Cache. For android emulator | |
- name: AVD cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }} | |
# Setup the AVD if not cached | |
- name: create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: ${{ matrix.target }} | |
emulator-port: 5582 | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: echo "Generated AVD snapshot for caching." | |
# Create local.properties | |
- name: Create local.properties | |
run: | | |
echo "sdk.dir=$ANDROID_HOME" > local.properties | |
echo "GOOGLE_KEY=${{ secrets.GOOGLE_MAPS_API }}" >> local.properties | |
# Create release.secrets.properties | |
- name: Create release.secrets.properties | |
run: | | |
echo "apiKommunicateIo=${{ secrets.APIKOMMUNICATEIO }}" >> release.secrets.properties | |
echo "apiEuKommunicateIo=${{ secrets.APIEUKOMMUNICATEIO }}" >> release.secrets.properties | |
echo "apiCaKommunicateIo=${{ secrets.APICAKOMMUNICATEIO }}" >> release.secrets.properties | |
echo "apiTestKommuncateIo=${{ secrets.APITESTKOMMUNCATEIO }}" >> release.secrets.properties | |
echo "kommunicateIo=${{ secrets.KOMMUNICATEIO }}" >> release.secrets.properties | |
echo "apiInKommunicateIo=${{ secrets.APIINKOMMUNICATEIO }}" >> release.secrets.properties | |
echo "kommunicateAWS=${{ secrets.KOMMUNICATEAWS }}" >> release.secrets.properties | |
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> release.secrets.properties | |
- name: run tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: ${{ matrix.target }} | |
emulator-port: 5582 | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: ./gradlew connectedCheck | |
# Build the app and run tests | |
- name: Build and Run Tests | |
run: | | |
./gradlew assembleDebug assembleAndroidTest | |
./gradlew connectedAndroidTest | |
# Upload Test Results | |
- name: Upload Test Results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results | |
path: app/build/reports/androidTests/ |