Skip to content

Commit e201f45

Browse files
committed
wip: tidy up PR
1 parent 9a056b6 commit e201f45

File tree

3 files changed

+36
-54
lines changed

3 files changed

+36
-54
lines changed

.github/workflows/android-regression.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,7 @@ jobs:
162162
- name: Download APK & extract it
163163
run: |
164164
pwd
165-
if [[ "${{ runner.os }}" == "macOS" ]]; then
166-
curl -L -o session-android.apk.tar.xz ${{ github.event.inputs.APK_URL }}
167-
else
168-
wget -q -O session-android.apk.tar.xz ${{ github.event.inputs.APK_URL }}
169-
fi
165+
curl -L -o session-android.apk.tar.xz ${{ github.event.inputs.APK_URL }}
170166
tar xf session-android.apk.tar.xz
171167
mv session-android-*universal extracted
172168

run/test/specs/utils/capabilities_android.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const emulator5Udid = 'emulator-5562';
3535
const emulator6Udid = 'emulator-5564';
3636
const emulator7Udid = 'emulator-5566';
3737
const emulator8Udid = 'emulator-5568';
38-
const emulator9Udid = 'emulator-5570';
3938

4039
const udids = [
4140
emulator1Udid,
@@ -46,7 +45,6 @@ const udids = [
4645
emulator6Udid,
4746
emulator7Udid,
4847
emulator8Udid,
49-
emulator9Udid,
5048
];
5149

5250
const emulatorCapabilities: AppiumCapabilities[] = udids.map(udid => ({
@@ -63,7 +61,6 @@ const emulatorCapabilities5 = emulatorCapabilities[4];
6361
const emulatorCapabilities6 = emulatorCapabilities[5];
6462
const emulatorCapabilities7 = emulatorCapabilities[6];
6563
const emulatorCapabilities8 = emulatorCapabilities[7];
66-
const emulatorCapabilities9 = emulatorCapabilities[8];
6764

6865
export const androidCapabilities = {
6966
sharedCapabilities,
@@ -80,7 +77,6 @@ function getAllCaps() {
8077
emulatorCapabilities6,
8178
emulatorCapabilities7,
8279
emulatorCapabilities8,
83-
emulatorCapabilities9,
8480
];
8581
return emulatorCaps;
8682
}

scripts/ci.sh

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,71 @@
22
set -x
33
# Android functions
44

5-
# Detect platform and set variables accordingly
5+
# Common configuration
6+
TARGET="google_apis_playstore"
7+
EMULATOR_DEVICE="pixel_6"
8+
EMULATOR_BIN="emulator"
9+
10+
# Platform-specific configuration
611
if [[ "$OSTYPE" == "darwin"* ]]; then
7-
# Mac settings
12+
# Mac ARM64 settings
813
ARCH="arm64-v8a"
914
EMULATOR_COUNT=6
1015
API_LEVEL="35"
1116
ANDROID_CMD="commandlinetools-mac-13114758_latest.zip"
12-
EMULATOR_BIN="emulator"
13-
TARGET="google_apis_playstore" # Mac ARM doesn't have playstore variant
1417
ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT:-"$HOME/Android/sdk"}
18+
RAM_SIZE="2048"
19+
EMULATOR_PROCESS="qemu-system-aarch64-headless"
1520
else
16-
# Linux settings
21+
# Linux x86_64 settings
1722
ARCH="x86_64"
1823
EMULATOR_COUNT=4
1924
API_LEVEL="34"
2025
ANDROID_CMD="commandlinetools-linux-13114758_latest.zip"
21-
EMULATOR_BIN="emulator"
22-
TARGET="google_apis_playstore" # Linux can use playstore
2326
ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT:-"/opt/android"}
27+
RAM_SIZE="4192"
28+
EMULATOR_PROCESS="qemu-system-x86_64"
2429
fi
2530

26-
27-
# Derive build tools version from API level
31+
# Derived configuration (uses the variables set above)
2832
BUILD_TOOLS="${API_LEVEL}.0.0"
29-
ANDROID_ARCH=${ANDROID_ARCH_DEFAULT}
3033
ANDROID_API_LEVEL="android-${API_LEVEL}"
31-
ANDROID_APIS="${TARGET};${ARCH}"
32-
EMULATOR_PACKAGE="system-images;${ANDROID_API_LEVEL};${ANDROID_APIS}"
34+
EMULATOR_PACKAGE="system-images;${ANDROID_API_LEVEL};${TARGET};${ARCH}"
3335
PLATFORM_VERSION="platforms;${ANDROID_API_LEVEL}"
3436
BUILD_TOOL="build-tools;${BUILD_TOOLS}"
35-
export ANDROID_SDK_PACKAGES="${EMULATOR_PACKAGE} ${PLATFORM_VERSION} ${BUILD_TOOL} platform-tools"
36-
export ANDROID_SDK_ROOT
37+
ANDROID_SDK_PACKAGES="${EMULATOR_PACKAGE} ${PLATFORM_VERSION} ${BUILD_TOOL} platform-tools emulator"
3738

38-
export PATH="$PATH:$ANDROID_SDK_ROOT/cmdline-tools/tools:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/build-tools/${BUILD_TOOLS}:$ANDROID_SDK_ROOT/platform-tools/"
39-
export EMULATOR_DEVICE="pixel_6" # all emulators are created with the pixel 6 spec for now
39+
# Export everything
40+
export ARCH EMULATOR_BIN EMULATOR_COUNT EMULATOR_PROCESS API_LEVEL ANDROID_CMD TARGET ANDROID_SDK_ROOT RAM_SIZE
41+
export BUILD_TOOLS ANDROID_API_LEVEL EMULATOR_PACKAGE PLATFORM_VERSION BUILD_TOOL ANDROID_SDK_PACKAGES EMULATOR_DEVICE
42+
export PATH="$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/build-tools/${BUILD_TOOLS}:$PATH"
4043

4144

4245
# this should only be done when we bump the API version or add a worker to the CI that needs emulators to be setup
4346
# Once you've run this, you must also start_for_snapshots() and force_save_snapshots() (see details below)
4447
function create_emulators() {
45-
# Skip apt install on Mac
48+
# Skip apt install on Mac
4649
if [[ "$OSTYPE" != "darwin"* ]]; then
4750
sudo apt update
48-
sudo apt install -y ca-certificates curl git vim bash wget unzip tree htop gzip default-jre libnss3 libxcursor1 libqt5gui5 libc++-dev libxcb-cursor0 htop tree tar gzip gh nload
51+
sudo apt install -y ca-certificates curl git vim bash wget unzip tree htop gzip default-jre libnss3 libxcursor1 libqt5gui5 libc++-dev libxcb-cursor0 tar gh nload
4952
fi
5053

5154
sudo rm -rf $ANDROID_SDK_ROOT
52-
5355
sudo mkdir -p $ANDROID_SDK_ROOT
56+
5457
if [[ "$OSTYPE" == "darwin"* ]]; then
5558
sudo chown $USER:staff $ANDROID_SDK_ROOT
5659
else
5760
sudo chown $USER:$USER $ANDROID_SDK_ROOT
5861
fi
59-
# Download the SDK tools
60-
if [[ "$OSTYPE" == "darwin"* ]]; then
61-
curl -L -o /tmp/${ANDROID_CMD} https://dl.google.com/android/repository/${ANDROID_CMD}
62-
else
63-
wget https://dl.google.com/android/repository/${ANDROID_CMD} -P /tmp
64-
fi
6562

66-
# Check if download succeeded
67-
if [[ ! -f /tmp/${ANDROID_CMD} ]]; then
68-
echo "Failed to download Android SDK tools"
63+
# Download SDK tools
64+
local download_url="https://dl.google.com/android/repository/${ANDROID_CMD}"
65+
echo "Downloading Android SDK tools..."
66+
curl -fL -o "/tmp/${ANDROID_CMD}" "$download_url"
67+
68+
if [[ ! -f "/tmp/${ANDROID_CMD}" ]]; then
69+
echo "Error: Failed to download Android SDK tools" >&2
6970
return 1
7071
fi
7172

@@ -93,28 +94,21 @@ function create_emulators() {
9394
for i in $(seq 1 $EMULATOR_COUNT)
9495
do
9596
echo "no" | avdmanager --verbose create avd --force --name "emulator$i" --device "${EMULATOR_DEVICE}" --package "${EMULATOR_PACKAGE}"
96-
CONFIG_FILE="$HOME/.android/avd/emulator$i.avd/config.ini"
9797

98+
# Configure RAM for each AVD
99+
local config_file="$HOME/.android/avd/emulator$i.avd/config.ini"
98100
if [[ "$OSTYPE" == "darwin"* ]]; then
99-
# Mac: 9 emulators @ 2GB each
100-
sed -i '' 's/^hw\.ramSize=.*/hw.ramSize=2048/' "$CONFIG_FILE"
101+
sed -i '' "s/^hw\.ramSize=.*/hw.ramSize=${RAM_SIZE}/" "$config_file"
101102
else
102-
# Linux: Keep original 4GB
103-
sed -i 's/^hw\.ramSize=.*/hw.ramSize=4192/' "$CONFIG_FILE"
103+
sed -i "s/^hw\.ramSize=.*/hw.ramSize=${RAM_SIZE}/" "$config_file"
104104
fi
105105
done
106106
}
107107

108108
function start_for_snapshots() {
109109
for i in $(seq 1 $EMULATOR_COUNT)
110110
do
111-
if [[ "$OSTYPE" == "darwin"* ]]; then
112-
# Mac: Not headless
113-
$EMULATOR_BIN @emulator$i -no-snapshot-load &
114-
else
115-
# Linux: Keep as-is with display
116-
DISPLAY=:0 $EMULATOR_BIN @emulator$i -gpu host -accel on -no-snapshot-load &
117-
fi
111+
$EMULATOR_BIN @emulator$i -gpu host -accel on -no-snapshot-load &
118112
sleep 20
119113
done
120114
}
@@ -131,11 +125,7 @@ function force_save_snapshots() {
131125
}
132126

133127
function killall_emulators() {
134-
if [[ "$OSTYPE" == "darwin"* ]]; then
135-
killall qemu-system-aarch64-headless 2>/dev/null || true
136-
else
137-
killall qemu-system-x86_64 2>/dev/null || true
138-
fi
128+
killall "$EMULATOR_PROCESS" 2>/dev/null || true
139129
}
140130

141131

0 commit comments

Comments
 (0)