Skip to content

Commit 9bdb409

Browse files
authored
Merge branch 'master' into bdu/testing-framework-test-convention
2 parents a11fb7c + 6a0c378 commit 9bdb409

File tree

199 files changed

+2880
-1680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+2880
-1680
lines changed

.github/workflows/create-release-branch.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Create Release Branch and Pin System-Tests
33
on:
44
push:
55
tags:
6-
- 'v[0-9]+.[0-9]+.0' # Trigger on minor release tags (e.g. v1.54.0)
6+
- 'v[0-9]+.[0-9]+.0' # Trigger on minor release tags (e.g. v1.54.0)
77
workflow_dispatch:
88
inputs:
99
tag:
@@ -15,8 +15,7 @@ jobs:
1515
create-release-branch:
1616
runs-on: ubuntu-latest
1717
permissions:
18-
# contents: write # Allow pushing the empty release branch
19-
contents: read
18+
contents: write # Allow pushing the empty release branch
2019
id-token: write # Required for OIDC token federation
2120
steps:
2221
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
@@ -25,8 +24,14 @@ jobs:
2524
scope: DataDog/dd-trace-java
2625
policy: self.update-system-tests.create-pr
2726

28-
- name: Checkout dd-trace-java at tag
27+
- name: Checkout dd-trace-java master branch
2928
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
29+
with:
30+
ref: master
31+
32+
- name: Get head SHA of master branch
33+
id: get-head-sha
34+
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
3035

3136
- name: Determine tag
3237
id: determine-tag
@@ -90,7 +95,7 @@ jobs:
9095
with:
9196
token: "${{ steps.octo-sts.outputs.token }}"
9297
branch: "${{ steps.define-temp-branch.outputs.temp-branch }}"
93-
head-sha: "${{ github.sha }}"
98+
head-sha: "${{ steps.get-head-sha.outputs.sha }}"
9499
create-branch: true
95100
command: push
96101
commits: "${{ steps.create-commit.outputs.commit }}"

.gitlab-ci.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ default:
132132
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}base
133133
stage: build
134134
variables:
135-
MAVEN_OPTS: "-Xms64M -Xmx512M"
135+
MAVEN_OPTS: "-Xms256M -Xmx1024M"
136136
GRADLE_WORKERS: 2
137-
GRADLE_MEM: 2560M
137+
GRADLE_MEM: 3G
138138
KUBERNETES_CPU_REQUEST: 8
139-
KUBERNETES_MEMORY_REQUEST: 8Gi
140-
KUBERNETES_MEMORY_LIMIT: 8Gi
139+
KUBERNETES_MEMORY_REQUEST: 10Gi
140+
KUBERNETES_MEMORY_LIMIT: 10Gi
141141
CACHE_TYPE: "lib" #default
142142
FF_USE_FASTZIP: "true"
143143
CACHE_COMPRESSION_LEVEL: "slowest"
@@ -289,8 +289,7 @@ build_tests:
289289
CACHE_TYPE: "latestdep"
290290
- GRADLE_TARGET: ":smokeTest"
291291
CACHE_TYPE: "smoke"
292-
MAVEN_OPTS: "-Xms64M -Xmx512M"
293-
292+
MAVEN_OPTS: "-Xms256M -Xmx1024M"
294293
script:
295294
- *gitlab_base_ref_params
296295
- ./gradlew --version

.gitlab/benchmarks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ check-big-regressions:
7171
needs:
7272
- job: benchmarks-startup
7373
artifacts: true
74-
- job: benchmarks-load
74+
- job: benchmarks-dacapo
7575
artifacts: true
7676
when: on_success
7777
tags: ["arch:amd64"]
@@ -86,7 +86,7 @@ check-big-regressions:
8686
script:
8787
- !reference [ .benchmarks, script ]
8888
- |
89-
for benchmarkType in startup load; do
89+
for benchmarkType in startup dacapo; do
9090
find "$ARTIFACTS_DIR/$benchmarkType" -name "benchmark-baseline.json" -o -name "benchmark-candidate.json" | while read file; do
9191
relpath="${file#$ARTIFACTS_DIR/$benchmarkType/}"
9292
prefix="${relpath%/benchmark-*}" # Remove the trailing /benchmark-(baseline|candidate).json

.mvn/wrapper/MavenWrapperDownloader.java

Lines changed: 0 additions & 118 deletions
This file was deleted.

.mvn/wrapper/maven-wrapper.jar

-49.5 KB
Binary file not shown.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2-
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.9/apache-maven-3.8.9-bin.zip

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66
id("datadog.dependency-locking")
77
id("datadog.tracer-version")
88
id("datadog.dump-hanged-test")
9+
id("config-inversion-linter")
910
id("datadog.ci-jobs")
1011

1112
id("com.diffplug.spotless") version "6.13.0"

buildSrc/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ dependencies {
6464
implementation("org.apache.maven", "maven-aether-provider", "3.3.9")
6565

6666
implementation("com.github.zafarkhaja:java-semver:0.10.2")
67+
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")
6768

6869
implementation("com.google.guava", "guava", "20.0")
6970
implementation(libs.asm)
@@ -86,8 +87,8 @@ testing {
8687
suites {
8788
val test by getting(JvmTestSuite::class) {
8889
dependencies {
89-
implementation(libs.spock.core)
9090
implementation(libs.groovy)
91+
implementation(libs.spock.core)
9192
}
9293
targets.configureEach {
9394
testTask.configure {

buildSrc/call-site-instrumentation-plugin/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ dependencies {
3535
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")
3636

3737
testImplementation(libs.bytebuddy)
38-
testImplementation(libs.spock.core)
39-
testImplementation("org.objenesis", "objenesis", "3.0.1")
4038
testImplementation(libs.groovy)
39+
testImplementation(libs.bundles.spock)
4140
testImplementation("javax.servlet", "javax.servlet-api", "3.0.1")
4241
testImplementation("com.github.spotbugs", "spotbugs-annotations", "4.2.0")
4342
}

buildSrc/src/main/kotlin/datadog/gradle/plugin/config/ConfigInversionLinter.kt

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
package datadog.gradle.plugin.config
22

3+
import com.github.javaparser.ParserConfiguration
4+
import com.github.javaparser.StaticJavaParser
5+
import com.github.javaparser.ast.CompilationUnit
6+
import com.github.javaparser.ast.expr.StringLiteralExpr
7+
import com.github.javaparser.ast.nodeTypes.NodeWithModifiers
8+
import com.github.javaparser.ast.Modifier
9+
import com.github.javaparser.ast.body.FieldDeclaration
10+
import com.github.javaparser.ast.body.VariableDeclarator
311
import org.gradle.api.Plugin
412
import org.gradle.api.Project
513
import org.gradle.api.GradleException
@@ -14,6 +22,7 @@ class ConfigInversionLinter : Plugin<Project> {
1422
val extension = target.extensions.create("supportedTracerConfigurations", SupportedTracerConfigurations::class.java)
1523
registerLogEnvVarUsages(target, extension)
1624
registerCheckEnvironmentVariablesUsage(target)
25+
registerCheckConfigStringsTask(target, extension)
1726
}
1827
}
1928

@@ -124,3 +133,93 @@ private fun registerCheckEnvironmentVariablesUsage(project: Project) {
124133
}
125134
}
126135
}
136+
137+
// Helper functions for checking Config Strings
138+
private fun normalize(configValue: String) =
139+
"DD_" + configValue.uppercase().replace("-", "_").replace(".", "_")
140+
141+
// Checking "public" "static" "final"
142+
private fun NodeWithModifiers<*>.hasModifiers(vararg mods: Modifier.Keyword) =
143+
mods.all { hasModifier(it) }
144+
145+
/** Registers `checkConfigStrings` to validate config definitions against documented supported configurations. */
146+
private fun registerCheckConfigStringsTask(project: Project, extension: SupportedTracerConfigurations) {
147+
val ownerPath = extension.configOwnerPath
148+
val generatedFile = extension.className
149+
150+
project.tasks.register("checkConfigStrings") {
151+
group = "verification"
152+
description = "Validates that all config definitions in `dd-trace-api/src/main/java/datadog/trace/api/config` exist in `metadata/supported-configurations.json`"
153+
154+
val mainSourceSetOutput = ownerPath.map {
155+
project.project(it)
156+
.extensions.getByType<SourceSetContainer>()
157+
.named(SourceSet.MAIN_SOURCE_SET_NAME)
158+
.map { main -> main.output }
159+
}
160+
inputs.files(mainSourceSetOutput)
161+
162+
doLast {
163+
val repoRoot: Path = project.rootProject.projectDir.toPath()
164+
val configDir = repoRoot.resolve("dd-trace-api/src/main/java/datadog/trace/api/config").toFile()
165+
166+
if (!configDir.exists()) {
167+
throw GradleException("Config directory not found: ${configDir.absolutePath}")
168+
}
169+
170+
val urls = mainSourceSetOutput.get().get().files.map { it.toURI().toURL() }.toTypedArray()
171+
val (supported, aliasMapping) = URLClassLoader(urls, javaClass.classLoader).use { cl ->
172+
val clazz = Class.forName(generatedFile.get(), true, cl)
173+
@Suppress("UNCHECKED_CAST")
174+
val supportedSet = clazz.getField("SUPPORTED").get(null) as Set<String>
175+
@Suppress("UNCHECKED_CAST")
176+
val aliasMappingMap = clazz.getField("ALIAS_MAPPING").get(null) as Map<String, String>
177+
Pair(supportedSet, aliasMappingMap)
178+
}
179+
180+
var parserConfig = ParserConfiguration()
181+
parserConfig.setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_8)
182+
183+
StaticJavaParser.setConfiguration(parserConfig)
184+
185+
val violations = buildList {
186+
configDir.listFiles()?.forEach { file ->
187+
val fileName = file.name
188+
val cu: CompilationUnit = StaticJavaParser.parse(file)
189+
190+
cu.findAll(VariableDeclarator::class.java).forEach { varDecl ->
191+
varDecl.parentNode
192+
.map { it as? FieldDeclaration }
193+
.ifPresent { field ->
194+
if (field.hasModifiers(Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC, Modifier.Keyword.FINAL) &&
195+
varDecl.typeAsString == "String") {
196+
197+
val fieldName = varDecl.nameAsString
198+
if (fieldName.endsWith("_DEFAULT")) return@ifPresent
199+
val init = varDecl.initializer.orElse(null) ?: return@ifPresent
200+
201+
if (init !is StringLiteralExpr) return@ifPresent
202+
val rawValue = init.value
203+
204+
val normalized = normalize(rawValue)
205+
if (normalized !in supported && normalized !in aliasMapping) {
206+
val line = varDecl.range.map { it.begin.line }.orElse(1)
207+
add("$fileName:$line -> Config '$rawValue' normalizes to '$normalized' " +
208+
"which is missing from '${extension.jsonFile.get()}'")
209+
}
210+
}
211+
}
212+
}
213+
}
214+
}
215+
216+
if (violations.isNotEmpty()) {
217+
logger.error("\nFound config definitions not in '${extension.jsonFile.get()}':")
218+
violations.forEach { logger.lifecycle(it) }
219+
throw GradleException("Undocumented Environment Variables found. Please add the above Environment Variables to '${extension.jsonFile.get()}'.")
220+
} else {
221+
logger.info("All config strings are present in '${extension.jsonFile.get()}'.")
222+
}
223+
}
224+
}
225+
}

0 commit comments

Comments
 (0)