Skip to content

Commit

Permalink
Merge pull request #1688 from DataDog/xgouchet/RUM-1493/upload_sample…
Browse files Browse the repository at this point in the history
…_app_synthetics

RUM-1493 add ci task to update E2E sample app
  • Loading branch information
xgouchet authored Nov 7, 2023
2 parents fd22c1f + 23aaccf commit fd0cae0
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 12 deletions.
25 changes: 24 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include:
# SETUP

variables:
CURRENT_CI_IMAGE: "4"
CURRENT_CI_IMAGE: "5"
CI_IMAGE_DOCKER: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/dd-sdk-android:$CURRENT_CI_IMAGE
GIT_DEPTH: 5

Expand Down Expand Up @@ -203,6 +203,29 @@ test-pyramid:single-fit-trace:
- rm -rf ~/.gradle/daemon/
- GRADLE_OPTS="-Xmx3072m" ./gradlew :reliability:single-fit:trace:testReleaseUnitTest --stacktrace --no-daemon --build-cache --gradle-user-home cache/


test-pyramid:publish-e2e-synthetics:
tags: [ "runner:main" ]
image: $CI_IMAGE_DOCKER
stage: test-pyramid
timeout: 1h
only:
- develop
script:
- mkdir -p ./config/
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.keystore --with-decryption --query "Parameter.Value" --out text | base64 -d > ./sample-android.keystore
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.e2e_config_json --with-decryption --query "Parameter.Value" --out text > ./config/us1.json
- export E2E_STORE_PASSWD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.keystore-password --with-decryption --query "Parameter.Value" --out text)
- 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 :sample:kotlin:packageUs1Release --stacktrace --no-daemon
- npm update -g @datadog/datadog-ci
- echo "Using datadog-ci $(npx @datadog/datadog-ci version)"
- npx @datadog/datadog-ci synthetics upload-application --appKey "$E2E_DD_APP_KEY" --apiKey "$E2E_DD_API_KEY" --mobileApp "sample/kotlin/build/outputs/apk/us1/release/kotlin-us1-release.apk" --mobileApplicationId "$E2E_MOBILE_APP_ID" --versionName "$CI_COMMIT_SHORT_SHA" --latest

# PUBLISH ARTIFACTS ON MAVEN

publish:release-core:
Expand Down
21 changes: 12 additions & 9 deletions Dockerfile.gitlab
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ ENV PATH $PATH:$GRADLE_HOME/bin
ENV PATH $PATH:$ANDROID_HOME/platform-tools
ENV PATH $PATH:$ANDROID_SDK_ROOT/build-tools/${ANDROID_BUILD_TOOLS}:$ANDROID_NDK

# Woke
ENV WOKE_VERSION "0.6.0"
ENV WOKE_SHA256 "ea5605d4242b93d9586a21878264dd8abcf64ed92f0f6538ea831d9d3215b883"

RUN curl -L https://github.com/get-woke/woke/releases/download/v${WOKE_VERSION}/woke-${WOKE_VERSION}-linux-amd64.tar.gz -o woke-linux-amd64.tar.gz \
&& echo "${WOKE_SHA256} woke-linux-amd64.tar.gz" | sha256sum -c \
&& tar -xf woke-linux-amd64.tar.gz \
&& mv woke-${WOKE_VERSION}-linux-amd64/woke /usr/bin/woke \
&& rm -Rf woke-${WOKE_VERSION}-linux-amd64 woke-${WOKE_VERSION}-linux-amd64.tar.gz
# Install Node
ENV NODENV_VERSION 16.13.0
ENV NODENV_ROOT /root/.nodenv
ENV PATH "$NODENV_ROOT/shims:$NODENV_ROOT/bin:$PATH"
RUN set -x \
&& curl -fsSL https://github.com/nodenv/nodenv-installer/raw/master/bin/nodenv-installer | bash \
&& nodenv install $NODENV_VERSION \
&& nodenv rehash

# Install Datadog CI
RUN npm install -g npm@9.6.5
RUN npm install -g @datadog/datadog-ci
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2016-Present Datadog, Inc.
#
org.gradle.jvmargs=-Xmx3072m
org.gradle.jvmargs=-Xmx4096m
android.useAndroidX=true
# Leave the next line blank for CI
26 changes: 26 additions & 0 deletions sample/kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sqldelight {
}
}

@Suppress("StringLiteralDuplication")
android {
compileSdk = AndroidConfig.TARGET_SDK
buildToolsVersion = AndroidConfig.BUILD_TOOLS_VERSION
Expand Down Expand Up @@ -111,6 +112,31 @@ android {
}
}
ndkVersion = Dependencies.Versions.Ndk

val e2ePassword = System.getenv("E2E_STORE_PASSWD")
signingConfigs {
if (e2ePassword != null) {
create("release") {
storeFile = File(project.rootDir, "sample-android.keystore")
storePassword = e2ePassword
keyAlias = "dd-sdk-android"
keyPassword = e2ePassword
}
}
}

buildTypes {
getByName("debug") {
isMinifyEnabled = false
}

getByName("release") {
isMinifyEnabled = false
if (e2ePassword != null) {
signingConfig = signingConfigs.getByName("release")
}
}
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal object Preferences {
fun getTrackingConsent(): TrackingConsent {
val consentId = PreferenceManager
.getDefaultSharedPreferences(applicationContext)
.getInt(PREF_TRACKING_CONSENT, CONSENT_PENDING)
.getInt(PREF_TRACKING_CONSENT, CONSENT_GRANTED)
return resolveConsentFromId(consentId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import android.util.Log
import androidx.lifecycle.ViewModelProvider
import com.datadog.android.Datadog
import com.datadog.android.DatadogSite
import com.datadog.android.core.configuration.BatchSize
import com.datadog.android.core.configuration.Configuration
import com.datadog.android.core.configuration.UploadFrequency
import com.datadog.android.core.sampling.RateBasedSampler
import com.datadog.android.event.EventMapper
import com.datadog.android.log.Logger
Expand Down Expand Up @@ -240,6 +242,8 @@ class SampleApplication : Application() {
variant = BuildConfig.FLAVOR
)
.setFirstPartyHosts(tracedHosts)
.setBatchSize(BatchSize.SMALL)
.setUploadFrequency(UploadFrequency.FREQUENT)

try {
configBuilder.useSite(DatadogSite.valueOf(BuildConfig.DD_SITE_NAME))
Expand Down

0 comments on commit fd0cae0

Please sign in to comment.