Skip to content

Android Klaatu Tests #98

Android Klaatu Tests

Android Klaatu Tests #98

name: Android Klaatu Tests
on:
workflow_dispatch:
inputs:
branch:
description: 'Experiment Branch'
default: 'control'
required: true
type: string
slug:
description: 'Experiment Slug'
default: 'an-awesome-experiment'
required: true
type: string
firefox-version:
description: 'The Firefox Version(s) you want to test'
default: "['126.0']"
required: false
type: string
feature-name:
description: 'The Feature you want to test'
default: 'smoke'
required: true
type: choice
options:
- smoke_test
- messaging_survey
- messaging_homescreen
extra-arguments:
description: 'Additional testing arguments'
default: ''
required: false
type: string
jobs:
android-klaatu-tests:
runs-on: ubuntu-latest
strategy:
matrix:
firefox: ${{ fromJSON(inputs.firefox-version) }}
name: ${{ inputs.feature-name }} tests for ${{ inputs.slug }} on firefox android ${{ matrix.firefox }}
steps:
- name: Checkout klaatu repo
uses: actions/checkout@v4
with:
path: klaatu
- name: Checkout android github Repository
if: ${{ matrix.firefox < 126 }}
uses: actions/checkout@v4
with:
repository: mozilla-mobile/firefox-android
ref: "releases_v${{ matrix.firefox }}"
path: fenix
- name: Clone gecko-dev
uses: actions/checkout@v4
with:
sparse-checkout: mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix
repository: mozilla/gecko-dev
path: gecko-dev
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Cache Fenix Test APK
id: cache_test_apk
if: ${{ matrix.firefox }}
uses: actions/cache@v2
with:
path: klaatu/android-debug-test-v${{ matrix.firefox }}.apk
key: android-debug-test-v${{ matrix.firefox }}
- name: Cache Fenix APK
if: ${{ matrix.firefox }}
uses: actions/cache@v2
with:
path: klaatu/fenix-debug-v${{ matrix.firefox }}.apk
key: fenix-debug-v${{ matrix.firefox }}
- 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
- name: Download android images
run: |
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --update
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "system-images;android-34;google_apis;x86_64"
echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "tools"
- name: Set PATHs
run: |
echo "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/" >> $GITHUB_PATH
echo "$ANDROID_SDK_ROOT/platform-tools" >> $GITHUB_PATH
echo "$ANDROID_SDK_ROOT/emulator" >> $GITHUB_PATH
- name: Start emulator
run: |
avdmanager create avd -n pixel_3a -k "system-images;android-34;google_apis;x86_64" --device "pixel_3a"
emulator -avd pixel_3a -no-window -no-snapshot -screen no-touch -noaudio -memory 2048 -no-boot-anim -accel on -camera-back none -gpu off &
adb wait-for-device
boot_completed="0"
while [ "$boot_completed" != "1" ]; do
boot_completed=$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')
if [ "$boot_completed" != "1" ]; then
echo "Waiting for emulator to boot..."
sleep 1
fi
done
- name: Download Android files and install
if: ${{ matrix.firefox > 125 }}
run: |
cd klaatu
pip3 install virtualenv poetry
poetry install --no-root
firefox_version=$(echo "${{ matrix.firefox }}" | tr '.' '_')
poetry run python utilities/get_android_apks.py --firefox-version=${{ matrix.firefox }}
adb devices
adb install klaatu/android-debug-test-v${{ matrix.firefox }}.apk
adb install klaatu/fenix-debug-v${{ matrix.firefox }}.apk
env:
ANDROID_SDK_HOME: $ANDROID_HOME
ANDROID_NDK_HOME: $ANDROID_NDK_HOME
- name: Build test files and install
if: ${{ matrix.firefox < 126 }} && steps.cache_test_apk.outputs.cache-hit != 'true'
run: |
cd fenix/fenix
ls -la
./gradlew clean app:assembleFenixDebug
./gradlew clean app:assembleFenixDebugAndroidTest
ls app/build/outputs/apk/fenix/debug/
adb install app/build/outputs/apk/fenix/debug/app-fenix-x86_64-debug.apk
adb install app/build/outputs/apk/androidTest/fenix/debug/app-fenix-debug-androidTest.apk
env:
ANDROID_SDK_HOME: $ANDROID_HOME
ANDROID_NDK_HOME: $ANDROID_NDK_HOME
- name: Install Nimbus CLI
run: curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/mozilla/application-services/main/install-nimbus-cli.sh | bash
- name: Run Tests
run: |
cd gecko-dev/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration
pip3 install virtualenv poetry pipenv
pipenv install
pipenv run python generate_smoke_tests.py
echo "PIPENV COMMAND: 'pipenv run pytest --experiment ${{ inputs.slug }} --experiment-branch ${{ inputs.branch }} --experiment-feature ${{ inputs.feature-name }} ${{ inputs.extra-arguments }}'"
pipenv run pytest --experiment ${{ inputs.slug }} --experiment-branch ${{ inputs.branch }} --experiment-feature ${{ inputs.feature-name }} ${{ inputs.extra-arguments }}
- uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: ${{ inputs.slug }} HTML Test Report on firefox v${{ matrix.firefox }}
path: /home/runner/work/klaatu/klaatu/gecko-dev/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/results/index.html