-
Notifications
You must be signed in to change notification settings - Fork 155
159 lines (142 loc) · 6.59 KB
/
prof_correctness.yml
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
name: Profiling correctness
on:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
prof-correctness:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.0, 8.1, 8.2, 8.3, 8.4]
phpts: [nts, zts]
include:
- phpts: zts
extensions: parallel
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ matrix.extensions }}
env:
phpts: ${{ matrix.phpts }}
- name: Restore build cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.php-version }}-${{ matrix.phpts }}
- name: Build profiler
run: |
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" | sudo tee -a /etc/apt/sources.list
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo apt remove -y clang-*
sudo apt-get update
sudo apt install -y clang-17
cd profiling
version_number=$(awk -F' = ' '$1 == "channel" { gsub(/"/, "", $2); print $2 }' rust-toolchain.toml)
curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal -y --default-toolchain "$version_number"
cargo rustc --features="trigger_time_sample" --release --crate-type=cdylib
- name: Cache build dependencies
uses: actions/cache/save@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.php-version }}-${{ matrix.phpts }}
- name: Run no profile test
run: |
export DD_PROFILING_ENABLED=Off
export DD_PROFILING_EXPERIMENTAL_FEATURES_ENABLED=1
export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1
php -v
php -d extension=target/release/libdatadog_php_profiling.so --ri datadog-profiling
for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions"; do
mkdir -p profiling/tests/correctness/"$test_case"/
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof
php -d extension=$PWD/target/release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php
if [ -f "$DD_PROFILING_OUTPUT_PPROF".1.lz4 ]; then
echo "File $DD_PROFILING_OUTPUT_PPROF.1.lz4 should not exist!"
exit 1;
fi
done
- name: Run tests
run: |
export DD_PROFILING_LOG_LEVEL=trace
export DD_PROFILING_EXPERIMENTAL_FEATURES_ENABLED=1
export DD_PROFILING_EXPERIMENTAL_EXCEPTION_SAMPLING_DISTANCE=1
export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1
php -v
php -d extension=target/release/libdatadog_php_profiling.so --ri datadog-profiling
for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions"; do
mkdir -p profiling/tests/correctness/"$test_case"/
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof
php -d extension=$PWD/target/release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php
done
- name: Run ZTS tests
if: matrix.phpts == 'zts'
run: |
export DD_PROFILING_LOG_LEVEL=trace
export DD_PROFILING_EXPERIMENTAL_FEATURES_ENABLED=1
export DD_PROFILING_EXPERIMENTAL_EXCEPTION_SAMPLING_DISTANCE=1
export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1
php -v
php -d extension=target/release/libdatadog_php_profiling.so --ri datadog-profiling
for test_case in "exceptions_zts"; do
mkdir -p profiling/tests/correctness/"$test_case"/
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof
php -d extension=$PWD/target/release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php
done
- name: Check profiler correctness for allocations
if: matrix.phpts != 'zts'
uses: Datadog/prof-correctness/analyze@main
with:
expected_json: profiling/tests/correctness/allocations.json
pprof_path: profiling/tests/correctness/allocations/
- name: Check profiler correctness for time
uses: Datadog/prof-correctness/analyze@main
with:
expected_json: profiling/tests/correctness/time.json
pprof_path: profiling/tests/correctness/time/
- name: Check profiler correctness for strange frames
uses: Datadog/prof-correctness/analyze@main
with:
expected_json: profiling/tests/correctness/strange_frames.json
pprof_path: profiling/tests/correctness/strange_frames/
- name: Check profiler correctness for timeline
uses: Datadog/prof-correctness/analyze@main
with:
expected_json: profiling/tests/correctness/timeline.json
pprof_path: profiling/tests/correctness/timeline/
- name: Check profiler correctness for exceptions ZTS
if: matrix.phpts == 'zts'
uses: Datadog/prof-correctness/analyze@main
with:
expected_json: profiling/tests/correctness/exceptions_zts.json
pprof_path: profiling/tests/correctness/exceptions_zts/
- name: Check profiler correctness for exceptions
uses: Datadog/prof-correctness/analyze@main
with:
expected_json: profiling/tests/correctness/exceptions.json
pprof_path: profiling/tests/correctness/exceptions/
- name: Notify Slack
if: failure() && github.ref == 'refs/heads/master'
run: |
curl -X POST "${{ secrets.SLACK_WEBHOOK }}" \
-H 'Content-Type: application/json' \
-d "{'scenarios': 'PHP', 'failed_run_url': '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'}"