Skip to content

Add compose test step to CI #7

Add compose test step to CI

Add compose test step to CI #7

Workflow file for this run

name: UI Tests
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
ui-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Cache gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Decode google-services.json
run: echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 -d > app/google-services.json
env:
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
- name: Make gradlew executable
run: chmod +x gradlew
- name: Build for debug with gradle
run: ./gradlew assembleDebug assembleAndroidTest
- name: Install Docker
run: |
sudo apt-get update
sudo apt-get install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER
- name: Start Docker Android Container
run: |
docker run -d --name android-container \
-p 4723:4723 -p 6080:6080 -p 5554:5554 -p 5555:5555 \
--privileged \
budtmo/docker-android-x86-7.1.1:1.8-p2
# Wait for container to fully initialize
echo "Waiting for Android container to initialize..."
sleep 90
# Check container status
docker ps
docker logs android-container
- name: Set up ADB and connect to device
run: |
sudo apt-get install -y android-tools-adb
adb start-server
# Get container IP
CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' android-container)
echo "Container IP: $CONTAINER_IP"
# Connect to the emulator
adb connect $CONTAINER_IP:5555
# Wait for device to be fully booted
echo "Waiting for device to fully boot..."
sleep 30
# Check connected devices
adb devices -l
# Disable animations
adb shell settings put global window_animation_scale 0.0
adb shell settings put global transition_animation_scale 0.0
adb shell settings put global animator_duration_scale 0.0
- name: Run UI Tests
run: |
# Install app
./gradlew installDebug
# Run tests
./gradlew connectedDebugAndroidTest
- name: Cleanup Docker Container
if: always()
run: |
adb kill-server
docker stop android-container
docker rm android-container
- name: Upload UI test report
if: always()
uses: actions/upload-artifact@v4
with:
name: compose_test_report
path: |
app/build/reports/androidTests/connected/
app/build/outputs/androidTest-results/connected/