Skip to content

PR check - Android Emulator #28

PR check - Android Emulator

PR check - Android Emulator #28

Workflow file for this run

name: Run UI tests
on:
push:
branches:
- feature/AND-11480_install_allure_in_docker_image
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
ALLURE_ENDPOINT: https://testops.tests-d.com
ALLURE_PROJECT_ID: 1
jobs:
run_tests:
name: Run UI tests
runs-on: [ self-hosted, X64 ]
steps:
- name: Clean workspace
run: |
echo "Cleaning workspace: $(pwd)"
rm -rf ./* .[^.]* .??*
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.GH_MOBILE_PAT }}
fetch-depth: 0
- name: Build Docker image
run: |
docker build --platform linux/x86_64 -t tangem_ci_android_environment_x86_64 -f tangem-android-tools/CI/dockerfiles/Dockerfile.android.x64 .
- name: Run UI tests
id: tests
env:
GITHUB_TOKEN: ${{ secrets.GH_MOBILE_PAT }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
run: |
env > .env
docker run --rm \
--user ubuntu \
--env-file .env \
--device /dev/kvm \
--volume ~/.gradle:/home/ubuntu/.gradle \
--volume ${{ github.workspace }}:/workspace \
tangem_ci_android_environment_x86_64 \
bash -c '
set -e
export PATH=$PATH:/opt/android-sdk/platform-tools
cd /workspace
cp app/src/main/assets/tangem-app-config/android/google-services/dev/google-services.json app
cp tangem-android-tools/CI/gradle_properties/ui_tests_ci_gradle.properties gradle.properties
cat gradle.properties
export HOME=/home/ubuntu
export ANDROID_AVD_HOME=$HOME/.android/avd
mkdir -p $ANDROID_AVD_HOME
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd \
--force \
--name "android_35_x86_64" \
--package "system-images;android-35;aosp_atd;x86_64" \
--device "pixel_5"
$ANDROID_HOME/emulator/emulator -list-avds
echo "Starting emulator..."
$ANDROID_HOME/emulator/emulator -avd android_35_x86_64 -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect &
EMU_PID=$!
for i in {1..20}; do
if adb shell getprop sys.boot_completed | grep -m 1 "1"; then
echo "Emulator booted!"
break
fi
echo "Waiting for emulator to boot..."
sleep 5
done
if ! adb shell getprop sys.boot_completed | grep -m 1 "1"; then
echo "Emulator failed to boot!"
exit 1
fi
adb devices
./gradlew :app:connectedMockedAndroidTest || echo "Tests completed with failures"
echo "Extracting Allure results..."
mkdir -p ./allure-results
adb pull /storage/emulated/0/Documents/allure-results/. ./allure-results/ || echo "No allure results found"
ls -la ./allure-results/ || echo "No results directory"
kill $EMU_PID
'
- name: Upload Allure Results to TestOps
if: always()
env:
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
run: |
if [ -d "./allure-results" ] && [ "$(ls -A ./allure-results)" ]; then
echo "Found Allure results, uploading to TestOps..."
docker run --rm \
--volume ${{ github.workspace }}:/workspace \
tangem_ci_android_environment_x86_64 \
bash -c "
cd /workspace
allurectl upload ./allure-results \
--endpoint $ALLURE_ENDPOINT \
--project-id $ALLURE_PROJECT_ID \
--token ALLURE_TOKEN \
--launch-name 'Android UI Tests - Build #${{ github.run_number }}' \
--launch-tags 'android_autotests' \
--launch-tags 'branch:${{ github.ref_name }}' \
--launch-tags 'commit:${{ github.sha }}'
"
echo "✅ Results uploaded to Allure TestOps"
else
echo "❌ No Allure results found to upload"
fi
- name: Comment with results
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const testStatus = '${{ steps.tests.outcome }}';
const testopsUrl = `${{ env.ALLURE_ENDPOINT }}/project/${{ env.ALLURE_PROJECT_ID }}/launches`;
const statusEmoji = testStatus === 'success' ? '✅' : testStatus === 'failure' ? '❌' : '⚠️';
const comment = `
## 📊 Android UI Test Results
**Test Status**: ${statusEmoji} ${testStatus}
**Branch**: ${{ github.ref_name }}
**Commit**: ${{ github.sha }}
**Reports**:
- [🔗 Allure TestOps](${testopsUrl})
**Build**: #${{ github.run_number }}
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});