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 31, 2024
1 parent b9848cc commit 02d2aa7
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 1 deletion.
78 changes: 77 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ variables:
KUBERNETES_MEMORY_REQUEST: "8Gi"
KUBERNETES_MEMORY_LIMIT: "16Gi"

EMULATOR_NAME: "android_emulator"
ANDROID_ARCH: "arm64-v8a"
ANDROID_API: "34"
ANDROID_SDK_VERSION: "commandlinetools-mac-11076708_latest"

stages:
- ci-image
- security
Expand All @@ -26,6 +31,34 @@ stages:
- publish
- notify

.snippets:
install-android-sdk:
- curl -sSL -o commandlinetools.zip https://dl.google.com/android/repository/$ANDROID_SDK_VERSION.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/"
- export ANDROID_SDK_ROOT="$HOME/android_sdk/"
- echo y | ~/android_sdk/cmdline-tools/latest/bin/sdkmanager --install "emulator"
- echo y | ~/android_sdk/cmdline-tools/latest/bin/sdkmanager --install "platform-tools"
- echo y | ~/android_sdk/cmdline-tools/latest/bin/sdkmanager --install "$ANDROID_PLATFORM"
- echo y | ~/android_sdk/cmdline-tools/latest/bin/sdkmanager --install "$ANDROID_BUILD_TOOLS"
- echo y | ~/android_sdk/cmdline-tools/latest/bin/sdkmanager --install "$ANDROID_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 "$ANDROID_EMULATOR_IMAGE"
run-instrumented-integration:
- $ANDROID_HOME/emulator/emulator -avd "$EMULATOR_NAME" -grpc-use-jwt -no-snapstorage -no-audio -no-window -no-boot-anim -verbose -qemu -machine virt &
- GRADLE_OPTS="-Xmx3072m" ./gradlew :instrumented:integration:assembleDebug :instrumented:integration:assembleDebugAndroidTest --stacktrace --no-daemon
- ./android-wait-for-emulator.sh
- set +e
- $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
- $ANDROID_HOME/platform-tools/adb shell am instrument -w com.datadog.android.sdk.integration.test/androidx.test.runner.AndroidJUnitRunner
- $ANDROID_HOME/platform-tools/adb emu kill

# CI IMAGE

ci-image:
Expand Down Expand Up @@ -115,7 +148,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 @@ -211,6 +243,50 @@ test-pyramid:single-fit-trace:
reports:
junit: "**/build/test-results/testReleaseUnitTest/*.xml"

# RUN INSTRUMENTED TESTS ON MIN API (21), LATEST API (34) and MEDIAN API (28)

test-pyramid:instrumented-legacy-min-api:
tags: [ "macos:sonoma" ]
image: $CI_IMAGE_DOCKER
stage: test-pyramid
timeout: 1h
variables:
ANDROID_API: "21"
ANDROID_EMULATOR_IMAGE: "system-images;android-$ANDROID_API;google_apis;${ANDROID_ARCH}"
ANDROID_PLATFORM: "platforms;android-$ANDROID_API"
ANDROID_BUILD_TOOLS: "build-tools;$ANDROID_API.0.0"
script:
- !reference [.snippets, install-android-sdk]
- !reference [.snippets, run-instrumented-integration]

test-pyramid:instrumented-legacy-latest-api:
tags: [ "macos:sonoma" ]
image: $CI_IMAGE_DOCKER
stage: test-pyramid
timeout: 1h
variables:
ANDROID_API: "34"
ANDROID_EMULATOR_IMAGE: "system-images;android-$ANDROID_API;google_apis;${ANDROID_ARCH}"
ANDROID_PLATFORM: "platforms;android-$ANDROID_API"
ANDROID_BUILD_TOOLS: "build-tools;$ANDROID_API.0.0"
script:
- !reference [.snippets, install-android-sdk]
- !reference [.snippets, run-instrumented-integration]

test-pyramid:instrumented-legacy-median-api:
tags: [ "macos:sonoma" ]
image: $CI_IMAGE_DOCKER
stage: test-pyramid
timeout: 1h
variables:
ANDROID_API: "28"
ANDROID_EMULATOR_IMAGE: "system-images;android-$ANDROID_API;google_apis;${ANDROID_ARCH}"
ANDROID_PLATFORM: "platforms;android-$ANDROID_API"
ANDROID_BUILD_TOOLS: "build-tools;$ANDROID_API.0.0"
script:
- !reference [.snippets, install-android-sdk]
- !reference [.snippets, run-instrumented-integration]

test-pyramid:publish-e2e-synthetics:
tags: [ "arch:amd64" ]
image: $CI_IMAGE_DOCKER
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 <ralf@embarkmobile.com>, 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 02d2aa7

Please sign in to comment.