Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUM-483 use macos runner #2154

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 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,33 @@ 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work okay if the emulator already exists? I assume that's what the echo "no" is for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in theory the emulator can't exist before hand, the no is there to prevent creating a backup of the data between emulator runs

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
- 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 +147,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 +242,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
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