Skip to content

Commit ba878aa

Browse files
committed
Merge branch 'master' into sarahchen6/combine-release-branch-workflows
2 parents aea0ef0 + fa2f591 commit ba878aa

75 files changed

Lines changed: 4140 additions & 2691 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: migrate-groovy-to-java
3+
description: migrate test groovy files to java
4+
---
5+
6+
Migrate test Groovy files to Java using JUnit 5
7+
8+
1. List all groovy files of the current gradle module
9+
2. convert groovy files to Java using Junit 5
10+
3. make sure the tests are still passing after migration
11+
4. remove groovy files
12+
13+
When converting groovy code to java code make sure that:
14+
- the Java code generated is compatible with JDK 8
15+
- when translating Spock test, favor using `@CsvSource` with `|` delimiters
16+
- when using a `@MethodSource`, use the test method name, and suffix it with `_arguments`
17+
- when converting tuples, create light dedicated structure instead to keep the typing system
18+
- Instead of checking a state and throwing an exception, use JUnit asserts
19+
- Do not wrap checked exception and throwing a Runtime exception, prefer adding a throws clause at method declaration
20+
- Do not mark local variables `final`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
issuer: https://token.actions.githubusercontent.com
2+
3+
subject: repo:DataDog/dd-trace-java:pull_request
4+
5+
claim_pattern:
6+
event_name: pull_request
7+
job_workflow_ref: DataDog/dd-trace-java/\.github/workflows/enforce-datadog-merge-queue\.yaml@refs/heads/master
8+
9+
permissions:
10+
issues: write
11+
pull_requests: write

.github/workflows/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ _Action:_ Check the pull request did not introduce unexpected label.
3636

3737
_Recovery:_ Update the pull request or add a comment to trigger the action again.
3838

39+
### enforce-datadog-merge-queue [🔗](enforce-datadog-merge-queue.yaml)
40+
41+
_Trigger:_ When creating or updating a pull request, or when a pull request is added to GitHub merge queue.
42+
43+
_Actions:_
44+
45+
* Pass the `Merge queue check` status check on pull requests so they remain in a mergeable state,
46+
* When a pull request is enqueued in GitHub merge queue, post a `/merge` comment to trigger the Datadog merge queue,
47+
* Fail the `Merge queue check` status check on merge groups to prevent GitHub from merging directly.
48+
49+
_Recovery:_ The workflow is expected to fail to block GitHub merge queue.
50+
This redirects GitHub's "Merge when ready" button to the Datadog merge queue system.
51+
3952
### create-release-branch [🔗](create-release-branch.yaml)
4053

4154
_Trigger:_ When a git tag matching the pattern "vM.N.0" is pushed (e.g. for a minor release).
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Enforce Datadog Merge Queue
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, enqueued]
6+
branches:
7+
- master
8+
merge_group:
9+
10+
jobs:
11+
enforce_datadog_merge_queue:
12+
name: Merge queue check
13+
runs-on: ubuntu-latest
14+
permissions:
15+
id-token: write # required for OIDC token federation
16+
steps:
17+
- name: Block GitHub merge queue
18+
if: github.event_name == 'merge_group'
19+
run: |
20+
echo "Merge is handled by the Datadog merge queue system. Use the /merge command to enqueue your PR for merging."
21+
exit 1
22+
- name: Get OIDC token
23+
if: github.event.action == 'enqueued'
24+
uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
25+
id: octo-sts
26+
with:
27+
scope: DataDog/dd-trace-java
28+
policy: self.enforce-datadog-merge-queue.comment-pr
29+
- name: Post /merge comment
30+
if: github.event.action == 'enqueued'
31+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # 8.0.0
32+
with:
33+
github-token: ${{ steps.octo-sts.outputs.token }}
34+
script: |
35+
await github.rest.issues.createComment({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
issue_number: context.payload.pull_request.number,
39+
body: '/merge'
40+
});

.github/workflows/prune-old-pull-requests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
pull-requests: write
1414
steps:
1515
- name: Prune old pull requests
16-
uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
16+
uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10.2.0
1717
with:
1818
days-before-stale: -1 # Disable general stale bot
1919
days-before-pr-stale: 90 # Only enable stale bot for PRs with no activity for 90 days

.github/workflows/run-system-tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Run system tests
22

33
on:
4+
merge_group:
45
pull_request:
56
workflow_dispatch:
67
schedule:

.gitlab-ci.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ variables:
3131
GRADLE_PLUGIN_PROXY: "https://depot-read-api-java.us1.ddbuild.io/magicmirror/magicmirror/@current/"
3232
BUILDER_IMAGE_VERSION_PREFIX: "v26.01-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "v25.05-")
3333
REPO_NOTIFICATION_CHANNEL: "#apm-java-escalations"
34-
DEFAULT_TEST_JVMS: /^(8|11|17|21|25)$/ # the latest "stable" version is LTS v25
34+
DEFAULT_TEST_JVMS: /^(8|11|17|21|25|stable)$/ # the latest "stable" version is 26
3535
PROFILE_TESTS:
3636
description: "Enable profiling of tests"
3737
value: "false"
@@ -62,15 +62,14 @@ workflow:
6262
- "17"
6363
- "21"
6464
- "25"
65-
- "26"
6665
- "semeru11"
6766
- "oracle8"
6867
- "zulu8"
6968
- "semeru8"
7069
- "ibm8"
7170
- "zulu11"
7271
- "semeru17"
73-
# - "stable"
72+
- "stable"
7473
CI_SPLIT: ["1/1"]
7574

7675
# Gitlab doesn't support "parallel" and "parallel:matrix" at the same time
@@ -450,12 +449,16 @@ test_published_artifacts:
450449
- source .gitlab/gitlab-utils.sh
451450
- gitlab_section_start "collect-reports" "Collecting reports"
452451
- .gitlab/collect_reports.sh --destination ./check_reports --move
452+
- .gitlab/collect_results.sh
453453
- gitlab_section_end "collect-reports"
454454
artifacts:
455455
when: always
456456
paths:
457457
- ./check_reports
458+
- ./results
458459
- '.gradle/daemon/*/*.out.log'
460+
reports:
461+
junit: results/*.xml
459462
retry:
460463
max: 2
461464
when:
@@ -516,15 +519,21 @@ muzzle:
516519
after_script:
517520
- *container_info
518521
- *cgroup_info
522+
- *set_datadog_api_keys
519523
- source .gitlab/gitlab-utils.sh
520524
- gitlab_section_start "collect-reports" "Collecting reports"
521525
- .gitlab/collect_reports.sh
526+
- .gitlab/collect_results.sh
527+
- .gitlab/upload_ciapp.sh $CACHE_TYPE
522528
- gitlab_section_end "collect-reports"
523529
artifacts:
524530
when: always
525531
paths:
526532
- ./reports
533+
- ./results
527534
- '.gradle/daemon/*/*.out.log'
535+
reports:
536+
junit: results/*.xml
528537

529538
muzzle-dep-report:
530539
extends: .gradle_build
@@ -588,6 +597,8 @@ muzzle-dep-report:
588597
when: on_success
589598
- if: '$CI_COMMIT_BRANCH =~ /^mq-working-branch-/'
590599
when: on_success
600+
- if: '$CI_COMMIT_BRANCH =~ /^gh-readonly-queue/'
601+
when: on_success
591602
script:
592603
- *gitlab_base_ref_params
593604
- >

.gitlab/collect_results.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,17 @@ do
6767
# E.g. for the example path: tomcat-5.5_forkedTest_TEST-TomcatServletV1ForkedTest.xml
6868
AGGREGATED_FILE_NAME=$(echo "$RESULT_XML_FILE" | rev | cut -d "/" -f 1,2,5 | rev | tr "/" "_")
6969
echo -n " as $AGGREGATED_FILE_NAME"
70-
cp "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
70+
TARGET_DIR="$TEST_RESULTS_DIR"
71+
mkdir -p "$TARGET_DIR"
72+
cp "$RESULT_XML_FILE" "$TARGET_DIR/$AGGREGATED_FILE_NAME"
7173
# Insert file attribute to testcase XML nodes
7274
get_source_file
73-
sed -i "/<testcase/ s|\(time=\"[^\"]*\"\)|\1 file=\"$file_path\"|g" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
75+
sed -i "/<testcase/ s|\(time=\"[^\"]*\"\)|\1 file=\"$file_path\"|g" "$TARGET_DIR/$AGGREGATED_FILE_NAME"
7476
# Replace Java Object hashCode by marker in testcase XML nodes to get stable test names
75-
sed -i '/<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
77+
sed -i '/<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' "$TARGET_DIR/$AGGREGATED_FILE_NAME"
7678
# Replace random port numbers by marker in testcase XML nodes to get stable test names
77-
sed -i '/<testcase/ s/localhost:[0-9]\{2,5\}/localhost:PORT/g' "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"
78-
if cmp -s "$RESULT_XML_FILE" "$TEST_RESULTS_DIR/$AGGREGATED_FILE_NAME"; then
79+
sed -i '/<testcase/ s/localhost:[0-9]\{2,5\}/localhost:PORT/g' "$TARGET_DIR/$AGGREGATED_FILE_NAME"
80+
if cmp -s "$RESULT_XML_FILE" "$TARGET_DIR/$AGGREGATED_FILE_NAME"; then
7981
echo ""
8082
else
8183
echo -n " (non-stable test names detected)"

.gitlab/upload_ciapp.sh

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
#!/usr/bin/env bash
22
SERVICE_NAME="dd-trace-java"
33
CACHE_TYPE=$1
4-
TEST_JVM=$2
4+
TEST_JVM=${2:-}
55

66
# CI_JOB_NAME, CI_NODE_INDEX, and CI_NODE_TOTAL are read from GitLab CI environment
77

88
# JAVA_???_HOME are set in the base image for each used JDK https://github.com/DataDog/dd-trace-java-docker-build/blob/master/Dockerfile#L86
9-
JAVA_HOME="JAVA_${TEST_JVM}_HOME"
10-
JAVA_BIN="${!JAVA_HOME}/bin/java"
11-
if [ ! -x "$JAVA_BIN" ]; then
12-
JAVA_BIN=$(which java)
9+
JAVA_PROPS=""
10+
if [ -n "$TEST_JVM" ]; then
11+
JAVA_BIN=""
12+
if [[ "$TEST_JVM" =~ ^[A-Za-z0-9_]+$ ]]; then
13+
JAVA_HOME_VAR="JAVA_${TEST_JVM}_HOME"
14+
JAVA_HOME_VALUE="${!JAVA_HOME_VAR}"
15+
if [ -n "$JAVA_HOME_VALUE" ] && [ -x "$JAVA_HOME_VALUE/bin/java" ]; then
16+
JAVA_BIN="$JAVA_HOME_VALUE/bin/java"
17+
fi
18+
fi
19+
if [ -z "$JAVA_BIN" ]; then
20+
JAVA_BIN="$(command -v java)"
21+
fi
22+
JAVA_PROPS=$($JAVA_BIN -XshowSettings:properties -version 2>&1)
1323
fi
1424

15-
# Extract Java properties from the JVM used to run the tests
16-
JAVA_PROPS=$($JAVA_BIN -XshowSettings:properties -version 2>&1)
1725
java_prop() {
1826
local PROP_NAME=$1
1927
echo "$JAVA_PROPS" | grep "$PROP_NAME" | head -n1 | cut -d'=' -f2 | xargs
@@ -27,11 +35,23 @@ junit_upload() {
2735
# Build custom tags array directly from arguments
2836
local custom_tags_args=()
2937

30-
# Extract job base name from CI_JOB_NAME (strip matrix suffix)
38+
# Extract job base name from CI_JOB_NAME.
39+
# Handles:
40+
# - matrix suffix format: "job-name: [value, 1/6]" -> "job-name"
41+
# - split suffix format: "job-name 1/6" -> "job-name"
3142
local job_base_name="${CI_JOB_NAME%%:*}"
43+
job_base_name="$(echo "$job_base_name" | sed -E 's/[[:space:]]+[0-9]+\/[0-9]+$//')"
3244

3345
# Add custom test configuration tags
34-
custom_tags_args+=(--tags "test.configuration.jvm:${TEST_JVM}")
46+
if [ -n "$TEST_JVM" ]; then
47+
custom_tags_args+=(--tags "test.configuration.jvm:${TEST_JVM}")
48+
custom_tags_args+=(--tags "runtime.name:$(java_prop java.runtime.name)")
49+
custom_tags_args+=(--tags "runtime.vendor:$(java_prop java.vendor)")
50+
custom_tags_args+=(--tags "runtime.version:$(java_prop java.version)")
51+
custom_tags_args+=(--tags "os.architecture:$(java_prop os.arch)")
52+
custom_tags_args+=(--tags "os.platform:$(java_prop os.name)")
53+
custom_tags_args+=(--tags "os.version:$(java_prop os.version)")
54+
fi
3555
if [ -n "$CI_NODE_INDEX" ] && [ -n "$CI_NODE_TOTAL" ]; then
3656
custom_tags_args+=(--tags "test.configuration.split:${CI_NODE_INDEX}/${CI_NODE_TOTAL}")
3757
fi
@@ -43,12 +63,6 @@ junit_upload() {
4363
datadog-ci junit upload --service $SERVICE_NAME \
4464
--logs \
4565
--tags "test.traits:{\"category\":[\"$CACHE_TYPE\"]}" \
46-
--tags "runtime.name:$(java_prop java.runtime.name)" \
47-
--tags "runtime.vendor:$(java_prop java.vendor)" \
48-
--tags "runtime.version:$(java_prop java.version)" \
49-
--tags "os.architecture:$(java_prop os.arch)" \
50-
--tags "os.platform:$(java_prop os.name)" \
51-
--tags "os.version:$(java_prop os.version)" \
5266
--tags "git.repository_url:https://github.com/DataDog/dd-trace-java" \
5367
"${custom_tags_args[@]}" \
5468
./results

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
java
3-
groovy
43
id("com.diffplug.spotless") version "8.2.1"
54
id("com.gradleup.shadow") version "8.3.9"
65
}
@@ -34,8 +33,9 @@ dependencies {
3433
implementation(libs.javaparser.symbol.solver)
3534

3635
testImplementation(libs.bytebuddy)
37-
testImplementation(libs.bundles.groovy)
38-
testImplementation(libs.bundles.spock)
36+
testImplementation(libs.bundles.junit5)
37+
testRuntimeOnly(libs.junit.platform.launcher)
38+
testImplementation(libs.bundles.mockito)
3939
testImplementation("javax.servlet", "javax.servlet-api", "3.0.1")
4040
testImplementation(libs.spotbugs.annotations)
4141
}

0 commit comments

Comments
 (0)