forked from mozilla/klaatu
-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (158 loc) · 6.83 KB
/
android_manual.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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_test'
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:
fail-fast: false
matrix:
firefox: ${{ fromJSON(inputs.firefox-version) }}
name: ${{ inputs.feature-name }} tests for ${{ inputs.slug }} on firefox android ${{ matrix.firefox }}
steps:
- name: Set FF Version for downloader
id: ff-version
run: |
version=${{ matrix.firefox }}
major_version=$(echo $version | cut -d'.' -f1)
echo "FF_VERSION=$major_version" >> "$GITHUB_OUTPUT"
- name: Checkout klaatu repo
uses: actions/checkout@v4
with:
path: klaatu
- 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: Clone firefox-android-github
uses: actions/checkout@v4
if: matrix.firefox < '126.0.0'
with:
repository: mozilla-mobile/firefox-android
ref: "releases_v${{ steps.ff-version.outputs.FF_VERSION }}"
path: firefox-android
- 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
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
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 and install Android files
if: |
(steps.cache_test_apk.outputs.cache-hit != 'true') &&
(matrix.firefox > '125.0.0')
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 android-debug-test-v${{ matrix.firefox }}.apk
adb install fenix-debug-v${{ matrix.firefox }}.apk
env:
ANDROID_SDK_HOME: $ANDROID_HOME
ANDROID_NDK_HOME: $ANDROID_NDK_HOME
- name: Build and install Android version sub 126
if: matrix.firefox < '126.0.0'
run: |
cd firefox-android/fenix
./gradlew clean app:assembleFenixDebugAndroidTest
adb install app/build/outputs/apk/androidTest/fenix/debug/app-fenix-debug-androidTest.apk
mv app/build/outputs/apk/androidTest/fenix/debug/app-fenix-debug-androidTest.apk /home/runner/work/klaatu/klaatu/android-debug-test-v${{ matrix.firefox }}.apk
./gradlew clean app:assembleFenixDebug
adb install app/build/outputs/apk/fenix/debug/app-fenix-x86_64-debug.apk
mv app/build/outputs/apk/fenix/debug/app-fenix-x86_64-debug.apk /home/runner/work/klaatu/klaatu/fenix-debug-v${{ matrix.firefox }}.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 install pytest-rerunfailures
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 }} --reruns 1
- 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