Skip to content

Data layer integration tests #2246

Data layer integration tests

Data layer integration tests #2246

name: Data layer integration tests
on:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
merge_group:
push:
branches:
- 'develop'
pull_request:
concurrency:
group: 'ci-${{ github.event.merge_group.head_ref || github.head_ref }}-${{ github.workflow }}'
cancel-in-progress: true
jobs:
data-layer-integration-tests:
name: Data layer integration tests run against Firebase emulator in Docker
runs-on: ubuntu-latest
strategy:
matrix:
# api-level: [ 30 ]
# target: [ google_apis ]
include:
- api-level: 30
target: google_atd
steps:
- 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
ls /dev/kvm
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
gradle-home-cache-cleanup: true
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.target }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
profile: "Galaxy Nexus"
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
## Build before running tests
- name: Build instrumented integration tests
run: ./gradlew :app:packageDebug :integration-tests:firebase:packageDebug
- name: Start Firebase emulator and wait for it to be ready
id: start-emulator
run: docker compose -f ./integration-tests/firebase/docker-compose.yml up --wait
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Run instrumented integration tests
uses: reactivecircus/android-emulator-runner@v2
with:
profile: "Galaxy Nexus"
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
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: |
# Workaround for https://github.com/ReactiveCircus/android-emulator-runner/issues/319
adb uninstall "com.omricat.maplibrarian.integrationtesting.debug" || true
adb uninstall "com.omricat.maplibrarian.debug" || true
./gradlew installDebug
./scripts/run-instrumented-integration-tests.sh
killall -INT crashpad_handler || true
- name: Extract logs from firebase emulator container
if: ${{ always() }}
run: |
mkdir -p ./build/logs || true
docker compose -f ./integration-tests/firebase/docker-compose.yml cp "firebase-emulator:/home/firebase-emulator" ./build/logs
- name: Upload firebase emulator logs
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: firebase-debug-logs-api-${{ matrix.api-level }}-${{ matrix.target }}
path: ./build/logs/firebase-emulator/**/*.log
- name: Upload test results/logs
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: instrumentation-test-results-api-${{ matrix.api-level }}-${{ matrix.target }}
path: |
./**/build/logs/logcat.log
./**/build/reports/androidTests/connected/**
./**/build/outputs/androidTest-results/**
./**/build/outputs/connected_android_test_additional_output/**