-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathgenerate-package.php
More file actions
1517 lines (1421 loc) · 46.9 KB
/
generate-package.php
File metadata and controls
1517 lines (1421 loc) · 46.9 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
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
include "generate-common.php";
$build_platforms = [
[
"triplet" => "x86_64-alpine-linux-musl",
"image_template" => "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-compile-extension-alpine-%s",
"arch" => "amd64",
"host_os" => "linux-musl",
"targets" => [
".apk.x86_64"
],
],
[
"triplet" => "aarch64-alpine-linux-musl",
"image_template" => "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-compile-extension-alpine-%s",
"arch" => "arm64",
"host_os" => "linux-musl",
"targets" => [
".apk.aarch64"
],
],
[
"triplet" => "x86_64-unknown-linux-gnu",
"image_template" => "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-%s_centos-7",
"arch" => "amd64",
"host_os" => "linux-gnu",
"targets" => [
".rpm.x86_64",
".deb.x86_64",
".tar.gz.x86_64",
],
],
[
"triplet" => "aarch64-unknown-linux-gnu",
"image_template" => "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-%s_centos-7",
"arch" => "arm64",
"host_os" => "linux-gnu",
"targets" => [
".rpm.arm64",
".deb.arm64",
".tar.gz.aarch64",
],
]
];
$asan_build_platforms = [
[
"triplet" => "x86_64-unknown-linux-gnu",
"image_template" => "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-%s_bookworm-5",
"arch" => "amd64",
"host_os" => "linux-gnu",
],
[
"triplet" => "aarch64-unknown-linux-gnu",
"image_template" => "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-%s_bookworm-5",
"arch" => "arm64",
"host_os" => "linux-gnu",
]
];
$windows_build_platforms = [
[
"triplet" => "x86_64-pc-windows-msvc",
"image_template" => "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-%s_windows",
"arch" => "amd64",
"host_os" => "windows-msvc",
"targets" => [
"dbgsym.tar.gz",
],
],
];
?>
stages:
- prepare
- profiler
- appsec
- tracing
- packaging
- benchmarks
- gate
- notify
- verify
- shared-pipeline # OCI packaging
- pre-release
- release
variables:
CARGO_HOME: "${CI_PROJECT_DIR}/.cache/cargo"
include:
- local: .gitlab/one-pipeline.locked.yml
- local: .gitlab/benchmarks.yml
# One pipeline job overrides
configure_system_tests:
variables:
SYSTEM_TESTS_SCENARIOS_GROUPS: "simple_onboarding,simple_onboarding_profiling,lib-injection,lib-injection-profiling"
ALLOW_MULTIPLE_CHILD_LEVELS: "false"
package-oci:
needs:
<?php
foreach ($arch_targets as $arch) {
?>
- job: "package loader: [<?= $arch ?>]"
artifacts: true
<?php
}
?>
requirements_json_test:
rules:
- when: on_success
variables:
REQUIREMENTS_BLOCK_JSON_PATH: "loader/packaging/block_tests.json"
REQUIREMENTS_ALLOW_JSON_PATH: "loader/packaging/allow_tests.json"
# dd-trace-php release packaging
"prepare code":
stage: prepare
image: registry.ddbuild.io/images/mirror/composer:2
tags: [ "arch:amd64" ]
script:
- ./.gitlab/append-build-id.sh
# Upgrading composer
- composer self-update --no-interaction
# Installing dependencies with composer
- |
export COMPOSER_MEMORY_LIMIT=-1 # disable composer memory limit completely
composer update --no-interaction
# Compiling dd-tace-php files into single file
- make generate
# Showing folder containing generated files
- ls -al ${CI_PROJECT_DIR:-.}/src/bridge
artifacts:
paths:
- VERSION.txt
- ./src/bridge/_generated*.php
<?php
foreach ($build_platforms as $platform) {
$image = sprintf($platform['image_template'], "8.1");
?>
"cache cargo deps: [<?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]":
stage: prepare
image: $IMAGE
tags: [ "arch:$ARCH" ]
variables:
TRIPLET: "<?= $platform['triplet'] ?>"
IMAGE: "<?= $image ?>"
ARCH: "<?= $platform['arch'] ?>"
script: |
if [ -e "${CARGO_HOME}/.package-cache" ] ; then
echo "WARNING: .package-cache was part of the cache and shouldn't be!"
rm -vf "${CARGO_HOME}/.package-cache"
fi
mkdir -p "${CARGO_HOME}"
cargo fetch -v --target "${TRIPLET}"
chmod -R 777 "${CARGO_HOME}"
# ensure the .package-cache isn't there
rm -vf "${CARGO_HOME}/.package-cache"
cache:
- key:
prefix: cargo-cache-${TRIPLET}
files:
- Cargo.lock
paths:
- "${CARGO_HOME}"
<?php
}
foreach ($build_platforms as $platform) {
foreach ($profiler_minor_major_targets as $major_minor) {
$abi_no = $php_versions_to_abi[$major_minor]
?>
"compile profiler extension: [<?= $major_minor ?>, <?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]":
stage: profiler
image: "<?= sprintf($platform['image_template'], $major_minor) ?>"
tags: [ "arch:$ARCH" ]
needs:
- job: "prepare code"
artifacts: true
- job: "cache cargo deps: [<?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]"
artifacts: true
variables:
TRIPLET: "<?= $platform['triplet'] ?>"
ARCH: "<?= $platform['arch'] ?>"
ABI_NO: "<?= $abi_no ?>"
PHP_VERSION: "<?= $major_minor ?>"
CARGO_BUILD_JOBS: 12
KUBERNETES_CPU_REQUEST: 12
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 8Gi
script:
- .gitlab/build-profiler.sh "datadog-profiling/${TRIPLET}/lib/php/${ABI_NO}" "nts"
- .gitlab/build-profiler.sh "datadog-profiling/${TRIPLET}/lib/php/${ABI_NO}" "zts"
cache:
- key:
prefix: cargo-cache-${TRIPLET}
files:
- Cargo.lock
paths:
- "${CARGO_HOME}"
policy: pull # `Cache Cargo Deps` is used to update/push the cache
artifacts:
paths:
- "datadog-profiling"
<?php
}
}
?>
<?php
foreach ($build_platforms as $platform) {
foreach ($php_versions_to_abi as $major_minor => $abi_no) {
$image = sprintf($platform['image_template'], $major_minor);
$suffix = ($platform['triplet'] === "x86_64-alpine-linux-musl" || $platform['triplet'] === "aarch64-alpine-linux-musl") ? "-alpine" : "";
?>
"compile appsec extension: [<?= $major_minor ?>, <?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]":
stage: appsec
image: $IMAGE
tags: [ "arch:$ARCH" ]
needs: [ "prepare code" ]
variables:
IMAGE: "<?= $image ?>"
TRIPLET: "<?= $platform['triplet'] ?>"
ARCH: "<?= $platform['arch'] ?>"
ABI_NO: "<?= $abi_no ?>"
PHP_VERSION: "<?= $major_minor ?>"
MAKE_JOBS: 12
KUBERNETES_CPU_REQUEST: 12
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 8Gi
script:
# Fix for $BASH_ENV not having a newline at the end of the file
- echo "" >> "$BASH_ENV"
<?php
if ($suffix == "-alpine") {
?>
- apk add cmake gcc g++ git python3 autoconf coreutils
<?php
}
?>
- .gitlab/build-appsec.sh <?= $suffix ?>
artifacts:
paths:
- "appsec_*"
<?php
}
}
?>
"compile appsec helper":
stage: appsec
image: "registry.ddbuild.io/images/mirror/b1o7r7e0/nginx_musl_toolchain"
tags: [ "arch:$ARCH" ]
needs: [ "prepare code" ]
parallel:
matrix:
- ARCH: ["amd64", "arm64" ]
variables:
MAKE_JOBS: 12
KUBERNETES_CPU_REQUEST: 12
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 8Gi
script: .gitlab/build-appsec-helper.sh
artifacts:
paths:
- "appsec_*"
"pecl build":
stage: tracing
image: "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-7.4_bookworm-5"
tags: [ "arch:amd64" ]
needs: [ "prepare code" ]
script:
- make build_pecl_package
- mkdir -p ./pecl && cp datadog_trace-*.tgz ./pecl
artifacts:
paths:
- pecl
<?php
foreach ($build_platforms as $platform) {
foreach ($php_versions_to_abi as $major_minor => $abi_no) {
$image = sprintf($platform['image_template'], $major_minor);
$suffix = ($platform['triplet'] === "x86_64-alpine-linux-musl" || $platform['triplet'] === "aarch64-alpine-linux-musl") ? "-alpine" : "";
$catch_warnings = ($major_minor == "7.3" && $suffix != "-alpine") ? "0" : "1";
?>
"compile tracing extension: [<?= $major_minor ?>, <?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]":
stage: tracing
image: $IMAGE
tags: [ "arch:$ARCH" ]
needs: [ "prepare code" ]
variables:
IMAGE: "<?= $image ?>"
TRIPLET: "<?= $platform['triplet'] ?>"
ARCH: "<?= $platform['arch'] ?>"
ABI_NO: "<?= $abi_no ?>"
PHP_VERSION: "<?= $major_minor ?>"
MAKE_JOBS: 12
KUBERNETES_CPU_REQUEST: 12
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 8Gi
script:
# Fix for $BASH_ENV not having a newline at the end of the file
- echo "" >> "$BASH_ENV"
- ./.gitlab/build-tracing.sh "<?= $suffix ?>" "<?= $catch_warnings ?>"
artifacts:
paths:
- "extensions_*"
- "standalone_*"
- "ddtrace_*.ldflags"
<?php
}
}
?>
<?php foreach ($arch_targets as $arch): ?>
"aggregate tracing extension: [<?= $arch ?>]":
stage: tracing
image: "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-7.4_bookworm-5"
tags: [ "arch:amd64" ]
script: ls ./
variables:
GIT_STRATEGY: none
needs:
<?php
foreach ($build_platforms as $platform):
if ($platform["arch"] == $arch):
foreach ($all_minor_major_targets as $major_minor):
?>
- job: "compile tracing extension: [<?= $major_minor ?>, <?= $arch ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
endforeach;
endif;
endforeach;
?>
artifacts:
paths:
- "extensions_*"
- "standalone_*"
- "ddtrace_*.ldflags"
<?php
endforeach;
?>
<?php
foreach ($build_platforms as $platform) {
$image = sprintf($platform['image_template'], "8.1");
$suffix = ($platform['triplet'] === "x86_64-alpine-linux-musl" || $platform['triplet'] === "aarch64-alpine-linux-musl") ? "-alpine" : "";
?>
"compile tracing sidecar: [<?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]":
stage: tracing
image: $IMAGE
tags: [ "arch:$ARCH" ]
needs:
- job: "prepare code"
artifacts: true
- job: "cache cargo deps: [<?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]"
artifacts: true
variables:
IMAGE: "<?= $image ?>"
TRIPLET: "<?= $platform['triplet'] ?>"
ARCH: "<?= $platform['arch'] ?>"
HOST_OS: "<?= $platform['host_os'] ?>"
CARGO_BUILD_JOBS: 16
KUBERNETES_CPU_REQUEST: 16
KUBERNETES_MEMORY_REQUEST: 5Gi
KUBERNETES_MEMORY_LIMIT: 8Gi
script:
- echo "" >> "$BASH_ENV"
- ./.gitlab/build-sidecar.sh "<?= $suffix ?>"
cache:
- key:
prefix: cargo-cache-${TRIPLET}
files:
- Cargo.lock
paths:
- "${CARGO_HOME}"
policy: pull # `cache cargo deps` is used to update/push the cache
artifacts:
paths:
- "libddtrace_php_*.*"
<?php
}
?>
<?php
foreach ($build_platforms as $platform) {
$image = sprintf($platform['image_template'], "8.1");
$suffix = ($platform['triplet'] === "x86_64-alpine-linux-musl" || $platform['triplet'] === "aarch64-alpine-linux-musl") ? "-alpine" : "";
?>
"link tracing extension: [<?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]":
stage: tracing
image: $IMAGE
tags: [ "arch:$ARCH" ]
needs:
- job: "compile tracing sidecar: [<?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
foreach ($php_versions_to_abi as $major_minor => $abi_no) {
?>
- job: "compile tracing extension: [<?= $major_minor ?>, <?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
}
?>
variables:
IMAGE: "<?= $image ?>"
TRIPLET: "<?= $platform['triplet'] ?>"
ARCH: "<?= $platform['arch'] ?>"
ABI_NO: "<?= $abi_no ?>"
KUBERNETES_CPU_REQUEST: 12
KUBERNETES_MEMORY_REQUEST: 8Gi
KUBERNETES_MEMORY_LIMIT: 16Gi
script:
# Fix for $BASH_ENV not having a newline at the end of the file
- echo "" >> "$BASH_ENV"
- ./.gitlab/link-tracing-extension.sh "<?= $suffix ?>"
artifacts:
paths:
- "extensions_*"
<?php
}
?>
<?php
foreach ($asan_build_platforms as $platform) {
foreach ($asan_minor_major_targets as $major_minor) {
$abi_no = $php_versions_to_abi[$major_minor];
$image = sprintf($platform['image_template'], $major_minor);
?>
"compile tracing extension asan: [<?= $major_minor ?>, <?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]":
stage: tracing
image: $IMAGE
tags: [ "arch:$ARCH" ]
needs:
- job: "prepare code"
artifacts: true
variables:
IMAGE: "<?= $image ?>"
TRIPLET: "<?= $platform['triplet'] ?>"
ARCH: "<?= $platform['arch'] ?>"
ABI_NO: "<?= $abi_no ?>"
PHP_VERSION: "<?= $major_minor ?>"
MAKE_JOBS: 12
KUBERNETES_CPU_REQUEST: 12
KUBERNETES_MEMORY_REQUEST: 4Gi
KUBERNETES_MEMORY_LIMIT: 8Gi
script: ./.gitlab/build-tracing-asan.sh
artifacts:
paths:
- "extensions_*"
<?php
}
}
?>
<?php
foreach ($windows_build_platforms as $platform) {
foreach ($windows_minor_major_targets as $major_minor) {
$abi_no = $php_versions_to_abi[$major_minor];
$image = sprintf($platform['image_template'], $major_minor);
?>
"compile extension windows: [<?= $major_minor ?>]":
stage: tracing
tags: [ "windows-v2:2019"]
needs:
- job: "prepare code"
artifacts: true
variables:
IMAGE: "<?= $image ?>"
ABI_NO: "<?= $abi_no ?>"
PHP_VERSION: "<?= $major_minor ?>"
GIT_STRATEGY: clone
GIT_CONFIG_COUNT: 2
GIT_CONFIG_KEY_0: core.longpaths
GIT_CONFIG_VALUE_0: true
GIT_CONFIG_KEY_1: core.symlinks
GIT_CONFIG_VALUE_1: true
CONTAINER_NAME: ${CI_JOB_NAME_SLUG}-${CI_JOB_ID}
script: |
# Make sure we actually fail if a command fails
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
mkdir extensions_x86_64
mkdir extensions_x86_64_debugsymbols
# Start the container
docker run -v ${pwd}:C:\Users\ContainerAdministrator\app -d --name ${CONTAINER_NAME} ${IMAGE} ping -t localhost
# Build nts (fail fast on any step)
docker exec ${CONTAINER_NAME} powershell.exe -Command "`$ErrorActionPreference='Stop'; `$PSNativeCommandUseErrorActionPreference=`$true; cd app; switch-php nts; & 'C:\\php\\SDK\\phpize.bat'; if (`$LASTEXITCODE -ne 0) { exit `$LASTEXITCODE }; .\\configure.bat --enable-debug-pack; if (`$LASTEXITCODE -ne 0) { exit `$LASTEXITCODE }; nmake; if (`$LASTEXITCODE -ne 0) { exit `$LASTEXITCODE }; Move-Item x64\\Release\\php_ddtrace.dll extensions_x86_64\\php_ddtrace-${ABI_NO}.dll -ErrorAction Stop; Move-Item x64\\Release\\php_ddtrace.pdb extensions_x86_64_debugsymbols\\php_ddtrace-${ABI_NO}.pdb -ErrorAction Stop"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
# Reuse libdatadog build (fail if move fails)
docker exec ${CONTAINER_NAME} powershell.exe -Command "`$ErrorActionPreference='Stop'; `$PSNativeCommandUseErrorActionPreference=`$true; New-Item -ItemType Directory -Force -Path 'app\\x64\\Release_TS' | Out-Null; Move-Item 'app\\x64\\Release\\target' 'app\\x64\\Release_TS\\target' -ErrorAction Stop"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
# Build zts (fail fast on any step)
docker exec ${CONTAINER_NAME} powershell.exe -Command "`$ErrorActionPreference='Stop'; `$PSNativeCommandUseErrorActionPreference=`$true; cd app; switch-php zts; & 'C:\\php\\SDK\\phpize.bat'; if (`$LASTEXITCODE -ne 0) { exit `$LASTEXITCODE }; .\\configure.bat --enable-debug-pack; if (`$LASTEXITCODE -ne 0) { exit `$LASTEXITCODE }; nmake; if (`$LASTEXITCODE -ne 0) { exit `$LASTEXITCODE }; Move-Item x64\\Release_TS\\php_ddtrace.dll extensions_x86_64\\php_ddtrace-${ABI_NO}-zts.dll -ErrorAction Stop; Move-Item x64\\Release_TS\\php_ddtrace.pdb extensions_x86_64_debugsymbols\\php_ddtrace-${ABI_NO}-zts.pdb -ErrorAction Stop"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
# Try to stop the container, don't care if we fail
try { docker stop -t 5 ${CONTAINER_NAME} } catch { }
artifacts:
paths:
- "extensions_x86_64"
- "./extensions_x86_64_debugsymbols"
<?php
}
}
?>
<?php
foreach ($build_platforms as $platform) {
$image = sprintf($platform['image_template'], "8.3");
?>
"compile loader: [<?= $platform['host_os'] ?>, <?= $platform['arch'] ?>]":
stage: tracing
image: $IMAGE
tags: [ "arch:$ARCH" ]
needs:
- job: "prepare code"
artifacts: true
variables:
IMAGE: "<?= $image ?>"
ARCH: "<?= $platform['arch'] ?>"
HOST_OS: "<?= $platform['host_os'] ?>"
MAKE_JOBS: 2
script:
# Fix for $BASH_ENV not having a newline at the end of the file
- echo "" >> "$BASH_ENV"
- ./.gitlab/build-loader.sh
artifacts:
paths:
- "dd_library_loader-*.so"
<?php
}
?>
.package_extension_base:
stage: packaging
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php_fpm_packaging
tags: [ "arch:amd64" ]
artifacts:
paths:
- "packages/"
<?php
foreach ($build_platforms as $platform) {
?>
"package extension: [<?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]":
extends: .package_extension_base
variables:
ARCH: "<?= $platform['arch'] ?>"
TRIPLET: "<?= $platform['triplet'] ?>"
script:
- make -j 4 <?= implode(' ', $platform['targets']) ?>
- ./tooling/bin/generate-final-artifact.sh $(<VERSION.txt) "build/packages" "${CI_PROJECT_DIR}"
- mv build/packages/ packages/
needs:
- job: "prepare code"
artifacts: true
# Link tracing extension
- job: "link tracing extension: [<?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]"
artifacts: true
# Compile tracing sidecar
- job: "compile tracing sidecar: [<?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
foreach ($php_versions_to_abi as $major_minor => $abi_no) {
?>
# Compile appsec extension
- job: "compile appsec extension: [<?= $major_minor ?>, <?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
}
?>
# Compile appsec helper
- job: "compile appsec helper"
parallel:
matrix:
- ARCH: "<?= $platform['arch'] ?>"
artifacts: true
<?php
foreach ($profiler_minor_major_targets as $major_minor) {
?>
# Profiler extension
- job: "compile profiler extension: [<?= $major_minor ?>, <?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
}
}
?>
"package extension windows":
extends: .package_extension_base
variables:
TRIPLET: "x86_64-pc-windows-msvc"
script:
- make -j 4 <?= implode(' ', $windows_build_platforms[0]['targets']), "\n" ?>
- ./tooling/bin/generate-final-artifact.sh $(<VERSION.txt) "build/packages" "${CI_PROJECT_DIR}"
- mv build/packages/ packages/
needs:
- job: "prepare code"
artifacts: true
<?php
foreach ($windows_minor_major_targets as $major_minor) {
?>
- job: "compile extension windows: [<?= $major_minor ?>]"
artifacts: true
<?php
}
?>
"package extension asan":
extends: .package_extension_base
script:
- ./tooling/bin/generate-final-artifact.sh $(<VERSION.txt) "build/packages" "${CI_PROJECT_DIR}"
- mv build/packages/ packages/
needs:
- job: "prepare code"
artifacts: true
<?php
foreach ($asan_build_platforms as $platform) {
foreach ($asan_minor_major_targets as $major_minor) {
$abi_no = $php_versions_to_abi[$major_minor];
?>
- job: "compile tracing extension asan: [<?= $major_minor ?>, <?= $platform['arch'] ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
}
}
?>
variables:
DDTRACE_MAKE_PACKAGES_ASAN: 1
<?php foreach ($arch_targets as $arch): ?>
"package loader: [<?= $arch ?>]":
extends: .package_extension_base
variables:
ARCHITECTURE: "<?= ($arch == 'amd64') ? 'x86_64' : 'aarch64' ?>"
script:
- mkdir -p build/packages tmp/
- ./tooling/bin/generate-ssi-package.sh $(<VERSION.txt) "build/packages"
- mv build/packages/ packages/
needs:
- job: "prepare code"
artifacts: true
- job: "compile appsec helper"
parallel:
matrix:
- ARCH: "<?= $arch ?>"
artifacts: true
- job: "compile loader: [linux-gnu, <?= $arch ?>]"
artifacts: true
- job: "compile loader: [linux-musl, <?= $arch ?>]"
artifacts: true
- job: "aggregate tracing extension: [<?= $arch ?>]"
artifacts: true
<?php
foreach ($build_platforms as $platform):
if ($platform["arch"] == $arch):
?>
- job: "compile tracing sidecar: [<?= $arch ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
foreach ($all_minor_major_targets as $major_minor):
?>
- job: "compile appsec extension: [<?= $major_minor ?>, <?= $arch ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
endforeach;
?>
<?php
foreach ($profiler_minor_major_targets as $major_minor):
?>
- job: "compile profiler extension: [<?= $major_minor ?>, <?= $arch ?>, <?= $platform['triplet'] ?>]"
artifacts: true
<?php
endforeach;
endif;
endforeach;
endforeach;
?>
"datadog-setup.php":
stage: packaging
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php_fpm_packaging
tags: [ "arch:amd64" ]
script:
- mkdir -p "build/packages"
- make "build/packages/datadog-setup.php"
- mv "build/packages/" "packages/"
needs:
- job: "prepare code"
artifacts: true
artifacts:
paths:
- "packages/datadog-setup.php"
"x-profiling phpt tests on Alpine":
stage: verify
image: "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-compile-extension-alpine-$PHP_VERSION"
tags: [ "arch:amd64" ]
parallel:
matrix:
- PHP_VERSION: <?= json_encode($profiler_minor_major_targets), "\n" ?>
needs:
- job: "package extension: [amd64, x86_64-alpine-linux-musl]"
artifacts: true
- job: datadog-setup.php
artifacts: true
before_script:
- installable_bundle=$(find packages -maxdepth 1 -name 'dd-library-php-*-x86_64-linux-musl.tar.gz')
- php datadog-setup.php --file "${installable_bundle}" --php-bin php --enable-profiling
- phpize # run phpize just to get run-tests.php
script:
- php run-tests.php -p $(which php) -d datadog.remote_config_enabled=false --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" tests/ext/profiling
.randomized_tests:
stage: verify
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal # TODO: use a proper docker image with make, php and git pre-installed
variables:
KUBERNETES_CPU_REQUEST: 7
KUBERNETES_MEMORY_REQUEST: 30Gi
KUBERNETES_MEMORY_LIMIT: 40Gi
RUST_BACKTRACE: 1
DOCKER_COMPOSE_DOWNLOAD_NAME: docker-compose-linux-x86_64
before_script:
<?php dockerhub_login() ?>
- apt install -y php git make curl
- curl -L --fail https://github.com/docker/compose/releases/download/v2.36.0/${DOCKER_COMPOSE_DOWNLOAD_NAME} -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- mv packages/* .
- docker network create randomized_tests_baseservices
- make -C tests/randomized library.local # Copy tracer package
- make -C tests/randomized generate PLATFORMS=$RANDOMIZED_RESTRICT_PLATFORMS NUMBER_OF_SCENARIOS=4
script:
- make -C tests/randomized test CONCURRENT_JOBS=2 DURATION=1m30s # Execute
after_script:
# - sudo chown -R circleci:circleci tests/randomized/.tmp.scenarios/.results
- make -C tests/randomized analyze
artifacts:
paths:
- tests/randomized/.tmp.scenarios/.results
<?php foreach (range(1, 5) as $i): ?>
"randomized tests: [amd64, no-asan, <?= $i ?>]":
extends: .randomized_tests
tags: [ "docker-in-docker:amd64" ]
needs:
- job: "package extension: [amd64, x86_64-unknown-linux-gnu]"
artifacts: true
<?php endforeach; ?>
<?php foreach (range(1, 5) as $i): ?>
"randomized tests: [amd64, asan, <?= $i ?>]":
extends: .randomized_tests
tags: [ "docker-in-docker:amd64" ]
needs:
- job: "package extension asan"
artifacts: true
<?php endforeach; ?>
<?php foreach (range(1, 5) as $i): ?>
# Skip until docker-in-docker:arm64 runner is available
# "randomized tests: [arm64, no-asan, <?= $i ?>]":
# extends: .randomized_tests
# tags: [ "docker-in-docker:arm64" ]
# variables:
# DOCKER_COMPOSE_DOWNLOAD_NAME: docker-compose-linux-aarch64
# needs:
# - job: "package extension: [arm64, aarch64-unknown-linux-gnu]"
# artifacts: true
<?php endforeach; ?>
<?php foreach (range(1, 5) as $i): ?>
# Skip until docker-in-docker:arm64 runner is available
# "randomized tests: [arm64, asan, <?= $i ?>]":
# extends: .randomized_tests
# tags: [ "docker-in-docker:arm64" ]
# variables:
# DOCKER_COMPOSE_DOWNLOAD_NAME: docker-compose-linux-aarch64
# needs:
# - job: "package extension asan"
# artifacts: true
<?php endforeach; ?>
"installer tests":
stage: verify
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
tags: [ "docker-in-docker:amd64" ]
needs:
- job: "package extension: [amd64, x86_64-unknown-linux-gnu]"
artifacts: true
- job: "package extension: [arm64, aarch64-unknown-linux-gnu]"
artifacts: true
- job: datadog-setup.php
artifacts: true
variables:
KUBERNETES_CPU_REQUEST: 2
KUBERNETES_MEMORY_REQUEST: 2Gi
KUBERNETES_MEMORY_LIMIT: 4Gi
RUST_BACKTRACE: 1
before_script:
<?php dockerhub_login() ?>
- apt install -y make
- mkdir build
- mv packages build
script:
- make -C dockerfiles/verify_packages test_installer
"test early PHP 8.1":
stage: verify
image: registry.ddbuild.io/images/mirror/ubuntu:jammy
tags: [ "arch:amd64" ]
needs:
- job: "package extension: [amd64, x86_64-unknown-linux-gnu]"
artifacts: true
- job: datadog-setup.php
artifacts: true
variables:
KUBERNETES_CPU_REQUEST: 2
KUBERNETES_MEMORY_REQUEST: 2Gi
KUBERNETES_MEMORY_LIMIT: 4Gi
RUST_BACKTRACE: 1
before_script:
<?php unset_dd_runner_env_vars() ?>
- apt-get update -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y php8.1 php8.1-dom php-pear
- rm /etc/php/8.1/cli/conf.d/10-opcache.ini
script:
- php datadog-setup.php --php-bin all --file $(ls packages/dd-library-php-*-x86_64-linux-gnu.tar.gz)
- sed -i 's/datadog.trace.sources_path/\;datadog.trace.sources_path/' /etc/php/8.1/cli/conf.d/98-ddtrace.ini
- DD_TRACE_GIT_METADATA_ENABLED=0 pecl run-tests --showdiff --ini=" -d datadog.trace.cli_enabled=1" $(find tests/ext -type d)
"framework test":
stage: verify
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
tags: [ "docker-in-docker:amd64" ]
variables:
KUBERNETES_CPU_REQUEST: 2
KUBERNETES_MEMORY_REQUEST: 2Gi
KUBERNETES_MEMORY_LIMIT: 4Gi
needs:
- job: "package extension: [amd64, x86_64-unknown-linux-gnu]"
artifacts: true
parallel:
matrix:
- TESTSUITE:
- flow
- flow_no_ddtrace
- mongodb-driver
- mongodb-driver_no_ddtrace
- phpredis3
- phpredis3_no_ddtrace
- phpredis4
- phpredis4_no_ddtrace
- phpredis5
- phpredis5_no_ddtrace
- wordpress
- wordpress_no_ddtrace
# The dd-trace-ci:php-framework-laravel docker image needs to be modified to handle the laravel queue integration
# - laravel_no_ddtrace
# - laravel
# Symfony path needs to be updated as symfony/contracts 2.0 has been released and it changes
# - symfony_no_ddtrace
# - symfony
before_script:
<?php dockerhub_login() ?>
- apt install -y make curl
- curl -L --fail https://github.com/docker/compose/releases/download/v2.36.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- mkdir build
- mv packages build
- docker-compose --version
script:
- make -f dockerfiles/frameworks/Makefile $TESTSUITE
artifacts:
paths:
- tests/randomized/.tmp.scenarios/.results
.verify_job:
stage: verify
image: "registry.ddbuild.io/images/mirror/$IMAGE"
tags: [ "arch:amd64" ]
services:
- !reference [.services, request-replayer]
variables:
KUBERNETES_CPU_REQUEST: 2
KUBERNETES_MEMORY_REQUEST: 2Gi
KUBERNETES_MEMORY_LIMIT: 4Gi
DD_AGENT_HOST: request-replayer
DD_TRACE_AGENT_PORT: 80
DD_TRACE_AGENT_FLUSH_INTERVAL: 1000
script:
- ./dockerfiles/verify_packages/verify.sh
"verify alpine":
extends: .verify_job
variables:
VERIFY_APACHE: "no"
parallel:
matrix:
- INSTALL_PACKAGES: php7 php7-fpm php7-json
IMAGE:
- alpine:3.8
- alpine:3.9
- alpine:3.10
- alpine:3.11
- alpine:3.12
- alpine:3.15
INSTALL_TYPE: &verify_install_types
- php_installer
- native_package
- INSTALL_PACKAGES: php php-fpm php-json
IMAGE:
- alpine:3.15
- alpine:3.16
- alpine:3.17
- alpine:3.20
- alpine:latest
INSTALL_TYPE: *verify_install_types
- IMAGE: <?= json_encode(array_map(function ($v) { return "php:$v-fpm-alpine"; }, $all_minor_major_targets)), "\n" ?>
INSTALL_TYPE: *verify_install_types
needs:
- job: "package extension: [amd64, x86_64-alpine-linux-musl]"
artifacts: true
- job: datadog-setup.php
artifacts: true
before_script: &verify_alpine_before_script
<?php dockerhub_login() ?>
- mkdir build
- mv packages build
- apk add --no-cache ca-certificates # see https://support.circleci.com/hc/en-us/articles/360016505753-Resolve-Certificate-Signed-By-Unknown-Authority-error-in-Alpine-images?flash_digest=39b76521a337cecacac0cc10cb28f3747bb5fc6a
- apk add curl ${INSTALL_PACKAGES:-}
"verify centos":
extends: .verify_job
variables:
IMAGE: centos:7
parallel:
matrix:
- PHP_MINOR_MAJOR:
- 70
- 71
- 72
- 73
- 74
- 80
- 81
- 82
- 83
INSTALL_TYPE: *verify_install_types
needs:
- job: "package extension: [amd64, x86_64-unknown-linux-gnu]"
artifacts: true
- job: datadog-setup.php
artifacts: true
before_script:
<?php dockerhub_login() ?>
- mkdir build
- mv packages build
- '# Fix yum config, as centos 7 is EOL and mirrorlist.centos.org does not resolve anymore - https://serverfault.com/a/1161847'
- sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
- sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
- sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo