Skip to content

Commit 03ac8e4

Browse files
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
2 parents b5f246e + 5f3aeab commit 03ac8e4

File tree

76 files changed

+1910
-957
lines changed

Some content is hidden

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

76 files changed

+1910
-957
lines changed

.github/chainguard/self.update-system-tests.push.sts.yaml renamed to .github/chainguard/self.update-system-tests.create-pr.sts.yaml

File renamed without changes.

.github/workflows/add-release-to-cloudfoundry.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ jobs:
5353
exit 0;
5454
fi
5555
56-
git commit -a -m "chore: Add version ${{ steps.get-release-version.outputs.VERSION }} to Cloud Foundry"
56+
git add --all
57+
git commit -m "chore: Add version ${{ steps.get-release-version.outputs.VERSION }} to Cloud Foundry"
5758
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
5859
- name: Push changes
5960
uses: DataDog/commit-headless@5a0f3876e0fbdd3a86b3e008acf4ec562db59eee # action/v2.0.1

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

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ jobs:
1515
create-release-branch:
1616
runs-on: ubuntu-latest
1717
permissions:
18-
contents: write # Allow pushing the empty release branch
18+
# contents: write # Allow pushing the empty release branch
19+
contents: read
1920
id-token: write # Required for OIDC token federation
2021
steps:
2122
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
2223
id: octo-sts
2324
with:
2425
scope: DataDog/dd-trace-java
25-
policy: self.update-system-tests.push
26+
policy: self.update-system-tests.create-pr
27+
28+
- name: Checkout dd-trace-java at tag
29+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
2630

2731
- name: Determine tag
2832
id: determine-tag
@@ -42,69 +46,63 @@ jobs:
4246
id: define-branch
4347
run: |
4448
TAG=${{ steps.determine-tag.outputs.tag }}
45-
BRANCH="release/${TAG%.0}.x"
46-
echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT"
49+
echo "branch=release/${TAG%.0}.x" >> "$GITHUB_OUTPUT"
4750
48-
- name: Checkout dd-trace-java at tag
49-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
50-
with:
51-
ref: ${{ github.sha }}
51+
# - name: Check if branch already exists
52+
# id: check-branch
53+
# run: |
54+
# BRANCH=${{ steps.define-branch.outputs.branch }}
55+
# if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then
56+
# echo "creating_new_branch=false" >> "$GITHUB_OUTPUT"
57+
# echo "Branch $BRANCH already exists - skipping following steps"
58+
# else
59+
# echo "creating_new_branch=true" >> "$GITHUB_OUTPUT"
60+
# echo "Branch $BRANCH does not exist - proceeding with following steps"
61+
# fi
5262

53-
- name: Check if branch already exists
54-
id: check-branch
55-
run: |
56-
BRANCH=${{ steps.define-branch.outputs.branch }}
57-
if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then
58-
echo "creating_new_branch=false" >> "$GITHUB_OUTPUT"
59-
echo "Branch $BRANCH already exists - skipping following steps"
60-
else
61-
echo "creating_new_branch=true" >> "$GITHUB_OUTPUT"
62-
echo "Branch $BRANCH does not exist - proceeding with following steps"
63-
fi
63+
# - name: Create and push empty release branch
64+
# if: steps.check-branch.outputs.creating_new_branch == 'true'
65+
# run: |
66+
# git checkout -b "${{ steps.define-branch.outputs.branch }}"
67+
# git push -u origin "${{ steps.define-branch.outputs.branch }}"
6468

65-
- name: Create and push empty release branch
66-
if: steps.check-branch.outputs.creating_new_branch == 'true'
67-
run: |
68-
git checkout -b "${{ steps.define-branch.outputs.branch }}"
69-
git push -u origin "${{ steps.define-branch.outputs.branch }}"
69+
- name: Update system-tests references to latest commit SHA on main
70+
# if: steps.check-branch.outputs.creating_new_branch == 'true'
71+
run: BRANCH=main ./tooling/update_system_test_reference.sh
7072

7173
- name: Define temp branch name
72-
if: steps.check-branch.outputs.creating_new_branch == 'true'
74+
# if: steps.check-branch.outputs.creating_new_branch == 'true'
7375
id: define-temp-branch
74-
run: echo "branch=ci/pin-system-tests-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
75-
76-
- name: Update system-tests references to latest commit SHA on main
77-
if: steps.check-branch.outputs.creating_new_branch == 'true'
78-
run: BRANCH=main ./tooling/update_system_test_reference.sh
76+
run: echo "temp-branch=ci/pin-system-tests-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
7977

8078
- name: Commit changes
81-
if: steps.check-branch.outputs.creating_new_branch == 'true'
79+
# if: steps.check-branch.outputs.creating_new_branch == 'true'
8280
id: create-commit
8381
run: |
8482
git config user.name "github-actions[bot]"
8583
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
8684
git commit -m "chore: Pin system-tests for release branch" .github/workflows/run-system-tests.yaml
8785
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
88-
86+
8987
- name: Push changes to temp branch
90-
if: steps.check-branch.outputs.creating_new_branch == 'true'
88+
# if: steps.check-branch.outputs.creating_new_branch == 'true'
9189
uses: DataDog/commit-headless@5a0f3876e0fbdd3a86b3e008acf4ec562db59eee # action/v2.0.1
9290
with:
9391
token: "${{ steps.octo-sts.outputs.token }}"
94-
branch: "${{ steps.define-temp-branch.outputs.branch }}"
92+
branch: "${{ steps.define-temp-branch.outputs.temp-branch }}"
9593
head-sha: "${{ github.sha }}"
9694
create-branch: true
9795
command: push
9896
commits: "${{ steps.create-commit.outputs.commit }}"
9997

10098
- name: Create pull request from temp branch to release branch
101-
if: steps.check-branch.outputs.creating_new_branch == 'true'
99+
# if: steps.check-branch.outputs.creating_new_branch == 'true'
102100
env:
103101
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}
104102
run: |
105-
gh pr create --title "Pin system-tests for ${{ steps.define-branch.outputs.branch }}" \
103+
gh pr create --title "Pin system-tests for ${{ steps.define-branch.outputs.branch }}" \
106104
--base "${{ steps.define-branch.outputs.branch }}" \
107-
--head "${{ steps.define-temp-branch.outputs.branch }}" \
105+
--head "${{ steps.define-temp-branch.outputs.temp-branch }}" \
108106
--label "tag: dependencies" \
109107
--label "tag: no release notes" \
110108
--body "This PR pins the system-tests reference for the release branch."

.github/workflows/update-gradle-dependencies.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ jobs:
5555
run: |
5656
git config user.name "github-actions[bot]"
5757
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
58-
git commit -a -m "chore: Update Gradle dependencies"
58+
git add --all
59+
git commit -m "chore: Update Gradle dependencies"
5960
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
6061
- name: Push changes
6162
uses: DataDog/commit-headless@5a0f3876e0fbdd3a86b3e008acf4ec562db59eee # action/v2.0.1

.gitlab-ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,3 +970,16 @@ create_key:
970970
expire_in: 13 mos
971971
paths:
972972
- pubkeys
973+
974+
validate_supported_configurations_local_file:
975+
extends: .validate_supported_configurations_local_file
976+
variables:
977+
LOCAL_JSON_PATH: "metadata/supported-configurations.json"
978+
979+
update_central_configurations_version_range:
980+
extends: .update_central_configurations_version_range
981+
variables:
982+
LOCAL_REPO_NAME: "dd-trace-java"
983+
LOCAL_JSON_PATH: "metadata/supported-configurations.json"
984+
LANGUAGE_NAME: "java"
985+
MULTIPLE_RELEASE_LINES: "false"

build.gradle.kts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import com.diffplug.gradle.spotless.SpotlessExtension
2+
import datadog.gradle.plugin.ci.testAggregate
23

34
plugins {
45
id("datadog.gradle-debug")
56
id("datadog.dependency-locking")
67
id("datadog.tracer-version")
78
id("datadog.dump-hanged-test")
9+
id("datadog.ci-jobs")
810

911
id("com.diffplug.spotless") version "6.13.0"
1012
id("com.github.spotbugs") version "6.4.4"
@@ -137,4 +139,16 @@ allprojects {
137139
}
138140
}
139141

140-
apply(from = "$rootDir/gradle/ci_jobs.gradle")
142+
testAggregate("smoke", listOf(":dd-smoke-tests"), emptyList())
143+
testAggregate("instrumentation", listOf(":dd-java-agent:instrumentation"), emptyList())
144+
testAggregate("profiling", listOf(":dd-java-agent:agent-profiling"), emptyList())
145+
testAggregate("debugger", listOf(":dd-java-agent:agent-debugger"), forceCoverage = true)
146+
testAggregate(
147+
"base", listOf(":"),
148+
listOf(
149+
":dd-java-agent:instrumentation",
150+
":dd-smoke-tests",
151+
":dd-java-agent:agent-profiling",
152+
":dd-java-agent:agent-debugger"
153+
)
154+
)
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package datadog.gradle.plugin.ci
2+
3+
import org.gradle.api.Project
4+
import org.gradle.api.Task
5+
import org.gradle.kotlin.dsl.extra
6+
7+
/**
8+
* Checks if a task is affected by git changes
9+
*/
10+
internal fun isAffectedBy(baseTask: Task, affectedProjects: Map<Project, Set<String>>): String? {
11+
val visited = mutableSetOf<Task>()
12+
val queue = mutableListOf(baseTask)
13+
14+
while (queue.isNotEmpty()) {
15+
val t = queue.removeAt(0)
16+
if (visited.contains(t)) {
17+
continue
18+
}
19+
visited.add(t)
20+
21+
val affectedTasks = affectedProjects[t.project]
22+
if (affectedTasks != null) {
23+
if (affectedTasks.contains("all")) {
24+
return "${t.project.path}:${t.name}"
25+
}
26+
if (affectedTasks.contains(t.name)) {
27+
return "${t.project.path}:${t.name}"
28+
}
29+
}
30+
31+
t.taskDependencies.getDependencies(t).forEach { queue.add(it) }
32+
}
33+
return null
34+
}
35+
36+
/**
37+
* Creates a single aggregate root task that depends on matching subproject tasks
38+
*/
39+
private fun Project.createRootTask(
40+
rootTaskName: String,
41+
subProjTaskName: String,
42+
includePrefixes: List<String>,
43+
excludePrefixes: List<String>,
44+
forceCoverage: Boolean
45+
) {
46+
val coverage = forceCoverage || rootProject.hasProperty("checkCoverage")
47+
tasks.register(rootTaskName) {
48+
subprojects.forEach { subproject ->
49+
val activePartition = subproject.extra.get("activePartition") as Boolean
50+
if (activePartition &&
51+
includePrefixes.any { subproject.path.startsWith(it) } &&
52+
!excludePrefixes.any { subproject.path.startsWith(it) }) {
53+
54+
val testTask = subproject.tasks.findByName(subProjTaskName)
55+
var isAffected = true
56+
57+
if (testTask != null) {
58+
val useGitChanges = rootProject.extra.get("useGitChanges") as Boolean
59+
if (useGitChanges) {
60+
@Suppress("UNCHECKED_CAST")
61+
val affectedProjects = rootProject.extra.get("affectedProjects") as Map<Project, Set<String>>
62+
val fileTrigger = isAffectedBy(testTask, affectedProjects)
63+
if (fileTrigger != null) {
64+
logger.warn("Selecting ${subproject.path}:$subProjTaskName (triggered by $fileTrigger)")
65+
} else {
66+
logger.warn("Skipping ${subproject.path}:$subProjTaskName (not affected by changed files)")
67+
isAffected = false
68+
}
69+
}
70+
if (isAffected) {
71+
dependsOn(testTask)
72+
}
73+
}
74+
75+
if (isAffected && coverage) {
76+
val coverageTask = subproject.tasks.findByName("jacocoTestReport")
77+
if (coverageTask != null) {
78+
dependsOn(coverageTask)
79+
}
80+
val verificationTask = subproject.tasks.findByName("jacocoTestCoverageVerification")
81+
if (verificationTask != null) {
82+
dependsOn(verificationTask)
83+
}
84+
}
85+
}
86+
}
87+
}
88+
}
89+
90+
/**
91+
* Creates aggregate test tasks for CI using createRootTask() above
92+
*
93+
* Creates three subtasks for the given base task name:
94+
* - ${baseTaskName}Test - runs allTests
95+
* - ${baseTaskName}LatestDepTest - runs allLatestDepTests
96+
* - ${baseTaskName}Check - runs check
97+
*/
98+
fun Project.testAggregate(
99+
baseTaskName: String,
100+
includePrefixes: List<String>,
101+
excludePrefixes: List<String> = emptyList(),
102+
forceCoverage: Boolean = false
103+
) {
104+
createRootTask("${baseTaskName}Test", "allTests", includePrefixes, excludePrefixes, forceCoverage)
105+
createRootTask("${baseTaskName}LatestDepTest", "allLatestDepTests", includePrefixes, excludePrefixes, forceCoverage)
106+
createRootTask("${baseTaskName}Check", "check", includePrefixes, excludePrefixes, forceCoverage)
107+
}
108+

0 commit comments

Comments
 (0)