Skip to content

Commit 3112dff

Browse files
LeiyksManuelPalenzuelaDDclaude
authored
test(CI): upload junit reports to datadog (#3521)
* test(CI): upload junit reports to datadog Signed-off-by: Alexandre Rulleau <[email protected]> * fix(CI): normalize paths and set GitHub repository URL in JUnit upload - Replace absolute file paths with paths relative to the repository root before uploading to Datadog - Add git.repository_url tag pointing to GitHub instead of GitLab to ensure Test Optimization features work correctly Co-Authored-By: Claude Opus 4.5 <[email protected]> * fix: restore CODEOWNER file Signed-off-by: Alexandre Rulleau <[email protected]> --------- Signed-off-by: Alexandre Rulleau <[email protected]> Co-authored-by: Manuel Palenzuela Merino <[email protected]> Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent a507818 commit 3112dff

7 files changed

Lines changed: 230 additions & 15 deletions

.gitlab/generate-appsec.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@
142142

143143
TERM=dumb ./gradlew $targets --info -Pbuildscan --scan
144144
TERM=dumb ./gradlew saveCaches --info
145+
after_script:
146+
- mkdir -p "${CI_PROJECT_DIR}/artifacts"
147+
- find appsec/tests/integration/build/test-results -name "*.xml" -exec cp --parents '{}' "${CI_PROJECT_DIR}/artifacts/" \;
148+
- .gitlab/upload-junit-to-datadog.sh "test.source.file:appsec"
149+
artifacts:
150+
reports:
151+
junit: "artifacts/**/test-results/**/TEST-*.xml"
152+
paths:
153+
- "artifacts/"
154+
when: "always"
145155
cache:
146156
- key: "appsec int test cache"
147157
paths:

.gitlab/generate-profiler.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,23 @@
4646
- '# NTS'
4747
- command -v switch-php && switch-php "${PHP_MAJOR_MINOR}"
4848
- cargo build --profile profiler-release --all-features
49-
- (cd tests; php run-tests.php -d "extension=/mnt/ramdisk/cargo/profiler-release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt")
49+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/profiler-tests"
50+
- (cd tests; TEST_PHP_JUNIT="${CI_PROJECT_DIR}/artifacts/profiler-tests/nts-results.xml" php run-tests.php -d "extension=/mnt/ramdisk/cargo/profiler-release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt")
5051

5152
- touch build.rs #make sure `build.rs` gets executed after `switch-php` call
5253

5354
- '# ZTS'
5455
- command -v switch-php && switch-php "${PHP_MAJOR_MINOR}-zts"
5556
- cargo build --profile profiler-release --all-features
56-
- (cd tests; php run-tests.php -d "extension=/mnt/ramdisk/cargo/profiler-release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt")
57+
- (cd tests; TEST_PHP_JUNIT="${CI_PROJECT_DIR}/artifacts/profiler-tests/zts-results.xml" php run-tests.php -d "extension=/mnt/ramdisk/cargo/profiler-release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt")
58+
after_script:
59+
- .gitlab/upload-junit-to-datadog.sh "test.source.file:profiling"
60+
artifacts:
61+
reports:
62+
junit: "artifacts/profiler-tests/*.xml"
63+
paths:
64+
- "artifacts/"
65+
when: "always"
5766

5867
"clippy NTS":
5968
stage: test

.gitlab/generate-shared.php

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@
2828
- mkdir -p tmp/build_php_components_asan && cd tmp/build_php_components_asan
2929
- cmake $([ -f "/etc/debian_version" ] && echo "-DCMAKE_TOOLCHAIN_FILE=../../cmake/asan.cmake") -DCMAKE_BUILD_TYPE=Debug -DDATADOG_PHP_TESTING=ON ../../components
3030
- make -j all
31-
- make test
31+
- mkdir -p "${CI_PROJECT_DIR}/artifacts"
32+
- make test ARGS="--output-junit ${CI_PROJECT_DIR}/artifacts/components-asan-results.xml --output-on-failure"
3233
after_script:
3334
- mkdir -p tmp/artifacts
34-
- cp tmp/build_php_components_asan/Testing/Temporary/LastTest.log tmp/artifacts/LastTestUBSan.log
35+
- cp tmp/build_php_components_asan/Testing/Temporary/LastTest.log tmp/artifacts/LastTestASan.log
36+
- .gitlab/upload-junit-to-datadog.sh "test.source.file:components-rs"
3537
artifacts:
38+
reports:
39+
junit: "artifacts/*-results.xml"
3640
paths:
3741
- tmp/artifacts
42+
- artifacts
43+
when: "always"
3844

3945
"C components UBSAN":
4046
tags: [ "arch:amd64" ]
@@ -46,13 +52,19 @@
4652
- mkdir -p tmp/build_php_components_ubsan && cd tmp/build_php_components_ubsan
4753
- CMAKE_PREFIX_PATH=/opt/catch2 cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake/ubsan.cmake -DCMAKE_BUILD_TYPE=Debug -DDATADOG_PHP_TESTING=ON ../../components
4854
- make -j all
49-
- make test ARGS="--output-on-failure --repeat until-fail:10" # channel is non-deterministic, so run tests a few more times. At the moment, Catch2 tests are not automatically adding labels, so run all tests instead of just channel's: https://github.com/catchorg/Catch2/issues/1590
55+
- mkdir -p "${CI_PROJECT_DIR}/artifacts"
56+
- make test ARGS="--output-junit ${CI_PROJECT_DIR}/artifacts/components-ubsan-results.xml --output-on-failure --repeat until-fail:10" # channel is non-deterministic, so run tests a few more times. At the moment, Catch2 tests are not automatically adding labels, so run all tests instead of just channel's: https://github.com/catchorg/Catch2/issues/1590
5057
after_script:
5158
- mkdir -p tmp/artifacts
52-
- cp tmp/build_php_components_ubsan/Testing/Temporary/LastTest.log tmp/artifacts/LastTestASan.log
59+
- cp tmp/build_php_components_ubsan/Testing/Temporary/LastTest.log tmp/artifacts/LastTestUBSan.log
60+
- .gitlab/upload-junit-to-datadog.sh "test.source.file:components-rs"
5361
artifacts:
62+
reports:
63+
junit: "artifacts/*-results.xml"
5464
paths:
5565
- tmp/artifacts
66+
- artifacts
67+
when: "always"
5668

5769
"Build & Test Tea":
5870
tags: [ "arch:amd64" ]
@@ -67,15 +79,21 @@
6779
script:
6880
- sh .gitlab/build-tea.sh $SWITCH_PHP_VERSION
6981
- cd tmp/build-tea-${SWITCH_PHP_VERSION}
70-
- make test
82+
- mkdir -p "${CI_PROJECT_DIR}/artifacts"
83+
- make test ARGS="--output-junit ${CI_PROJECT_DIR}/artifacts/tea-${SWITCH_PHP_VERSION}-results.xml --output-on-failure"
7184
- grep -e "=== Total [0-9]+ memory leaks detected ===" Testing/Temporary/LastTest.log && exit 1 || true
7285
after_script:
7386
- mkdir -p tmp/artifacts/
74-
- cp tmp/build-tea-${SWITCH_PHP_VERSION}/Testing/Temporary/LastTest.log tmp/artifacts/LastTestASan.log
87+
- cp tmp/build-tea-${SWITCH_PHP_VERSION}/Testing/Temporary/LastTest.log tmp/artifacts/LastTest.log
88+
- .gitlab/upload-junit-to-datadog.sh "test.source.file:zend_abstract_interface"
7589
artifacts:
90+
reports:
91+
junit: "artifacts/*-results.xml"
7692
paths:
7793
- tmp/tea
7894
- tmp/artifacts
95+
- artifacts
96+
when: "always"
7997

8098
.tea_test:
8199
tags: [ "arch:amd64" ]
@@ -89,9 +107,14 @@
89107
after_script:
90108
- mkdir -p tmp/artifacts
91109
- cp tmp/build*/Testing/Temporary/LastTest.log tmp/artifacts/LastTest.log
110+
- .gitlab/upload-junit-to-datadog.sh "test.source.file:zend_abstract_interface"
92111
artifacts:
112+
reports:
113+
junit: "artifacts/*-results.xml"
93114
paths:
94115
- tmp/artifacts
116+
- artifacts
117+
when: "always"
95118

96119
<?php
97120
foreach ($all_minor_major_targets as $major_minor):
@@ -118,7 +141,8 @@
118141
- mkdir -p tmp/build_zai && cd tmp/build_zai
119142
- CMAKE_PREFIX_PATH=/opt/catch2 Tea_ROOT=../../tmp/tea/<?= $switch_php_version ?> cmake <?= $toolchain ?> -DCMAKE_BUILD_TYPE=Debug -DBUILD_ZAI_TESTING=ON -DPhpConfig_ROOT=$(php-config --prefix) ../../zend_abstract_interface
120143
- make -j all
121-
- make test
144+
- mkdir -p "${CI_PROJECT_DIR}/artifacts"
145+
- make test ARGS="--output-junit ${CI_PROJECT_DIR}/artifacts/zai-<?= $major_minor ?>-<?= $switch_php_version ?>-results.xml --output-on-failure"
122146
- grep -e "=== Total [0-9]+ memory leaks detected ===" Testing/Temporary/LastTest.log && exit 1 || true
123147
<?php
124148
endforeach;

.gitlab/generate-tracer.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function after_script($execute_dir = ".", $has_test_agent = false) {
2323
- .gitlab/check_test_agent.sh
2424
<?php endif; ?>
2525
- .gitlab/collect_artifacts.sh "<?= $execute_dir ?>"
26+
- .gitlab/upload-junit-to-datadog.sh "test.source.file:src"
2627
<?php
2728
}
2829

@@ -247,7 +248,9 @@ function before_script_steps($with_docker_auth = false) {
247248
MAX_TEST_PARALLELISM: 2
248249
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
249250
ARCH: "<?= $arch ?>"
251+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests/php-tests.xml"
250252
script:
253+
- mkdir -p "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests"
251254
- make test_c
252255
<?php after_script("tmp/build_extension", has_test_agent: true); ?>
253256

@@ -263,7 +266,9 @@ function before_script_steps($with_docker_auth = false) {
263266
variables:
264267
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
265268
ARCH: "<?= $arch ?>"
269+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
266270
script:
271+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
267272
- make test_internal_api_randomized
268273
<?php after_script(); ?>
269274

@@ -289,7 +294,9 @@ function before_script_steps($with_docker_auth = false) {
289294
variables:
290295
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
291296
ARCH: "amd64"
297+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
292298
script:
299+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
293300
- make test_with_init_hook
294301
<?php after_script(); ?>
295302

@@ -311,7 +318,9 @@ function before_script_steps($with_docker_auth = false) {
311318
MAX_TEST_PARALLELISM: 4
312319
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
313320
ARCH: "amd64"
321+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests/php-tests.xml"
314322
script:
323+
- mkdir -p "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests"
315324
- make test_c_observer
316325
<?php after_script("tmp/build_extension", has_test_agent: true); ?>
317326
<?php endif; ?>
@@ -328,7 +337,9 @@ function before_script_steps($with_docker_auth = false) {
328337
variables:
329338
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
330339
ARCH: "amd64"
340+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
331341
script:
342+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
332343
- make test_opcache
333344
<?php after_script(); ?>
334345
<?php
@@ -379,7 +390,7 @@ function before_script_steps($with_docker_auth = false) {
379390
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
380391
ARCH: "amd64"
381392
script:
382-
- make test_unit <?= ASSERT_NO_MEMLEAKS ?>
393+
- make test_unit PHPUNIT_JUNIT="artifacts/tests/php-tests.xml" <?= ASSERT_NO_MEMLEAKS ?>
383394
<?php after_script(); ?>
384395

385396
"API unit tests: [<?= $major_minor ?>]":
@@ -394,7 +405,9 @@ function before_script_steps($with_docker_auth = false) {
394405
variables:
395406
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
396407
ARCH: "amd64"
408+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
397409
script:
410+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
398411
- make test_api_unit <?= ASSERT_NO_MEMLEAKS ?>
399412
<?php after_script(); ?>
400413

@@ -410,6 +423,7 @@ function before_script_steps($with_docker_auth = false) {
410423
variables:
411424
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
412425
ARCH: "amd64"
426+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
413427
<?php if (version_compare($major_minor, "7.4", ">=")): ?>
414428
KUBERNETES_CPU_REQUEST: 8
415429
MAX_TEST_PARALLELISM: 16
@@ -418,6 +432,7 @@ function before_script_steps($with_docker_auth = false) {
418432
timeout: 40m
419433
<?php endif; ?>
420434
script:
435+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
421436
- make test_c_disabled <?= ASSERT_NO_MEMLEAKS ?>
422437
<?php after_script(); ?>
423438

@@ -433,7 +448,9 @@ function before_script_steps($with_docker_auth = false) {
433448
variables:
434449
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
435450
ARCH: "amd64"
451+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
436452
script:
453+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
437454
- make test_internal_api_randomized
438455
<?php after_script(); ?>
439456

@@ -449,7 +466,9 @@ function before_script_steps($with_docker_auth = false) {
449466
variables:
450467
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
451468
ARCH: "amd64"
469+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests/php-tests.xml"
452470
script:
471+
- mkdir -p "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests"
453472
- make test_opcache
454473
<?php after_script("tmp/build_extension"); ?>
455474

@@ -472,7 +491,7 @@ function before_script_steps($with_docker_auth = false) {
472491
DD_TRACE_WARN_LEGACY_DD_TRACE: "0"
473492
DD_TRACE_GIT_METADATA_ENABLED: "0"
474493
REPORT_EXIT_STATUS: "1"
475-
TEST_PHP_JUNIT: "/tmp/artifacts/tests/php-tests.xml"
494+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
476495
SKIP_ONLINE_TEST: "1"
477496
<?php if (version_compare($major_minor, "7.2", ">=")): /* too expensive */ ?>
478497
DD_INSTRUMENTATION_TELEMETRY_ENABLED: 0
@@ -516,7 +535,7 @@ function before_script_steps($with_docker_auth = false) {
516535
- make composer_tests_update
517536
- .gitlab/wait-for-service-ready.sh
518537
script:
519-
- DD_TRACE_AGENT_TIMEOUT=1000 make $MAKE_TARGET RUST_DEBUG_BUILD=1 PHPUNIT_OPTS="--log-junit artifacts/tests/results.xml" <?= ASSERT_NO_MEMLEAKS ?>
538+
- DD_TRACE_AGENT_TIMEOUT=1000 make $MAKE_TARGET RUST_DEBUG_BUILD=1 PHPUNIT_JUNIT="artifacts/tests/results.xml" <?= ASSERT_NO_MEMLEAKS ?>
520539
<?php after_script(".", true); ?>
521540
- find tests -type f \( -name 'phpunit_error.log' -o -name 'nginx_*.log' -o -name 'apache_*.log' -o -name 'php_fpm_*.log' -o -name 'dd_php_error.log' \) -exec cp --parents '{}' artifacts \;
522541
- make tested_versions && cp tests/tested_versions/tested_versions.json artifacts/tested_versions_${MAKE_TARGET}_${PHP_MAJOR_MINOR}_${DD_TRACE_TEST_SAPI:-cli}.json
@@ -697,7 +716,7 @@ function before_script_steps($with_docker_auth = false) {
697716
- php /usr/local/src/php/run-tests.php -g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP -p $(which php) --show-all -d zend_extension=xdebug-<?= $xdebug ?>.so "tests/xdebug/<?= $xdebug[0] == 2 ? $xdebug : "3.0.0" ?>"
698717
<?php if ($xdebug != "2.7.2" && $xdebug != "2.9.2"): ?>
699718
- '# Run unit tests with xdebug'
700-
- TEST_EXTRA_INI='-d zend_extension=xdebug-<?= $xdebug ?>.so' make test_unit RUST_DEBUG_BUILD=1 PHPUNIT_OPTS="--log-junit test-results/php-unit/results_unit.xml"
719+
- TEST_EXTRA_INI='-d zend_extension=xdebug-<?= $xdebug ?>.so' make test_unit RUST_DEBUG_BUILD=1 PHPUNIT_JUNIT="test-results/php-unit/results_unit.xml"
701720
<?php endif; ?>
702721
<?php after_script(has_test_agent: true); ?>
703722

.gitlab/run_php_language_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if [[ ! "${XFAIL_LIST:-none}" == "none" ]]; then
1515
fi
1616

1717
cd /usr/local/src/php
18-
mkdir -p /tmp/artifacts/tests
18+
mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
1919
# replace all hardcoded object ids in tests by %d as ddtrace creates its own objects
2020
php <<'PHP'
2121
<?php

0 commit comments

Comments
 (0)