Skip to content

Commit

Permalink
RUM-3861 Update testing ci steps to limit OOM and memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
xgouchet committed Apr 15, 2024
1 parent ebf7542 commit 7bf4beb
Show file tree
Hide file tree
Showing 32 changed files with 52 additions and 162 deletions.
21 changes: 0 additions & 21 deletions .codecov.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

# Manually build the java bytecode
- name: Execute Gradle build
run: ./gradlew assembleLibraries
run: ./gradlew assembleLibrariesRelease

# Perform the analysis
- name: Perform CodeQL Analysis
Expand Down
35 changes: 26 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ static-analysis:
stage: analysis
variables:
DETEKT_PUBLIC_API: "true"
DETEKT_CUSTOM_RULES_BUILD_TASK: "assembleLibraries :tools:detekt:jar"
DETEKT_CUSTOM_RULES_BUILD_TASK: "assembleLibrariesRelease :tools:detekt:jar"
DETEKT_CUSTOM_RULES_JAR_PATH: "tools/detekt/build/libs/detekt.jar"
DETEKT_CUSTOM_RULES_YML_PATH: "detekt_custom.yml"
DETEKT_GENERATE_CLASSPATH_BUILD_TASK: "printSdkDebugRuntimeClasspath"
DETEKT_CLASSPATH_FILE_PATH: "sdk_classpath"
FLAVORED_ANDROID_LINT: ":tools:lint:lint :sample:kotlin:lintUs1Release :sample:wear:lintUs1Release"
FLAVORED_ANDROID_LINT: ":tools:lint:lint"
trigger:
include: "https://gitlab-templates.ddbuild.io/mobile/v25558398-8517309a/static-analysis.yml"
strategy: depend
Expand Down Expand Up @@ -104,18 +104,23 @@ test:debug:
script:
- rm -rf ~/.gradle/daemon/
- export DD_AGENT_HOST="$BUILDENV_HOST_IP"
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:debug" ./gradlew :unitTestDebug --stacktrace --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:debug" ./gradlew :dd-sdk-android-core:testDebugUnitTest --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG -Dorg.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:debug" ./gradlew :unitTestDebugFeatures --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG -Dorg.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:debug" ./gradlew :unitTestDebugIntegrations --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG -Dorg.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError
artifacts:
when: always
expire_in: 1 week
reports:
junit: "**/build/test-results/testDebugUnitTest/*.xml"
paths:
- "*.hprof"

test:release:
tags: [ "arch:amd64" ]
image: $CI_IMAGE_DOCKER
stage: test
timeout: 1h
when: manual
cache:
key: $CI_COMMIT_REF_SLUG
paths:
Expand All @@ -125,12 +130,16 @@ test:release:
script:
- rm -rf ~/.gradle/daemon/
- export DD_AGENT_HOST="$BUILDENV_HOST_IP"
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:release" ./gradlew :unitTestRelease --stacktrace --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:release" ./gradlew :dd-sdk-android-core:testReleaseUnitTest --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG -Dorg.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:release" ./gradlew :unitTestReleaseFeatures --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG -Dorg.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:release" ./gradlew :unitTestReleaseIntegrations --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG -Dorg.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError
artifacts:
when: always
expire_in: 1 week
reports:
junit: "**/build/test-results/testReleaseUnitTest/*.xml"
paths:
- "*.hprof"

test:tools:
tags: [ "arch:amd64" ]
Expand All @@ -146,7 +155,8 @@ test:tools:
script:
- rm -rf ~/.gradle/daemon/
- export DD_AGENT_HOST="$BUILDENV_HOST_IP"
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:jvmRelease" ./gradlew :unitTestTools --stacktrace --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG
- GRADLE_OPTS="-Xmx3072m" ./gradlew :unitTestTools --stacktrace --no-daemon --build-cache --gradle-user-home cache/


test:kover:
tags: [ "arch:amd64" ]
Expand All @@ -165,10 +175,17 @@ test:kover:
- export DD_API_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.api_key --with-decryption --query "Parameter.Value" --out text)
- export DD_APP_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.app_key --with-decryption --query "Parameter.Value" --out text)
- CODECOV_TOKEN=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.codecov-token --with-decryption --query "Parameter.Value" --out text)
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:release" ./gradlew :koverReportAll --stacktrace --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG
- python3 ddcoverage.py --prefix dd-sdk-android
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:release" ./gradlew :dd-sdk-android-core:koverXmlReportRelease --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG -Dorg.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:release" ./gradlew :koverReportFeatures --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG -Dorg.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError
- GRADLE_OPTS="-Xmx3072m" DD_TAGS="test.configuration.variant:release" ./gradlew :koverReportIntegrations --no-daemon --build-cache --gradle-user-home cache/ -Dorg.gradle.jvmargs=-javaagent:$DD_TRACER_FOLDER/dd-java-agent.jar=$DD_COMMON_AGENT_CONFIG -Dorg.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError
- bash <(cat ./codecov.sh) -t $CODECOV_TOKEN

artifacts:
when: always
expire_in: 1 week
reports:
junit: "**/build/test-results/testReleaseUnitTest/*.xml"
paths:
- "*.hprof"

# TEST PYRAMID
# the steps in this section should reflect our test pyramid strategy
Expand Down Expand Up @@ -252,7 +269,7 @@ test-pyramid:publish-e2e-synthetics:
- export E2E_DD_API_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.e2e_api_key --with-decryption --query "Parameter.Value" --out text)
- export E2E_DD_APP_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.e2e_app_key --with-decryption --query "Parameter.Value" --out text)
- export E2E_MOBILE_APP_ID=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.e2e_mobile_app_id --with-decryption --query "Parameter.Value" --out text)
- GRADLE_OPTS="-Xmx4096M" ./gradlew assembleLibraries --stacktrace --no-daemon
- GRADLE_OPTS="-Xmx4096M" ./gradlew assembleLibrariesRelease --stacktrace --no-daemon
- GRADLE_OPTS="-Xmx4096M" ./gradlew :sample:kotlin:packageUs1Release --stacktrace --no-daemon
- npm update -g @datadog/datadog-ci
- echo "Using datadog-ci $(npx @datadog/datadog-ci version)"
Expand Down
21 changes: 18 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/
@file:Suppress("StringLiteralDuplication")

import com.android.build.gradle.LibraryExtension
import com.datadog.gradle.config.AndroidConfig
Expand Down Expand Up @@ -66,20 +67,32 @@ tasks.register("checkAll") {
dependsOn(
"lintCheckAll",
"unitTestAll",
"koverReportAll",
"instrumentTestAll"
)
}

registerSubModuleAggregationTask("assembleLibraries", "assemble")
registerSubModuleAggregationTask("assembleLibrariesDebug", "assembleDebug")
registerSubModuleAggregationTask("assembleLibrariesRelease", "assembleRelease")

registerSubModuleAggregationTask("unitTestRelease", "testReleaseUnitTest")
registerSubModuleAggregationTask("unitTestReleaseFeatures", "testReleaseUnitTest", ":features:")
registerSubModuleAggregationTask("unitTestReleaseIntegrations", "testReleaseUnitTest", ":integrations:")

registerSubModuleAggregationTask("unitTestDebug", "testDebugUnitTest")
registerSubModuleAggregationTask("unitTestDebugFeatures", "testDebugUnitTest", ":features:")
registerSubModuleAggregationTask("unitTestDebugIntegrations", "testDebugUnitTest", ":integrations:")

tasks.register("unitTestTools") {
tasks.register("assembleSampleRelease") {
dependsOn(
":sample:kotlin:assembleUs1Release",
":sample:wear:assembleUs1Release",
":sample:vendor-lib:assembleRelease",
":sample:vendor-lib:assembleRelease"
)
}

tasks.register("unitTestTools") {
dependsOn(
":tools:unit:testJvmReleaseUnitTest",
":tools:detekt:test",
":tools:lint:test",
Expand Down Expand Up @@ -110,6 +123,8 @@ tasks.register("checkGeneratedFiles") {
}

registerSubModuleAggregationTask("koverReportAll", "koverXmlReportRelease")
registerSubModuleAggregationTask("koverReportFeatures", "koverXmlReportRelease", ":features:")
registerSubModuleAggregationTask("koverReportIntegrations", "koverXmlReportRelease", ":integrations:")

tasks.register("instrumentTestAll") {
dependsOn(":instrumented:integration:connectedCheck")
Expand Down
1 change: 0 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ dependencies {
implementation(libs.dokkaGradlePlugin)
implementation(libs.mavenModel)
implementation(libs.nexusPublishGradlePlugin)
implementation(libs.kover)

// check api surface
implementation(libs.kotlinGrammarParser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ import org.gradle.api.Task
fun Project.registerSubModuleAggregationTask(
taskName: String,
subModuleTaskName: String,
subModulePathPrefix: String = ":",
subModuleNamePrefix: String = "dd-sdk-android-",
additionalConfiguration: Task.() -> Unit = {}
) {
tasks.register(taskName) {
project.subprojects.forEach { subProject ->
if (subProject.name.startsWith(subModuleNamePrefix)) {
println("SubProject ${subProject.name} / ${subProject.path}")
if (subProject.name.startsWith(subModuleNamePrefix) &&
subProject.path.startsWith(subModulePathPrefix)
) {
dependsOn("${subProject.path}:$subModuleTaskName")
}
}
Expand Down
1 change: 0 additions & 1 deletion dd-sdk-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ plugins {

// Tests
id("de.mobilej.unmock")
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
Expand Down
77 changes: 0 additions & 77 deletions ddcoverage.py

This file was deleted.

1 change: 0 additions & 1 deletion features/dd-sdk-android-logs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ plugins {

// Tests
id("de.mobilej.unmock")
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
Expand Down
3 changes: 0 additions & 3 deletions features/dd-sdk-android-ndk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ plugins {
// Analysis tools
id("com.github.ben-manes.versions")

// Tests
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
id("apiSurface")
Expand Down
1 change: 0 additions & 1 deletion features/dd-sdk-android-rum/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ plugins {

// Tests
id("de.mobilej.unmock")
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ plugins {
// Analysis tools
id("com.github.ben-manes.versions")

// Tests
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
id("apiSurface")
Expand Down
1 change: 0 additions & 1 deletion features/dd-sdk-android-session-replay/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ plugins {
id("com.github.ben-manes.versions")

// Tests
id("org.jetbrains.kotlinx.kover")
id("de.mobilej.unmock")

// Internal Generation
Expand Down
1 change: 0 additions & 1 deletion features/dd-sdk-android-trace/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ plugins {

// Tests
id("de.mobilej.unmock")
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
Expand Down
1 change: 0 additions & 1 deletion features/dd-sdk-android-webview/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ plugins {

// Tests
id("de.mobilej.unmock")
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ espresso = "3.5.1"
assertJ = "3.18.1"
elmyr = "1.3.1"
mockitoKotlin = "5.1.0"
kover = "0.7.6"
kspTesting = "1.5.0"

# Tools
Expand Down Expand Up @@ -169,7 +168,6 @@ elmyrJUnit5 = { module = "com.github.xgouchet.Elmyr:junit5", version.ref = "elmy
elmyrJVM = { module = "com.github.xgouchet.Elmyr:jvm", version.ref = "elmyr" }
mockitoKotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockitoKotlin" }
kotlinReflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
kover = { module = "org.jetbrains.kotlinx:kover-gradle-plugin", version.ref = "kover" }
kspTesting = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version.ref = "kspTesting" }
androidLintTests = { module = "com.android.tools.lint:lint-tests", version.ref = "androidLint" }

Expand Down
3 changes: 0 additions & 3 deletions integrations/dd-sdk-android-coil/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ plugins {
// Analysis tools
id("com.github.ben-manes.versions")

// Tests
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
id("apiSurface")
Expand Down
1 change: 0 additions & 1 deletion integrations/dd-sdk-android-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ plugins {

// Tests
id("de.mobilej.unmock")
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
Expand Down
3 changes: 0 additions & 3 deletions integrations/dd-sdk-android-fresco/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ plugins {
// Analysis tools
id("com.github.ben-manes.versions")

// Tests
id("org.jetbrains.kotlinx.kover")

// Internal Generation
id("thirdPartyLicences")
id("apiSurface")
Expand Down
Loading

0 comments on commit 7bf4beb

Please sign in to comment.