Skip to content

Commit a58298f

Browse files
feat(ci): Update CI reports to prod (#7922)
1 parent 047fabf commit a58298f

File tree

3 files changed

+74
-29
lines changed

3 files changed

+74
-29
lines changed

.circleci/upload_ciapp.sh

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
#!/usr/bin/env bash
22
SERVICE_NAME="dd-trace-java"
3+
PIPELINE_STAGE=$1
4+
TEST_JVM=$2
35

46
# 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
5-
java_home="JAVA_$2_HOME"
6-
java_bin="${!java_home}/bin/java"
7-
if [ ! -x $java_bin ]; then
8-
java_bin=$(which java)
7+
JAVA_HOME="JAVA_${TEST_JVM}_HOME"
8+
JAVA_BIN="${!JAVA_HOME}/bin/java"
9+
if [ ! -x "$JAVA_BIN" ]; then
10+
JAVA_BIN=$(which java)
911
fi
1012

11-
java_props=$($java_bin -XshowSettings:properties -version 2>&1)
12-
java_prop () {
13-
echo "$(echo "$java_props" | grep $1 | head -n1 | cut -d'=' -f2 | xargs)"
13+
# Extract Java properties from the JVM used to run the tests
14+
JAVA_PROPS=$($JAVA_BIN -XshowSettings:properties -version 2>&1)
15+
java_prop() {
16+
local PROP_NAME=$1
17+
echo "$JAVA_PROPS" | grep "$PROP_NAME" | head -n1 | cut -d'=' -f2 | xargs
1418
}
1519

16-
# based on tracer implementation: https://github.com/DataDog/dd-trace-java/blob/master/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/TestDecorator.java#L55-L77
17-
datadog-ci junit upload --service $SERVICE_NAME \
18-
--logs \
19-
--tags "test.traits:{\"marker\":[\"$1\"]}" \
20-
--tags "runtime.name:$(java_prop java.runtime.name)" \
21-
--tags "runtime.vendor:$(java_prop java.vendor)" \
22-
--tags "runtime.version:$(java_prop java.version)" \
23-
--tags "os.architecture:$(java_prop os.arch)" \
24-
--tags "os.platform:$(java_prop os.name)" \
25-
--tags "os.version:$(java_prop os.version)" \
26-
./results
20+
# Upload test results to CI Visibility
21+
junit_upload() {
22+
# based on tracer implementation: https://github.com/DataDog/dd-trace-java/blob/master/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/TestDecorator.java#L55-L77
23+
DD_API_KEY=$1 \
24+
datadog-ci junit upload --service $SERVICE_NAME \
25+
--logs \
26+
--tags "test.traits:{\"marker\":[\"$PIPELINE_STAGE\"]}" \
27+
--tags "runtime.name:$(java_prop java.runtime.name)" \
28+
--tags "runtime.vendor:$(java_prop java.vendor)" \
29+
--tags "runtime.version:$(java_prop java.version)" \
30+
--tags "os.architecture:$(java_prop os.arch)" \
31+
--tags "os.platform:$(java_prop os.name)" \
32+
--tags "os.version:$(java_prop os.version)" \
33+
./results
34+
}
35+
36+
# Upload test results to production environment like all other CI jobs
37+
junit_upload "$DATADOG_API_KEY_PROD"
38+
# And also upload to staging environment to benefit from the new features not yet released
39+
junit_upload "$DATADOG_API_KEY_DDSTAGING"

.github/workflows/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ _Recovery:_ Manually trigger the action again on the relevant tag.
5454
_Trigger:_ When creating a minor or major version tag.
5555

5656
_Actions:_
57+
5758
* Close the milestone related to the tag,
5859
* Create a new milestone by incrementing minor version.
5960

@@ -76,6 +77,7 @@ _Notes:_ _Download releases_ are special GitHub releases with fixed URL and tags
7677
_Trigger:_ When a release is published. Releases of type `prereleased` should skip this.
7778

7879
_Action:_
80+
7981
* Find all issues related to the release by checking the related milestone,
8082
* Add a comment to let know the issue was addressed by the newly published release,
8183
* Close all those issues.
@@ -105,10 +107,13 @@ _Recovery:_ Manually trigger the action again.
105107

106108
_Trigger:_ When pushing commits to `master` or any pull request targeting `master`.
107109

108-
_Action:_
110+
_Action:_
111+
109112
* Run [DataDog Static Analysis](https://docs.datadoghq.com/static_analysis/) and upload result to DataDog Code Analysis,
110-
* Run [GitHub CodeQL](https://codeql.github.com/) action, upload result to GitHub security tab and DataDog Code Analysis -- do not apply to pull request, only when pushing to `master`,
111-
* Run [Trivy security scanner](https://github.com/aquasecurity/trivy) on built artifacts and upload result to GitHub security tab.
113+
* Run [GitHub CodeQL](https://codeql.github.com/) action, upload result to GitHub security tab -- do not apply to pull request, only when pushing to `master`,
114+
* Run [Trivy security scanner](https://github.com/aquasecurity/trivy) on built artifacts and upload result to GitHub security tab and Datadog Code Analysis.
115+
116+
_Notes:_ Results are sent on both production and staging environments.
112117

113118
### comment-on-submodule-update [🔗](comment-on-submodule-update.yaml)
114119

.github/workflows/analyze-changes.yaml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@ jobs:
1616
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # 4.1.6
1717
with:
1818
submodules: 'recursive'
19-
- name: Check code meets quality standards
19+
- name: Check code meets quality standards (production)
2020
id: datadog-static-analysis
2121
uses: DataDog/datadog-static-analyzer-github-action@c74aff158c8cc1c3e285660713bcaa5f9c6d696e # v1
2222
with:
23-
dd_app_key: ${{ secrets.DD_APP_KEY }}
24-
dd_api_key: ${{ secrets.DD_API_KEY }}
25-
dd_site: datad0g.com
23+
dd_app_key: ${{ secrets.DATADOG_APP_KEY_PROD }}
24+
dd_api_key: ${{ secrets.DATADOG_API_KEY_PROD }}
25+
dd_site: "datadoghq.com"
26+
dd_service: "dd-trace-java"
27+
dd_env: "ci"
28+
cpu_count: 2
29+
enable_performance_statistics: false
30+
# Also run the static analysis on the staging environment to benefit from the new features not yet released
31+
- name: Check code meets quality standards (staging)
32+
id: datadog-static-analysis-staging
33+
uses: DataDog/datadog-static-analyzer-github-action@c74aff158c8cc1c3e285660713bcaa5f9c6d696e # v1
34+
with:
35+
dd_app_key: ${{ secrets.DATADOG_APP_KEY_STAGING }}
36+
dd_api_key: ${{ secrets.DATADOG_API_KEY_STAGING }}
37+
dd_site: "datad0g.com"
2638
dd_service: "dd-trace-java"
2739
dd_env: "ci"
2840
cpu_count: 2
@@ -77,11 +89,19 @@ jobs:
7789
# For now, CodeQL SARIF results are not supported by Datadog CI
7890
# - name: Upload results to Datadog CI Static Analysis
7991
# run: |
80-
# wget --no-verbose https://github.com/DataDog/datadog-ci/releases/download/v2.42.0/datadog-ci_linux-x64 -O datadog-ci
92+
# wget --no-verbose https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64 -O datadog-ci
8193
# chmod +x datadog-ci
8294
# ./datadog-ci sarif upload /home/runner/work/dd-trace-java/results/java.sarif --service dd-trace-java --env ci
8395
# env:
84-
# DD_API_KEY: ${{ secrets.DD_API_KEY }}
96+
# DD_API_KEY: ${{ secrets.DATADOG_APP_KEY_PROD }}
97+
# DD_SITE: datadoghq.com
98+
99+
# For now, CodeQL SARIF results are not supported by Datadog CI
100+
# - name: Upload results to Datadog Staging CI Static Analysis
101+
# run: |
102+
# ./datadog-ci sarif upload /home/runner/work/dd-trace-java/results/java.sarif --service dd-trace-java --env ci
103+
# env:
104+
# DD_API_KEY: ${{ secrets.DATADOG_API_KEY_STAGING }}
85105
# DD_SITE: datad0g.com
86106

87107
trivy:
@@ -152,9 +172,16 @@ jobs:
152172

153173
- name: Upload results to Datadog CI Static Analysis
154174
run: |
155-
wget --no-verbose https://github.com/DataDog/datadog-ci/releases/download/v2.42.0/datadog-ci_linux-x64 -O datadog-ci
175+
wget --no-verbose https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64 -O datadog-ci
156176
chmod +x datadog-ci
157177
./datadog-ci sarif upload trivy-results.sarif --service dd-trace-java --env ci
158178
env:
159-
DD_API_KEY: ${{ secrets.DD_API_KEY }}
179+
DD_API_KEY: ${{ secrets.DATADOG_API_KEY_PROD }}
180+
DD_SITE: datadoghq.com
181+
182+
- name: Upload results to Datadog Staging CI Static Analysis
183+
run: |
184+
./datadog-ci sarif upload trivy-results.sarif --service dd-trace-java --env ci
185+
env:
186+
DD_API_KEY: ${{ secrets.DATADOG_API_KEY_STAGING }}
160187
DD_SITE: datad0g.com

0 commit comments

Comments
 (0)