Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add CI build and test jobs
  • Loading branch information
krystofwoldrich committed Oct 18, 2024
commit 339a8d7e84a0d693f24672b47bdff8758b728853
89 changes: 89 additions & 0 deletions .github/workflows/integration-tests-ui-critical.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: UI Tests Critical

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
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"

jobs:
build:
name: Build sentry-uitest-android-critical
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 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 Maestro Tests
needs: build
runs-on: ubuntu-latest
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: Download APK artifact
uses: actions/download-artifact@v4
with:
name: ${{env.APK_ARTIFACT_NAME}}

- name: Install Maestro
run: |
brew tap mobile-dev-inc/tap
brew install maestro

- name: Run Maestro tests
run: |
maestro test \
"${{env.BASE_PATH}}/maestro" \
--debug-output "${{env.BASE_PATH}}/maestro-logs"

- 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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ assembleUiTestRelease:
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleRelease
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleAndroidTest -DtestBuildType=release

# Assemble release of the uitest-android-critical module
assembleUiTestCriticalRelease:
./gradlew :sentry-android-integration-tests:sentry-uitest-android-critical:assembleRelease

# Run Maestro tests for the uitest-android-critical module
runUiTestCritical:
./scripts/test-ui-critical.sh

# Create coverage reports
# - Jacoco for Java & Android modules
# - Kover for KMP modules e.g sentry-compose
Expand Down
35 changes: 35 additions & 0 deletions scripts/test-ui-critical.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e

echo "Checking if ADB is installed..."
if ! command -v adb &> /dev/null; then
echo "ADB is not installed or not in PATH. Please install Android SDK platform tools and ensure ADB is in your PATH."
exit 1
fi

echo "Checking if an Android emulator is running..."
if ! adb devices | grep -q "emulator"; then
echo "No Android emulator is currently running. Please start an emulator before running this script."
exit 1
fi

echo "Checking if Maestro is installed..."
if ! command -v maestro &> /dev/null; then
echo "Maestro is not installed. Please install Maestro before running this script."
exit 1
fi

echo "Building the UI Test Critical app..."
make assembleUiTestCriticalRelease

echo "Installing the UI Test Critical app on the emulator..."
baseDir="sentry-android-integration-tests/sentry-uitest-android-critical"
buildDir="build/outputs/apk/release"
apkName="sentry-uitest-android-critical-release.apk"
appPath="${baseDir}/${buildDir}/${apkName}"
adb install -r -d "$appPath"

echo "Running the Maestro tests..."
maestro test \
"${baseDir}/maestro" \
--debug-output "${baseDir}/maestro-logs"
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ android {
compileSdk = Config.Android.compileSdkVersion
namespace = "io.sentry.uitest.android.critical"

signingConfigs {
getByName("debug") {
// Debug config remains unchanged
}
}

defaultConfig {
applicationId = "io.sentry.uitest.android.critical"
minSdk = 21
Expand All @@ -20,6 +26,7 @@ android {
buildTypes {
release {
isMinifyEnabled = false
signingConfig = signingConfigs.getByName("debug")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down