Skip to content

Commit 61ad64f

Browse files
authored
Merge branch 'master' into mhlidd/update_trace_header_tags
2 parents 13d420f + 0c891b7 commit 61ad64f

File tree

125 files changed

+2011
-407
lines changed

Some content is hidden

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

125 files changed

+2011
-407
lines changed

.github/workflows/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ _Action:_
8585

8686
_Recovery:_ Check at the milestone for the related issues and update them manually.
8787

88-
### prune-github-container-registry [🔗](prune-github-container-registry.yaml)
89-
90-
_Trigger:_ Every day or manually.
91-
92-
_Action:_ Clean up old lib-injection OCI images from GitHub Container Registry.
93-
94-
_Recovery:_ Manually trigger the action again.
9588

9689
### prune-old-pull-requests [🔗](prune-old-pull-requests.yaml)
9790

.github/workflows/analyze-changes.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
${{ runner.os }}-gradle-
4141
4242
- name: Initialize CodeQL
43-
uses: github/codeql-action/init@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
43+
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
4444
with:
4545
languages: 'java'
4646
build-mode: 'manual'
@@ -57,7 +57,7 @@ jobs:
5757
--build-cache --parallel --stacktrace --no-daemon --max-workers=4
5858
5959
- name: Perform CodeQL Analysis and upload results to GitHub Security tab
60-
uses: github/codeql-action/analyze@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
60+
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
6161

6262
trivy:
6363
name: Analyze changes with Trivy
@@ -122,7 +122,7 @@ jobs:
122122
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
123123

124124
- name: Upload Trivy scan results to GitHub Security tab
125-
uses: github/codeql-action/upload-sarif@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
125+
uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
126126
if: always()
127127
with:
128128
sarif_file: 'trivy-results.sarif'

.github/workflows/prune-github-container-registry.yaml

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

.gitlab-ci.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ default:
119119
- .gitlab/cgroup-info.sh
120120
- gitlab_section_end "cgroup-info"
121121

122+
.gitlab_base_ref_params: &gitlab_base_ref_params
123+
- |
124+
# FIXME: Disabled until we find a way to not hit GitHub API rate limit
125+
if false && [[ ! $CI_COMMIT_BRANCH =~ ^(master|release/.*)$ ]]; then
126+
export GIT_BASE_REF=$(.gitlab/find-gh-base-ref.sh)
127+
if [[ -n "$GIT_BASE_REF" ]]; then
128+
export GRADLE_PARAMS="$GRADLE_PARAMS -PgitBaseRef=origin/$GIT_BASE_REF"
129+
else
130+
echo "Failed to find base ref for PR" >&2
131+
fi
132+
fi
133+
122134
.gradle_build: &gradle_build
123135
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}base
124136
stage: build
@@ -223,7 +235,8 @@ build_tests:
223235
MAVEN_OPTS: "-Xms64M -Xmx512M -Dorg.slf4j.simpleLogger.defaultLogLevel=debug" # FIXME: Build :smokeTest build fails unless mvn debug logging is on
224236

225237
script:
226-
- ./gradlew clean $GRADLE_TARGET -PskipTests $GRADLE_ARGS
238+
- *gitlab_base_ref_params
239+
- ./gradlew clean $GRADLE_TARGET $GRADLE_PARAMS -PskipTests $GRADLE_ARGS
227240

228241
populate_dep_cache:
229242
extends: build_tests
@@ -327,7 +340,8 @@ test_published_artifacts:
327340
variables:
328341
CACHE_TYPE: lib
329342
script:
330-
- ./gradlew $GRADLE_TARGET -PskipTests -PrunBuildSrcTests -PskipSpotless -PtaskPartitionCount=$NORMALIZED_NODE_TOTAL -PtaskPartition=$NORMALIZED_NODE_INDEX $GRADLE_ARGS
343+
- *gitlab_base_ref_params
344+
- ./gradlew $GRADLE_TARGET $GRADLE_PARAMS -PskipTests -PrunBuildSrcTests -PskipSpotless -PtaskPartitionCount=$NORMALIZED_NODE_TOTAL -PtaskPartition=$NORMALIZED_NODE_INDEX $GRADLE_ARGS
331345
after_script:
332346
- *cgroup_info
333347
- source .gitlab/gitlab-utils.sh
@@ -460,6 +474,7 @@ muzzle-dep-report:
460474
- if: $CI_COMMIT_BRANCH == "master"
461475
when: on_success
462476
script:
477+
- *gitlab_base_ref_params
463478
- >
464479
if [ "$PROFILE_TESTS" == "true" ] && [ "$testJvm" != "ibm8" ] && [ "$testJvm" != "oracle8" ];
465480
then
@@ -506,7 +521,7 @@ muzzle-dep-report:
506521
CI_USE_TEST_AGENT: "true"
507522
CI_AGENT_HOST: local-agent
508523
services:
509-
- name: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.11.0
524+
- name: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.24.1
510525
alias: local-agent
511526
variables:
512527
LOG_LEVEL: "DEBUG"
@@ -729,6 +744,7 @@ deploy_to_di_backend:manual:
729744
UPSTREAM_COMMIT_AUTHOR: $CI_COMMIT_AUTHOR
730745
UPSTREAM_COMMIT_SHORT_SHA: $CI_COMMIT_SHORT_SHA
731746

747+
# If the deploy_to_sonatype job is re-run, re-trigger the deploy_artifacts_to_github job as well so that the artifacts match.
732748
deploy_to_sonatype:
733749
extends: .gradle_build
734750
stage: publish
@@ -746,8 +762,8 @@ deploy_to_sonatype:
746762
- when: manual
747763
allow_failure: true
748764
script:
749-
- export SONATYPE_USERNAME=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.sonatype_username --with-decryption --query "Parameter.Value" --out text)
750-
- export SONATYPE_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.sonatype_password --with-decryption --query "Parameter.Value" --out text)
765+
- export SONATYPE_USERNAME=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_username --with-decryption --query "Parameter.Value" --out text)
766+
- export SONATYPE_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_password --with-decryption --query "Parameter.Value" --out text)
751767
- export GPG_PRIVATE_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.signing.gpg_private_key --with-decryption --query "Parameter.Value" --out text)
752768
- export GPG_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.signing.gpg_passphrase --with-decryption --query "Parameter.Value" --out text)
753769
- ./gradlew -PbuildInfo.build.number=$CI_JOB_ID publishToSonatype closeSonatypeStagingRepository -PskipTests $GRADLE_ARGS
@@ -765,7 +781,7 @@ deploy_artifacts_to_github:
765781
when: never
766782
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
767783
when: on_success
768-
# Requires the deploy_to_sonatype job to have run first the UP-TO-DATE gradle check across jobs is broken
784+
# Requires the deploy_to_sonatype job to have run first (the UP-TO-DATE gradle check across jobs is broken)
769785
# This will deploy the artifacts built from the publishToSonatype task to the GitHub release
770786
needs:
771787
- job: deploy_to_sonatype

.gitlab/benchmarks.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
UPSTREAM_BRANCH: $CI_COMMIT_REF_NAME # The branch or tag name for which project is built.
2828
UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA # The commit revision the project is built for.
2929

30-
KUBERNETES_SERVICE_ACCOUNT_OVERWRITE: dd-trace-java
31-
FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY: "true"
32-
3330
benchmarks-startup:
3431
extends: .benchmarks
3532
script:
@@ -56,6 +53,7 @@ benchmarks-dacapo:
5653

5754
benchmarks-post-results:
5855
extends: .benchmarks
56+
tags: ["arch:amd64"]
5957
script:
6058
- !reference [ .benchmarks, script ]
6159
- ./steps/upload-results-to-s3.sh

.gitlab/find-gh-base-ref.sh

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/usr/bin/env bash
2+
# Determines the base branch for the current PR (if we are running in a PR).
3+
set -euo pipefail
4+
5+
CURRENT_HEAD_SHA="$(git rev-parse HEAD)"
6+
if [[ -z "${CURRENT_HEAD_SHA:-}" ]]; then
7+
echo "Failed to determine current HEAD SHA" >&2
8+
exit 1
9+
fi
10+
11+
# 'workspace' is declared in the ci pipeline cache
12+
CACHE_PATH=workspace/find-gh-base-ref.cache
13+
save_cache() {
14+
local base_ref="$1"
15+
local head_sha="$2"
16+
mkdir -p workspace
17+
echo "CACHED_BASE_REF=${base_ref}" > "$CACHE_PATH"
18+
echo "CACHED_HEAD_SHA=${head_sha}" >> "$CACHE_PATH"
19+
}
20+
21+
# Get cached result (if HEAD commit matches)
22+
if [[ -f $CACHE_PATH ]]; then
23+
set -a
24+
source "$CACHE_PATH"
25+
set +a
26+
if [[ "$CURRENT_HEAD_SHA" == "${CACHED_HEAD_SHA:-}" && -n "${CACHED_BASE_REF:-}" ]]; then
27+
echo "Cache hit on $CACHE_PATH" >&2
28+
echo "$CACHED_BASE_REF"
29+
exit 0
30+
else
31+
echo "Cache miss on $CACHE_PATH" >&2
32+
fi
33+
fi
34+
35+
# Happy path: if we're just one commit away from master, base ref is master.
36+
if [[ $(git log --pretty=oneline origin/master..HEAD | wc -l) -eq 1 ]]; then
37+
echo "We are just one commit away from master, base ref is master" >&2
38+
save_cache "master" "$CURRENT_HEAD_SHA"
39+
echo "master"
40+
exit 0
41+
fi
42+
43+
# In GitLab: we have no reference to the base branch or even the PR number.
44+
# We have to find it from the current branch name, which is defined in
45+
# CI_COMMIT_REF_NAME.
46+
if [[ -z "${CI_COMMIT_REF_NAME}" ]]; then
47+
echo "CI_COMMIT_REF_NAME is not set, not running in GitLab CI?" >&2
48+
exit 1
49+
fi
50+
51+
# In GitLab, CI_PROJECT_NAME is set, otherwise, set it for testing.
52+
export CI_PROJECT_NAME="${CI_PROJECT_NAME:-dd-trace-java}"
53+
54+
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
55+
echo "GITHUB_TOKEN is not set, fetching from AWS SSM" >&2
56+
if ! command -v aws >/dev/null 2>&1; then
57+
echo "aws is not installed, please install it" >&2
58+
exit 1
59+
fi
60+
set +e
61+
GITHUB_TOKEN=$(aws ssm get-parameter --name "ci.$CI_PROJECT_NAME.gh_release_token" --with-decryption --query "Parameter.Value" --output text)
62+
set -e
63+
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
64+
echo "Failed to fetch GITHUB_TOKEN from AWS SSM" >&2
65+
exit 1
66+
fi
67+
export GITHUB_TOKEN
68+
fi
69+
70+
if ! command -v curl >/dev/null 2>&1; then
71+
echo "curl is not installed, please install it" >&2
72+
exit 1
73+
fi
74+
75+
if ! command -v jq >/dev/null 2>&1; then
76+
echo "jq is not installed, please install it" >&2
77+
exit 1
78+
fi
79+
80+
while true; do
81+
set +e
82+
PR_DATA=$(curl \
83+
-XGET \
84+
--silent \
85+
--include \
86+
--fail-with-body \
87+
-H 'Accept: application/vnd.github+json' \
88+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
89+
-H "X-GitHub-Api-Version: 2022-11-28" \
90+
"https://api.github.com/repos/datadog/dd-trace-java/pulls?head=DataDog:${CI_COMMIT_REF_NAME}&sort=updated&direction=desc")
91+
exit_code=$?
92+
set -e
93+
if [[ ${exit_code} -eq 0 ]]; then
94+
PR_NUMBER=$(echo "$PR_DATA" | sed '1,/^[[:space:]]*$/d' | jq -r '.[].number')
95+
PR_BASE_REF=$(echo "$PR_DATA" | sed '1,/^[[:space:]]*$/d' | jq -r '.[].base.ref')
96+
if [[ -n "${PR_BASE_REF:-}" ]]; then
97+
echo "PR is https://github.com/datadog/dd-trace-java/pull/${PR_NUMBER} and base ref is ${PR_BASE_REF}">&2
98+
save_cache "${PR_BASE_REF}" "$CURRENT_HEAD_SHA"
99+
echo "${PR_BASE_REF}"
100+
exit 0
101+
fi
102+
fi
103+
if echo "$PR_DATA" | grep -q "^x-ratelimit-reset:"; then
104+
reset_timestamp=$(echo -n "$PR_DATA" | grep "^x-ratelimit-reset:" | sed -e 's/^x-ratelimit-reset: //' -e 's/\r//')
105+
now=$(date +%s)
106+
sleep_time=$((reset_timestamp - now + 1))
107+
echo "GitHub rate limit exceeded, sleeping for ${sleep_time} seconds" >&2
108+
sleep "${sleep_time}"
109+
continue
110+
fi
111+
echo -e "GitHub request failed for an unknown reason:\n$(echo "$PR_DATA" | sed '/^$/q')" >&2
112+
exit 1
113+
done

.gitlab/macrobenchmarks.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
- platform/artifacts/
2323
expire_in: 3 months
2424
variables:
25-
FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY: "true"
26-
2725
K6_OPTIONS_WARMUP_RATE: 2000
2826
K6_OPTIONS_WARMUP_DURATION: 5m
2927
K6_OPTIONS_WARMUP_GRACEFUL_STOP: 10s

build.gradle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ plugins {
2121
id 'de.thetaphi.forbiddenapis' version '3.8'
2222

2323
id 'pl.allegro.tech.build.axion-release' version '1.14.4'
24-
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
24+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
2525

2626
id 'com.gradleup.shadow' version '8.3.6' apply false
2727
id 'me.champeau.jmh' version '0.7.0' apply false
@@ -35,13 +35,17 @@ def isCI = System.getenv("CI") != null
3535

3636
apply from: "$rootDir/gradle/repositories.gradle"
3737
apply from: "$rootDir/gradle/scm.gradle"
38+
3839
spotless {
3940
// only resolve the spotless dependencies once in the build
4041
predeclareDeps()
4142
}
43+
4244
spotlessPredeclare {
4345
// these need to align with the types and versions in gradle/spotless.gradle
4446
java {
47+
removeUnusedImports()
48+
4549
// This is the last Google Java Format version that supports Java 8
4650
googleJavaFormat('1.7')
4751
}
@@ -88,7 +92,7 @@ nexusPublishing {
8892
def forceLocal = project.hasProperty('forceLocal') && forceLocal
8993
if (forceLocal && !isCI) {
9094
local {
91-
// For testing use with https://hub.docker.com/r/sonatype/nexus
95+
// For testing, use with https://hub.docker.com/r/sonatype/nexus
9296
// docker run --rm -d -p 8081:8081 --name nexus sonatype/nexus:oss
9397
// ./gradlew publishToLocal
9498
// Doesn't work for testing releases though... (due to staging)
@@ -99,7 +103,13 @@ nexusPublishing {
99103
allowInsecureProtocol = true
100104
}
101105
} else {
106+
// see https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-central
107+
// For official documentation:
108+
// staging repo publishing https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
109+
// snapshot publishing https://central.sonatype.org/publish/publish-portal-snapshots/#publishing-via-other-methods
102110
sonatype {
111+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
112+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
103113
username = System.getenv("SONATYPE_USERNAME")
104114
password = System.getenv("SONATYPE_PASSWORD")
105115
}

0 commit comments

Comments
 (0)