Skip to content

Commit 217c346

Browse files
authored
fix(ci): fix test optimization upload broken by datadog-ci v5.13.0 requiring Node >= 20 (#3802)
* fix(ci): require Node >= 20 for datadog-ci npx, surface errors in silent wrapper @datadog/datadog-ci@5.13.0 bumped its minimum Node.js requirement to >=20. CI runners have Node 18, causing a ReferenceError: File is not defined crash and silently failing all test optimization uploads. Fix: raise the npx node version check from >=16 to >=20 so Node 18 runners fall back to the standalone binary instead. Also improve silent-upload-junit-to-datadog.sh to surface Warning/Error lines even when the upload script exits 0, so future failures are visible in CI logs. * revert silent-upload grep to original * fix(ci): exit 1 on datadog-ci upload failure so silent wrapper shows output
1 parent e2386d8 commit 217c346

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

.gitlab/generate-appsec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
after_script:
132132
- mkdir -p "${CI_PROJECT_DIR}/artifacts"
133133
- find appsec/tests/integration/build/test-results -name "*.xml" -exec cp --parents '{}' "${CI_PROJECT_DIR}/artifacts/" \;
134-
- .gitlab/upload-junit-to-datadog.sh "test.source.file:appsec/"
134+
- .gitlab/silent-upload-junit-to-datadog.sh "test.source.file:appsec/"
135135
artifacts:
136136
reports:
137137
junit: "artifacts/**/test-results/**/TEST-*.xml"
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
22
OUTFILE=/tmp/datadog-junit-upload.txt
33
"$(dirname -- "${BASH_SOURCE[0]}")"/upload-junit-to-datadog.sh "$@" >$OUTFILE 2>&1
4-
if [[ $? -ne 0 ]]; then
4+
rc=$?
5+
if [[ $rc -ne 0 ]]; then
56
cat $OUTFILE
67
else
78
grep -E '^\* ' $OUTFILE
89
fi
10+
exit $rc

.gitlab/upload-junit-to-datadog.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ export DATADOG_API_KEY
142142
# Determine which datadog-ci method to use
143143
datadog_ci_cmd=""
144144

145-
# Prefer npm/npx if available and node version is recent enough (>=16)
145+
# Prefer npm/npx if available and node version is recent enough (>=20, required by @datadog/datadog-ci >= 5.13.0)
146146
node_version="$(node --version 2>/dev/null | sed 's/^v//' | cut -d. -f1)"
147-
if [ -n "$node_version" ] && [ "$node_version" -ge 16 ] 2>/dev/null && { command -v npx &> /dev/null || command -v npm &> /dev/null; }; then
147+
if [ -n "$node_version" ] && [ "$node_version" -ge 20 ] 2>/dev/null && { command -v npx &> /dev/null || command -v npm &> /dev/null; }; then
148148
echo "Using npx to run datadog-ci (node v${node_version})"
149149
datadog_ci_cmd="npx --yes @datadog/datadog-ci"
150150
else
@@ -215,8 +215,8 @@ echo "Current directory: $(pwd)"
215215
echo "Running command: ${datadog_ci_cmd} junit upload --service \"${DD_SERVICE}\" --max-concurrency 20 --verbose --tags git.repository_url:https://github.com/DataDog/dd-trace-php ${tags_args} ${xpath_tags_args} ${files_array[*]}"
216216

217217
if ! ${datadog_ci_cmd} junit upload --service "${DD_SERVICE}" --max-concurrency 20 --verbose --tags "git.repository_url:https://github.com/DataDog/dd-trace-php" ${tags_args} ${xpath_tags_args} "${files_array[@]}"; then
218-
echo "Warning: Failed to upload JUnit files" >&2
219-
exit 0
218+
echo "Error: Failed to upload JUnit files" >&2
219+
exit 1
220220
fi
221221

222222
echo "=== JUnit upload completed ==="

0 commit comments

Comments
 (0)