Skip to content

test(critical): Add Mock Relay to verify crash envelope #40

test(critical): Add Mock Relay to verify crash envelope

test(critical): Add Mock Relay to verify crash envelope #40

name: UI Tests Critical
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
INTEGRATION_TESTS_PATH: "sentry-android-integration-tests"
BASE_PATH: "sentry-android-integration-tests/sentry-uitest-android-critical"
BUILD_PATH: "build/outputs/apk/release"
APK_NAME: "sentry-uitest-android-critical-release.apk"
APK_ARTIFACT_NAME: "sentry-uitest-android-critical-release"
MAESTRO_VERSION: "1.39.0"
MOCK_RELAY_ARTIFACT_NAME: "sentry-mock-relay"
MOCK_RELAY_PATH: "sentry-mock-relay-0.0.1.zip"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@bb0c460cbf5354b0cddd15bacdf0d6aaa3e5a32b # pin@v3
with:
gradle-home-cache-cleanup: true
- name: Build mock relay
run: make buildMockRelay
- name: Upload Mock Relay
uses: actions/upload-artifact@v4
with:
name: ${{env.MOCK_RELAY_ARTIFACT_NAME}}
path: "${{env.INTEGRATION_TESTS_PATH}}/sentry-mock-relay/build/distributions/${{env.MOCK_RELAY_PATH}}"
retention-days: 1
- name: Build debug APK
run: make assembleUiTestCriticalRelease
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.APK_ARTIFACT_NAME}}
path: "${{env.BASE_PATH}}/${{env.BUILD_PATH}}/${{env.APK_NAME}}"
retention-days: 1
run-maestro-tests:
name: Run Tests for API Level ${{ matrix.api-level }}
needs: build
runs-on: ubuntu-latest
strategy:
# we want that the matrix keeps running, default is to cancel them if it fails.
fail-fast: false
matrix:
include:
- api-level: 30 # Android 11
target: aosp_atd
channel: canary # Necessary for ATDs
arch: x86_64
- api-level: 31 # Android 12
target: aosp_atd
channel: canary # Necessary for ATDs
arch: x86_64
- api-level: 33 # Android 13
target: aosp_atd
channel: canary # Necessary for ATDs
arch: x86_64
- api-level: 34 # Android 14
target: aosp_atd
channel: canary # Necessary for ATDs
arch: x86_64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup KVM
shell: bash
run: |
# check if virtualization is supported...
sudo apt install -y --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok
# allow access to KVM to run the emulator
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: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Download APK artifact
uses: actions/download-artifact@v4
with:
name: ${{env.APK_ARTIFACT_NAME}}
- name: Download Mock Relay
uses: actions/download-artifact@v4
with:
name: ${{env.MOCK_RELAY_ARTIFACT_NAME}}
- name: Unzip Mock Relay
run: unzip -o ${{env.MOCK_RELAY_PATH}}
- name: Install Maestro
uses: dniHze/maestro-test-action@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # [email protected]
with:
version: ${{env.MAESTRO_VERSION}}
- name: Run tests
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # [email protected]
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
disable-animations: true
disable-spellchecker: true
target: ${{ matrix.target }}
channel: ${{ matrix.channel }}
arch: ${{ matrix.arch }}
emulator-options: >
-no-window
-no-snapshot-save
-gpu swiftshader_indirect
-noaudio
-no-boot-anim
-camera-back none
-camera-front none
-timezone US/Pacific
script: |
adb install -r -d "${{env.APK_NAME}}"
./sentry-mock-relay-0.0.1/bin/sentry-mock-relay > /dev/null &
maestro test "${{env.BASE_PATH}}/maestro" --debug-output "${{env.BASE_PATH}}/maestro-logs"
curl --fail http://localhost:8961/assertReceivedAtLeastOneCrashReport
bin/bash "${{env.INTEGRATION_TESTS_PATH}}/sentry-mock-relay/scripts/kill.sh"
- name: Upload Maestro test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: maestro-logs
path: "${{env.BASE_PATH}}/maestro-logs"
retention-days: 1