Skip to content

Commit

Permalink
RUM-483 use macos runner
Browse files Browse the repository at this point in the history
  • Loading branch information
xgouchet committed Jul 29, 2024
1 parent 4a3bc9f commit 89e7075
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
34 changes: 33 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ variables:
KUBERNETES_MEMORY_REQUEST: "8Gi"
KUBERNETES_MEMORY_LIMIT: "16Gi"

EMULATOR_NAME: "android_emulator"
ANDROID_ARCH: "x86_64"
EMULATOR_IMAGE: "system-images;android-34;google_apis;${ANDROID_ARCH}"

stages:
- ci-image
- security
Expand All @@ -26,6 +30,21 @@ stages:
- publish
- notify

.snippets:
install-android-sdk:
- curl -sSL -o commandlinetools.zip https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip
- rm -rf ~/android_sdk
- rm -rf ~/cmdline-tools
- unzip -q commandlinetools -d ~/
- mkdir -p ~/android_sdk/cmdline-tools/latest
- mv ~/cmdline-tools/* ~/android_sdk/cmdline-tools/latest
- rm ./commandlinetools.zip
- export ANDROID_HOME="$HOME/android_sdk/"
- echo y | ~/android_sdk/cmdline-tools/latest/bin/sdkmanager --install "emulator"
- echo y | ~/android_sdk/cmdline-tools/latest/bin/sdkmanager --install "$EMULATOR_IMAGE"
- yes | ~/android_sdk/cmdline-tools/latest/bin/sdkmanager --licenses || true
- echo "no" | ~/android_sdk/cmdline-tools/latest/bin/avdmanager --verbose create avd --force --name "$EMULATOR_NAME" --package "$EMULATOR_IMAGE"

# CI IMAGE

ci-image:
Expand Down Expand Up @@ -115,7 +134,6 @@ test:tools:
- export DD_AGENT_HOST="$BUILDENV_HOST_IP"
- GRADLE_OPTS="-Xmx3072m" ./gradlew :unitTestTools --stacktrace --no-daemon --build-cache --gradle-user-home cache/


test:kover:
tags: [ "arch:amd64" ]
image: $CI_IMAGE_DOCKER
Expand Down Expand Up @@ -145,6 +163,20 @@ test:kover:
paths:
- "*.hprof"

test:instrumented-legacy:
tags: [ "macos:sonoma" ]
image: $CI_IMAGE_DOCKER
stage: test
timeout: 1h
script:
- !reference [.snippets, install-android-sdk]
- java --version
- $ANDROID_HOME/emulator/emulator -avd "$EMULATOR_NAME" -grpc-use-jwt -no-snapstorage -no-audio -no-window -qemu -machine virt &
- GRADLE_OPTS="-Xmx3072m" ./gradlew :instrumented:integration:assembleDebug :instrumented:integration:assembleDebugAndroidTest --stacktrace --no-daemon
- ./android-wait-for-emulator.sh
- $ANDROID_HOME/platform-tools/adb install -t -d -g -r instrumented/integration/build/outputs/apk/androidTest/debug/integration-debug-androidTest.apk
- $ANDROID_HOME/platform-tools/adb install -t -d -g -r instrumented/integration/build/outputs/apk/debug/integration-debug.apk

# TEST PYRAMID
# the steps in this section should reflect our test pyramid strategy

Expand Down
25 changes: 25 additions & 0 deletions android-wait-for-emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Originally written by Ralf Kistner <[email protected]>, but placed in the public domain

set +e

bootanim=""
failcounter=0
timeout_in_sec=360

until [[ "$bootanim" =~ "stopped" ]]; do
bootanim=`adb -e shell getprop init.svc.bootanim 2>&1 &`
if [[ "$bootanim" =~ "device not found" || "$bootanim" =~ "device offline"
|| "$bootanim" =~ "running" ]]; then
let "failcounter += 1"
echo "Waiting for emulator to start"
if [[ $failcounter -gt timeout_in_sec ]]; then
echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator"
exit 1
fi
fi
sleep 1
done

echo "Emulator is ready"
3 changes: 3 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ gradlePlugin {
}
}

java.targetCompatibility = JavaVersion.VERSION_17
java.sourceCompatibility = JavaVersion.VERSION_17

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
#
org.gradle.jvmargs=-Xmx4096m
android.useAndroidX=true

# Allows Kotlin with target JVM compat 17 to be built on JDK 21
kotlin.jvm.target.validation.mode = IGNORE
# Leave the next line blank for CI

0 comments on commit 89e7075

Please sign in to comment.