-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathgenerate-tracer.php
More file actions
821 lines (765 loc) · 26 KB
/
Copy pathgenerate-tracer.php
File metadata and controls
821 lines (765 loc) · 26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
<?php
include "generate-common.php";
preg_match('(^\.services(.*?)\n(\S|\Z))ms', file_get_contents(__DIR__ . "/generate-common.php"), $m);
preg_match_all('(^ (\S*):)m', $m[1], $m, PREG_PATTERN_ORDER);
$services = array_combine($m[1], $m[1]);
const ASSERT_NO_MEMLEAKS = ' 2>&1 | tee /dev/stderr | { ! grep -qe "=== Total [0-9]+ memory leaks detected ==="; }';
function after_script($execute_dir = ".", $has_test_agent = false) {
?>
artifacts:
reports:
junit: "artifacts/tests/php-tests.xml"
paths:
- "artifacts/"
when: "always"
after_script:
<?php if ($has_test_agent): ?>
- .gitlab/check_test_agent.sh
<?php endif; ?>
- .gitlab/collect_artifacts.sh "<?= $execute_dir ?>"
- .gitlab/silent-upload-junit-to-datadog.sh "test.source.file:src/"
<?php
}
function sidecar_logs() {
?>
_DD_DEBUG_SIDECAR_LOG_LEVEL: trace
_DD_DEBUG_SIDECAR_LOG_METHOD: "file://${CI_PROJECT_DIR}/artifacts/sidecar.log"
<?php
}
function before_script_steps($with_docker_auth = false) {
if ($with_docker_auth) dockerhub_login();
unset_dd_runner_env_vars();
?>
- switch-php "${SWITCH_PHP_VERSION}"
- git config --global --add safe.directory "${CI_PROJECT_DIR}"
- git config --global --add safe.directory "${CI_PROJECT_DIR}/*"
- mkdir -p tmp/build_extension/modules artifacts
- mv "modules/${PHP_MAJOR_MINOR}-${SWITCH_PHP_VERSION}-${host_os}-${ARCH}/ddtrace.so" "tmp/build_extension/modules/"
<?php
}
?>
stages:
- compile
- test
- "integrations test"
- "web test"
- "aggregate versions"
#variables:
# CI_DEBUG_SERVICES: "true"
<?php function agent_httpbin_service() { ?>
- !reference [.services, test-agent]
- !reference [.services, request-replayer]
- !reference [.services, httpbin-integration]
<?php } ?>
"compile extension: debug":
stage: compile
tags: [ "arch:${ARCH}" ]
image: registry.ddbuild.io/ci/dd-trace-php/dd-trace-ci:php-${PHP_MAJOR_MINOR}_bookworm-10
parallel:
matrix:
- PHP_MAJOR_MINOR: *all_minor_major_targets
ARCH: *arch_targets
variables:
host_os: linux-gnu
WITH_ASAN: "0"
CARGO_HOME: "/rust/cargo/"
SWITCH_PHP_VERSION: "debug"
KUBERNETES_CPU_REQUEST: 12
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 8Gi
script: .gitlab/compile_extension.sh
after_script: |
export out_dir="modules/${PHP_MAJOR_MINOR}-${SWITCH_PHP_VERSION}-${host_os}-${ARCH}/"
mkdir -p "${out_dir}"
mv "tmp/build_extension/modules/ddtrace.so" "${out_dir}"
cache:
- key:
prefix: $CI_JOB_NAME
files:
- Cargo.lock
- Cargo.toml
paths:
- /rust/cargo/
artifacts:
paths:
- "VERSION"
- "modules/"
"compile extension: debug-zts-asan":
extends: "compile extension: debug"
variables:
WITH_ASAN: "1"
SWITCH_PHP_VERSION: "debug-zts-asan"
parallel:
matrix:
- PHP_MAJOR_MINOR: *asan_minor_major_targets
ARCH: *arch_targets
"windows test_c":
stage: test
tags: [ "windows-v2:2019"]
needs: []
parallel:
matrix:
- PHP_MAJOR_MINOR: <?= json_encode($windows_minor_major_targets) ?>
variables:
CONTAINER_NAME: $CI_JOB_NAME_SLUG
GIT_STRATEGY: none
IMAGE: "registry.ddbuild.io/ci/dd-trace-php/dd-trace-ci:php-${PHP_MAJOR_MINOR}_windows"
script: |
<?php windows_git_setup() ?>
mkdir dumps
$names = @('httpbin-integration','request-replayer', $env:CONTAINER_NAME)
foreach ($n in $names) { try { docker rm -f $n | Out-Null } catch {} }
try { docker network rm net | Out-Null } catch {}
# Start the container network and services
docker network create -d "nat" -o com.docker.network.windowsshim.dnsservers="1.1.1.1" net
docker run --network net -d --name httpbin-integration registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:httpbin-windows
docker run --network net -d --name request-replayer registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-request-replayer-2.0-windows
docker run -v ${pwd}:C:\Users\ContainerAdministrator\app --network net -d --name ${CONTAINER_NAME} ${IMAGE} ping -t localhost
# Build nts
docker exec ${CONTAINER_NAME} powershell.exe "cd app; switch-php nts; C:\php\SDK\phpize.bat; .\configure.bat --enable-debug-pack; nmake"
# Set test environment variables
docker exec ${CONTAINER_NAME} powershell.exe "setx DD_AUTOLOAD_NO_COMPILE true; setx DATADOG_HAVE_DEV_ENV 1; setx DD_TRACE_GIT_METADATA_ENABLED 0"
# Exclude tests that deadlock the php-cgi SKIPIF skip-task on Windows.
<?php foreach ([
"tests/ext/sandbox/hook_function/hook_does_not_leak_error.phpt",
] as $win_excluded_test): ?>
docker exec ${CONTAINER_NAME} powershell.exe "Remove-Item -Force -ErrorAction SilentlyContinue C:\Users\ContainerAdministrator\app\<?= str_replace('/', '\\', $win_excluded_test) ?>"
<?php endforeach ?>
# Run extension tests
docker exec ${CONTAINER_NAME} powershell.exe 'cd app; $env:_DD_DEBUG_SIDECAR_LOG_LEVEL=trace; $env:_DD_DEBUG_SIDECAR_LOG_METHOD="""file://${pwd}\sidecar.log"""; C:\php\php.exe -n -d memory_limit=-1 -d output_buffering=0 run-tests.php -g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP --show-diff -p C:\php\php.exe -d "extension=${pwd}\x64\Release\php_ddtrace.dll" "${pwd}\tests\ext"'
after_script:
- |
docker exec ${CONTAINER_NAME} cmd.exe /s /c xcopy /y /c /s /e C:\ProgramData\Microsoft\Windows\WER\ReportQueue .\app\dumps\
exit 0
- |
# Try to stop the container, don't care if we fail
try { docker stop -t 5 ${CONTAINER_NAME} } catch { }
- 'powershell -NoProfile -Command "try { docker logs request-replayer } catch {}"'
- 'powershell -NoProfile -Command "try { docker logs httpbin-integration } catch {}"'
- 'powershell -NoProfile -Command "try { docker stop -t 15 request-replayer } catch {}"'
- 'powershell -NoProfile -Command "try { docker rm -f request-replayer } catch {}"'
- 'powershell -NoProfile -Command "try { docker stop -t 15 httpbin-integration } catch {}"'
- 'powershell -NoProfile -Command "try { docker rm -f httpbin-integration } catch {}"'
- 'powershell -NoProfile -Command "try { docker network rm net } catch {}"'
artifacts:
paths:
- sidecar.log
- x64/Release/php_ddtrace.dll
- x64/Release/php_ddtrace.pdb
- dumps
"Prepare code":
stage: compile
image: registry.ddbuild.io/images/mirror/php:8.2-cli
tags: [ "arch:amd64" ]
needs: []
variables:
KUBERNETES_CPU_REQUEST: 1
KUBERNETES_MEMORY_REQUEST: 2Gi
before_script:
- apt update && apt install -y unzip
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php && mv composer.phar /usr/local/bin/composer
- composer update --no-interaction
script:
- make generate
artifacts:
paths:
- src/bridge/_generated_*.php
.base_test:
stage: test
tags: [ "arch:${ARCH}" ]
image: registry.ddbuild.io/ci/dd-trace-php/dd-trace-ci:php-${PHP_MAJOR_MINOR}_bookworm-10
timeout: 60m
interruptible: true
rules:
- if: $CI_COMMIT_BRANCH == "master"
interruptible: false
- when: on_success
variables:
host_os: linux-gnu
COMPOSER_MEMORY_LIMIT: "-1"
DD_TRACE_ASSUME_COMPILED: "1"
DDAGENT_HOSTNAME: "127.0.0.1"
MAX_TEST_PARALLELISM: 8
TEST_FILES_DIR: "."
DATADOG_HAVE_DEV_ENV: 1
HTTPBIN_HOSTNAME: httpbin-integration
HTTPBIN_PORT: 8080
RUST_BACKTRACE: 1
<?php sidecar_logs(); ?>
before_script:
<?php before_script_steps(true) ?>
- .gitlab/wait-for-service-ready.sh
.asan_test:
extends: .base_test
variables:
SWITCH_PHP_VERSION: debug-zts-asan
ASAN_OPTIONS: abort_on_error=1:disable_coredump=0:unmap_shadow_on_exit=1
<?php
foreach ($asan_minor_major_targets as $major_minor):
foreach ($arch_targets as $arch):
?>
"ASAN test_c: [<?= $major_minor ?>, <?= $arch ?>]":
extends: .asan_test
services:
<?php agent_httpbin_service() ?>
needs:
- job: "compile extension: debug-zts-asan"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "<?= $arch ?>"
artifacts: true
variables:
WAIT_FOR: test-agent:9126
KUBERNETES_CPU_REQUEST: 6
KUBERNETES_CPU_LIMIT: 6
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 4Gi
MAX_TEST_PARALLELISM: 2
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "<?= $arch ?>"
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests/php-tests.xml"
script:
- mkdir -p "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests"
- make test_c
<?php after_script("tmp/build_extension", has_test_agent: true); ?>
"ASAN Internal api randomized tests: [<?= $major_minor ?>, <?= $arch ?>]":
extends: .asan_test
needs:
- job: "compile extension: debug-zts-asan"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "<?= $arch ?>"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "<?= $arch ?>"
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
script:
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
- make test_internal_api_randomized
<?php after_script(); ?>
<?php
endforeach;
endforeach;
?>
<?php
foreach ($asan_minor_major_targets as $major_minor):
?>
"ASAN init hook tests: [<?= $major_minor ?>]":
extends: .asan_test
services:
- !reference [.services, httpbin-integration]
needs:
- job: "compile extension: debug-zts-asan"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
script:
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
- make test_with_init_hook
<?php after_script(); ?>
<?php if (version_compare($major_minor, "8.0", ">=")): ?>
"ASAN test_c with multiple observers: [<?= $major_minor ?>]":
extends: .asan_test
services:
<?php agent_httpbin_service() ?>
needs:
- job: "compile extension: debug-zts-asan"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
WAIT_FOR: test-agent:9126
KUBERNETES_CPU_REQUEST: 12
MAX_TEST_PARALLELISM: 4
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests/php-tests.xml"
ASAN_OPTIONS: "abort_on_error=1:disable_coredump=0:unmap_shadow_on_exit=1:detect_stack_use_after_return=0"
script:
- mkdir -p "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests"
- make test_c_observer
<?php after_script("tmp/build_extension", has_test_agent: true); ?>
<?php endif; ?>
"ASAN Opcache tests: [<?= $major_minor ?>]":
extends: .asan_test
needs:
- job: "compile extension: debug-zts-asan"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
script:
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
- make test_opcache
<?php after_script(); ?>
<?php
endforeach;
?>
.debug_test:
extends: .base_test
variables:
SWITCH_PHP_VERSION: debug
<?php
foreach ($all_minor_major_targets as $major_minor):
?>
<?php /* Normal and valgrind passes run as separate jobs: valgrind is far
slower, so run in parallel. */ ?>
"test_extension_ci: [<?= $major_minor ?>]":
extends: .debug_test
services:
<?php agent_httpbin_service() ?>
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
WAIT_FOR: test-agent:9126
KUBERNETES_CPU_REQUEST: 12
<?php if (version_compare($major_minor, "7.4", ">=")): ?>
# Match the CPU request.
MAX_TEST_PARALLELISM: 12
<?php endif; ?>
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
KUBERNETES_POD_ANNOTATIONS_1: "ci.ddbuild.io/enforce-static-cpus=true"
<?php if (version_compare($major_minor, "7.4", ">=")): ?>
timeout: 45m
<?php else: ?>
# run-tests.php only gets -j on PHP >= 7.4 (RUN_TESTS_IS_PARALLEL in the
# Makefile), so these versions run serially and need the larger budget.
timeout: 120m
<?php endif; ?>
script:
- make test_extension_ci_normal
<?php after_script("tmp/build_extension", has_test_agent: true); ?>
"test_extension_ci: [<?= $major_minor ?>, valgrind]":
extends: .debug_test
services:
<?php agent_httpbin_service() ?>
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
WAIT_FOR: test-agent:9126
KUBERNETES_CPU_REQUEST: 12
# Below the CPU request: each worker spawns its own valgrind process.
MAX_TEST_PARALLELISM: 4
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
KUBERNETES_POD_ANNOTATIONS_1: "ci.ddbuild.io/enforce-static-cpus=true"
timeout: 120m
script:
- make test_extension_ci_valgrind
<?php after_script("tmp/build_extension", has_test_agent: true); ?>
"Unit tests: [<?= $major_minor ?>]":
extends: .debug_test
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
script:
- make test_unit PHPUNIT_JUNIT="artifacts/tests/php-tests.xml" <?= ASSERT_NO_MEMLEAKS ?>
<?php after_script(); ?>
<?php if (version_compare($major_minor, "8.0", ">=")): ?>
"Feature flags tests: [<?= $major_minor ?>]":
extends: .debug_test
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
- job: "Prepare code"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
script:
- make test_featureflags PHPUNIT_JUNIT="artifacts/tests/php-tests.xml" <?= ASSERT_NO_MEMLEAKS ?>
<?php after_script(); ?>
<?php endif; ?>
"API unit tests: [<?= $major_minor ?>]":
extends: .debug_test
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
script:
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
- make test_api_unit <?= ASSERT_NO_MEMLEAKS ?>
<?php after_script(); ?>
"Disabled test_c run: [<?= $major_minor ?>]":
extends: .debug_test
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
<?php if (version_compare($major_minor, "7.4", ">=")): ?>
KUBERNETES_CPU_REQUEST: 8
MAX_TEST_PARALLELISM: 16
<?php else: /* no test parallelism */ ?>
KUBERNETES_CPU_REQUEST: 1
timeout: 40m
<?php endif; ?>
script:
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
- make test_c_disabled <?= ASSERT_NO_MEMLEAKS ?>
<?php after_script(); ?>
"Internal api randomized tests: [<?= $major_minor ?>]":
extends: .debug_test
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
script:
- mkdir -p "${CI_PROJECT_DIR}/artifacts/tests"
- make test_internal_api_randomized
<?php after_script(); ?>
"Opcache tests: [<?= $major_minor ?>]":
extends: .debug_test
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests/php-tests.xml"
script:
- mkdir -p "${CI_PROJECT_DIR}/tmp/build_extension/artifacts/tests"
- make test_opcache
<?php after_script("tmp/build_extension"); ?>
"PHP Language Tests: [<?= $major_minor ?>]":
extends: .debug_test
services:
- !reference [.services, test-agent]
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
DD_TRACE_STARTUP_LOGS: "0"
DD_TRACE_WARN_CALL_STACK_DEPTH: "0"
DD_TRACE_WARN_LEGACY_DD_TRACE: "0"
DD_TRACE_GIT_METADATA_ENABLED: "0"
REPORT_EXIT_STATUS: "1"
TEST_PHP_JUNIT: "${CI_PROJECT_DIR}/artifacts/tests/php-tests.xml"
SKIP_ONLINE_TESTS: "1"
WAIT_FOR: test-agent:9126
<?php if (version_compare($major_minor, "7.4", ">=")): ?>
KUBERNETES_CPU_REQUEST: 8
KUBERNETES_CPU_LIMIT: 8
KUBERNETES_MEMORY_REQUEST: 7Gi
KUBERNETES_MEMORY_LIMIT: 7Gi
<?php else: ?>
KUBERNETES_CPU_REQUEST: 1
KUBERNETES_CPU_LIMIT: 1
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 4Gi
<?php endif; ?>
KUBERNETES_HELPER_CPU_REQUEST: 1
KUBERNETES_HELPER_CPU_LIMIT: 1
KUBERNETES_HELPER_MEMORY_REQUEST: 1Gi
KUBERNETES_HELPER_MEMORY_LIMIT: 1Gi
KUBERNETES_POD_ANNOTATIONS_1: "ci.ddbuild.io/enforce-static-cpus=true"
<?php if (version_compare($major_minor, "7.2", ">=")): /* too expensive */ ?>
DD_INSTRUMENTATION_TELEMETRY_ENABLED: 0
<?php endif; ?>
timeout: 40m
script:
- make install_all
- export XFAIL_LIST="dockerfiles/ci/xfail_tests/${PHP_MAJOR_MINOR}.list"
- .gitlab/run_php_language_tests.sh
<?php after_script("/usr/local/src/php"); ?>
<?php
endforeach;
?>
.cli_integration_test:
extends: .base_test
variables:
DD_TRACE_TEST_SAPI: cli-server
COMPOSER_PROCESS_TIMEOUT: 0
KUBERNETES_CPU_REQUEST: 2 # generally one for PHP and one for the webserver
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 4Gi
SWITCH_PHP_VERSION: debug
COMPOSER_VERSION: 2
before_script:
<?php before_script_steps(true) ?>
- if [[ "$MAKE_TARGET" != "test_composer" ]] || ! [[ "$PHP_MAJOR_MINOR" =~ 8.[01] ]]; then sudo composer self-update --$COMPOSER_VERSION --no-interaction; fi
- COMPOSER_MEMORY_LIMIT=-1 composer update --no-interaction # disable composer memory limit completely
- make composer_tests_update
- .gitlab/wait-for-service-ready.sh
script:
# The Fabric proxy changes network failure semantics in integration tests.
- unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy ALL_PROXY all_proxy
- DD_TRACE_AGENT_TIMEOUT=1000 make $MAKE_TARGET RUST_DEBUG_BUILD=1 PHPUNIT_JUNIT="artifacts/tests/results.xml" <?= ASSERT_NO_MEMLEAKS ?>
<?php after_script(".", true); ?>
- 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 \;
- make tested_versions && cp tests/tested_versions/tested_versions.json artifacts/tested_versions_${MAKE_TARGET}_${PHP_MAJOR_MINOR}_${DD_TRACE_TEST_SAPI:-cli}.json
<?php
// specific service maps:
$services["elasticsearch1"] = "elasticsearch2";
$services["elasticsearch8"] = "elasticsearch7";
$services["elasticsearch_latest"] = "elasticsearch7";
$services["magento"] = "elasticsearch7";
$services["deferred_loading"] = "mysql";
$services["deferred_loadin"] = "redis";
$services["pdo"] = "mysql";
$services["kafka"] = ["kafka", "zookeeper"]; // Overwrite auto-generated entry
$jobs = [];
preg_match_all('(^TEST_(?<type>INTEGRATIONS|WEB)_(?<major>\d+)(?<minor>\d)[^\n]+(?<targets>.*?)^(?!\t))ms', file_get_contents(__DIR__ . "/../Makefile"), $matches, PREG_SET_ORDER);
foreach ($matches as $m) {
$major_minor = "{$m["major"]}.{$m["minor"]}";
$type = strtolower($m["type"]);
preg_match_all('(\t\K[a-z0-9_]+)', $m["targets"], $targets, PREG_PATTERN_ORDER);
foreach ($targets[0] as $target) {
$jobs[$type][$target][] = $major_minor;
}
}
foreach ($jobs as $type => $type_jobs):
foreach ($type_jobs as $target => $versions):
foreach ($versions as $major_minor):
$sapis = $type == "web" && version_compare($major_minor, "7.2", ">=") ? ["cli-server", "cgi-fcgi", "apache2handler"] : [""];
if ($target == "test_web_custom" && in_array("cli-server", $sapis)) {
$sapis[] = "fpm-fcgi";
}
foreach ($sapis as $sapi):
?>
"<?= $target ?>: [<?= $major_minor, $sapi ? ", $sapi" : "" ?>]":
extends: .cli_integration_test
stage: "<?= $type ?> test"
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
- job: "Prepare code"
artifacts: true
services:
<?php agent_httpbin_service() ?>
<?php if ($type == "web"): ?>
- !reference [.services, mysql]
<?php endif; ?>
<?php
foreach ($services as $part => $service) {
if (str_contains($target, $part)) {
foreach ((array)$service as $svc) {
echo " - !reference [.services, $svc]\n";
}
}
}
?>
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
MAKE_TARGET: "<?= $target ?>"
ARCH: "amd64"
<?php if ($sapi): ?>
DD_TRACE_TEST_SAPI: "<?= $sapi ?>"
<?php endif; ?>
<?php if (str_contains($target, "kafka")): ?>
WAIT_FOR: zookeeper:2181 kafka-integration:9092
CI_DEBUG_SERVICES: "true"
<?php endif; ?>
<?php if (str_contains($target, "sqlsrv")): ?>
WAIT_FOR: sqlsrv-integration:1433
<?php endif; ?>
<?php if (preg_match("(test_web_symfony_(2|30|33|40))", $target)): ?>
COMPOSER_VERSION: 2.2
<?php endif; ?>
<?php if (preg_match("(test_web_laravel_octane)", $target)): ?>
KUBERNETES_MEMORY_REQUEST: 6Gi
KUBERNETES_MEMORY_LIMIT: 6Gi
<?php endif; ?>
<?php
endforeach;
endforeach;
endforeach;
endforeach;
?>
<?php
foreach ($all_minor_major_targets as $major_minor):
foreach (["test_auto_instrumentation", "test_composer", "test_integration"] as $test):
?>
"<?= $test ?>: [<?= $major_minor ?>]":
extends: .cli_integration_test
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
- job: "Prepare code"
artifacts: true
services:
<?php agent_httpbin_service() ?>
- !reference [.services, mongodb]
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
MAKE_TARGET: "<?= $test ?>"
ARCH: "amd64"
<?php
endforeach;
?>
<?php foreach(["cli-server", "cgi-fcgi"] as $sapi): ?>
"test_distributed_tracing: [<?= $major_minor ?>, <?= $sapi ?>]":
extends: .cli_integration_test
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
- job: "Prepare code"
artifacts: true
services:
<?php agent_httpbin_service() ?>
- !reference [.services, mongodb]
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
MAKE_TARGET: "test_distributed_tracing"
ARCH: "amd64"
<?php if ($sapi == "cgi-fcgi"): ?>
DD_DISTRIBUTED_TRACING: "false"
<?php endif; ?>
<?php
endforeach;
endforeach;
?>
<?php
$xdebug_test_matrix = [
["7.0", "2.7.2"],
["7.1", "2.9.2"],
["7.1", "2.9.5"],
["7.2", "2.9.2"],
["7.2", "2.9.5"],
["7.3", "2.9.2"],
["7.3", "2.9.5"],
["7.4", "2.9.2"],
["7.4", "2.9.5"],
["8.0", "3.0.0"],
["8.1", "3.1.0"],
["8.2", "3.2.2"],
["8.3", "3.3.2"],
["8.4", "3.4.0"],
// ["8.5", "3.5.0"], Xdebug not supported yet on 8.5
];
foreach ($xdebug_test_matrix as [$major_minor, $xdebug]):
?>
"xDebug tests: [<?= $major_minor ?>, <?= $xdebug ?>]":
extends: .debug_test
services:
<?php agent_httpbin_service() ?>
needs:
- job: "compile extension: debug"
parallel:
matrix:
- PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
artifacts: true
variables:
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
ARCH: "amd64"
REPORT_EXIT_STATUS: "1"
script:
- make install_all
- '# Run xdebug tests'
- 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" ?>"
<?php if ($xdebug != "2.7.2" && $xdebug != "2.9.2"): ?>
- '# Run unit tests with xdebug'
- 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"
<?php endif; ?>
<?php after_script(has_test_agent: true); ?>
<?php endforeach; ?>
"aggregate tested versions":
stage: "aggregate versions"
image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.06-1
tags: [ "arch:amd64" ]
when: always
id_tokens:
DDOCTOSTS_ID_TOKEN:
aud: dd-octo-sts
script:
- git config --global --add safe.directory "$CI_PROJECT_DIR"
- git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- git config --global user.name "github-actions[bot]"
- dd-octo-sts debug --scope DataDog/dd-trace-php --policy gitlab-ci-aggregate-versions
- dd-octo-sts token --scope DataDog/dd-trace-php --policy gitlab-ci-aggregate-versions > github_token.txt
- export GITHUB_TOKEN=$(cat github_token.txt)
- ./tooling/tested_versions/create_or_update_supported_versions_pr.sh
after_script:
# Revoke the GitHub token after usage
- if [[ -f github_token.txt ]]; then dd-octo-sts revoke -t $(cat github_token.txt) || true; fi
artifacts:
paths:
- "aggregated_tested_versions.json"
- "integration_versions.md"
when: "always"
rules:
# Run automatically on master even if previous jobs failed (flaky tests may still provide artifacts)
- if: $CI_COMMIT_REF_NAME == "master"
when: always
- when: manual
allow_failure: true