Skip to content

Commit c4d3680

Browse files
committed
test(CI): upload junit reports to datadog
Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com>
1 parent 867b36c commit c4d3680

File tree

9 files changed

+224
-35
lines changed

9 files changed

+224
-35
lines changed

.github/CODEOWNERS

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

.gitlab/generate-appsec.php

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

155155
TERM=dumb ./gradlew $targets --info -Pbuildscan --scan
156156
TERM=dumb ./gradlew saveCaches --info
157+
after_script:
158+
- mkdir -p "${CI_PROJECT_DIR}/artifacts"
159+
- find appsec/tests/integration/build/test-results -name "*.xml" -exec cp --parents '{}' "${CI_PROJECT_DIR}/artifacts/" \;
160+
- .gitlab/upload-junit-to-datadog.sh "test.source.file:appsec"
161+
artifacts:
162+
reports:
163+
junit: "artifacts/**/test-results/**/TEST-*.xml"
164+
paths:
165+
- "artifacts/"
166+
when: "always"
157167
cache:
158168
- key: "appsec int test cache"
159169
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

@@ -246,7 +247,9 @@ function before_script_steps() {
246247
MAX_TEST_PARALLELISM: 2
247248
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
248249
ARCH: "<?= $arch ?>"
250+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests/php-tests.xml"
249251
script:
252+
- mkdir -p "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests"
250253
- make test_c
251254
<?php after_script("tmp/build_extension", has_test_agent: true); ?>
252255

@@ -262,7 +265,9 @@ function before_script_steps() {
262265
variables:
263266
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
264267
ARCH: "<?= $arch ?>"
268+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
265269
script:
270+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
266271
- make test_internal_api_randomized
267272
<?php after_script(); ?>
268273

@@ -288,7 +293,9 @@ function before_script_steps() {
288293
variables:
289294
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
290295
ARCH: "amd64"
296+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
291297
script:
298+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
292299
- make test_with_init_hook
293300
<?php after_script(); ?>
294301

@@ -310,7 +317,9 @@ function before_script_steps() {
310317
MAX_TEST_PARALLELISM: 4
311318
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
312319
ARCH: "amd64"
320+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests/php-tests.xml"
313321
script:
322+
- mkdir -p "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests"
314323
- make test_c_observer
315324
<?php after_script("tmp/build_extension", has_test_agent: true); ?>
316325
<?php endif; ?>
@@ -327,7 +336,9 @@ function before_script_steps() {
327336
variables:
328337
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
329338
ARCH: "amd64"
339+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
330340
script:
341+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
331342
- make test_opcache
332343
<?php after_script(); ?>
333344
<?php
@@ -378,7 +389,7 @@ function before_script_steps() {
378389
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
379390
ARCH: "amd64"
380391
script:
381-
- make test_unit <?= ASSERT_NO_MEMLEAKS ?>
392+
- make test_unit PHPUNIT_JUNIT="artifacts/tests/php-tests.xml" <?= ASSERT_NO_MEMLEAKS ?>
382393
<?php after_script(); ?>
383394

384395
"API unit tests: [<?= $major_minor ?>]":
@@ -393,7 +404,9 @@ function before_script_steps() {
393404
variables:
394405
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
395406
ARCH: "amd64"
407+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
396408
script:
409+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
397410
- make test_api_unit <?= ASSERT_NO_MEMLEAKS ?>
398411
<?php after_script(); ?>
399412

@@ -409,6 +422,7 @@ function before_script_steps() {
409422
variables:
410423
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
411424
ARCH: "amd64"
425+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
412426
<?php if (version_compare($major_minor, "7.4", ">=")): ?>
413427
KUBERNETES_CPU_REQUEST: 8
414428
MAX_TEST_PARALLELISM: 16
@@ -417,6 +431,7 @@ function before_script_steps() {
417431
timeout: 40m
418432
<?php endif; ?>
419433
script:
434+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
420435
- make test_c_disabled <?= ASSERT_NO_MEMLEAKS ?>
421436
<?php after_script(); ?>
422437

@@ -432,7 +447,9 @@ function before_script_steps() {
432447
variables:
433448
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
434449
ARCH: "amd64"
450+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
435451
script:
452+
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
436453
- make test_internal_api_randomized
437454
<?php after_script(); ?>
438455

@@ -448,7 +465,9 @@ function before_script_steps() {
448465
variables:
449466
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
450467
ARCH: "amd64"
468+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests/php-tests.xml"
451469
script:
470+
- mkdir -p "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests"
452471
- make test_opcache
453472
<?php after_script("tmp/build_extension"); ?>
454473

@@ -471,7 +490,7 @@ function before_script_steps() {
471490
DD_TRACE_WARN_LEGACY_DD_TRACE: "0"
472491
DD_TRACE_GIT_METADATA_ENABLED: "0"
473492
REPORT_EXIT_STATUS: "1"
474-
TEST_PHP_JUNIT: "/tmp/artifacts/tests/php-tests.xml"
493+
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
475494
SKIP_ONLINE_TEST: "1"
476495
<?php if (version_compare($major_minor, "7.2", ">=")): /* too expensive */ ?>
477496
DD_INSTRUMENTATION_TELEMETRY_ENABLED: 0
@@ -504,7 +523,7 @@ function before_script_steps() {
504523
- make composer_tests_update
505524
- .gitlab/wait-for-service-ready.sh
506525
script:
507-
- DD_TRACE_AGENT_TIMEOUT=1000 make $MAKE_TARGET RUST_DEBUG_BUILD=1 PHPUNIT_OPTS="--log-junit artifacts/tests/results.xml" <?= ASSERT_NO_MEMLEAKS ?>
526+
- DD_TRACE_AGENT_TIMEOUT=1000 make $MAKE_TARGET RUST_DEBUG_BUILD=1 PHPUNIT_JUNIT="artifacts/tests/results.xml" <?= ASSERT_NO_MEMLEAKS ?>
508527
<?php after_script(".", true); ?>
509528
- 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 \;
510529
- make tested_versions && cp tests/tested_versions/tested_versions.json artifacts/tested_versions_${MAKE_TARGET}_${PHP_MAJOR_MINOR}_${DD_TRACE_TEST_SAPI:-cli}.json
@@ -685,7 +704,7 @@ function before_script_steps() {
685704
- 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" ?>"
686705
<?php if ($xdebug != "2.7.2" && $xdebug != "2.9.2"): ?>
687706
- '# Run unit tests with xdebug'
688-
- 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"
707+
- 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"
689708
<?php endif; ?>
690709
<?php after_script(has_test_agent: true); ?>
691710

.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)