4
4
- cron : " 30 0 * * *"
5
5
workflow_dispatch :
6
6
inputs :
7
- repository :
8
- description : ' Repository name that is going to be benchmarked (e.g. "johndoe/php-src ")'
7
+ pull_request :
8
+ description : ' PR number that is going to be benchmarked (e.g. "1234 ")'
9
9
required : true
10
- type : string
11
- branch :
12
- description : ' Branch name that is going to be benchmarked (e.g. "my-branch")'
13
- required : true
14
- type : string
15
- commit :
16
- description : ' Commit SHA that is going to be benchmarked (e.g. "123456789a")'
17
- required : true
18
- type : string
19
- baseline_commit :
20
- description : ' A commit SHA that is compared against the one provided by the "commit" input (e.g. "abcdef123456")'
21
- required : true
22
- type : string
10
+ type : number
23
11
jit :
24
12
description : ' Whether JIT is benchmarked'
25
13
required : false
26
14
type : choice
27
15
options :
28
16
- " 0"
29
17
- " 1"
18
+ opcache :
19
+ description : ' Whether opcache is enabled for the benchmarked commit'
20
+ required : true
21
+ default : " 1"
22
+ type : choice
23
+ options :
24
+ - " 0"
25
+ - " 1"
26
+ - " 2"
27
+ baseline_opcache :
28
+ description : ' Whether opcache is enabled for the baseline commit'
29
+ required : true
30
+ default : " 1"
31
+ type : choice
32
+ options :
33
+ - " 0"
34
+ - " 1"
35
+ - " 2"
30
36
permissions :
31
37
contents : read
38
+ pull-requests : write
32
39
jobs :
33
40
REAL_TIME_BENCHMARK :
34
41
name : REAL_TIME_BENCHMARK
35
42
if : github.repository == 'php/php-src' || github.event_name == 'workflow_dispatch'
36
43
runs-on : ubuntu-22.04
37
44
env :
38
- REPOSITORY : ${{ inputs.repository || 'php/php-src' }}
39
- BRANCH : ${{ inputs.branch || 'master' }}
40
- COMMIT : ${{ inputs.commit || github.sha }}
41
- BASELINE_COMMIT : ${{ inputs.baseline_commit || 'd5f6e56610c729710073350af318c4ea1b292cfe' }}
45
+ REPOSITORY : ${{ github.repository }}
46
+ BRANCH : " master"
47
+ COMMIT : ${{ github.sha }}
48
+ BASELINE_COMMIT : " d5f6e56610c729710073350af318c4ea1b292cfe"
49
+ ID : " master"
50
+ OPCACHE : ${{ inputs.opcache || '1' }}
51
+ BASELINE_OPCACHE : ${{ inputs.baseline_opcache || '2' }}
42
52
JIT : ${{ inputs.jit || '1' }}
53
+ YEAR : " "
43
54
steps :
55
+ - name : Setup benchmark environment
56
+ env :
57
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
58
+ run : |
59
+ YEAR="$(date '+%Y')"
60
+ echo "YEAR=$YEAR" >> $GITHUB_ENV
61
+
62
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
63
+ PR_INFO=$(gh pr view ${{ inputs.pull_request }} --json headRepositoryOwner,headRepository,headRefName,headRefOid,baseRefOid --repo ${{ github.repository }} | jq -r '.headRepositoryOwner.login, .headRepository.name, .headRefName, .headRefOid, .baseRefOid')
64
+
65
+ REPOSITORY="$(echo "$PR_INFO" | sed -n '1p')/$(echo "$PR_INFO" | sed -n '2p')"
66
+ echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV
67
+
68
+ BRANCH=$(echo "$PR_INFO" | sed -n '3p')
69
+ echo "BRANCH=$BRANCH" >> $GITHUB_ENV
70
+
71
+ COMMIT=$(echo "$PR_INFO" | sed -n '4p')
72
+ echo "COMMIT=$COMMIT" >> $GITHUB_ENV
73
+
74
+ BASELINE_COMMIT=$(echo "$PR_INFO" | sed -n '5p')
75
+ echo "BASELINE_COMMIT=$BASELINE_COMMIT" >> $GITHUB_ENV
76
+
77
+ echo "ID=benchmarked" >> $GITHUB_ENV
78
+ fi
79
+
44
80
- name : Install dependencies
45
81
run : |
46
82
set -ex
66
102
repository : ' ${{ env.REPOSITORY }}'
67
103
ref : ' ${{ env.COMMIT }}'
68
104
fetch-depth : 100
69
- path : ' php-version-benchmarks/tmp/php_${{ env.BRANCH }}'
105
+ path : ' php-version-benchmarks/tmp/php_${{ env.ID }}'
70
106
- name : Checkout php-src (baseline version)
71
107
uses : actions/checkout@v4
72
108
with :
81
117
82
118
rm -rf ./php-version-benchmarks/docs/results
83
119
- name : Checkout benchmark data
84
- if : github.repository == 'php/php-src' && github. event_name != 'workflow_dispatch'
120
+ if : github.event_name != 'workflow_dispatch'
85
121
uses : actions/checkout@v4
86
122
with :
87
123
repository : php/real-time-benchmark-data
@@ -97,61 +133,60 @@ jobs:
97
133
cp ./php-version-benchmarks/build/infrastructure/config/aws.tfvars.dist ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
98
134
sed -i 's/access_key = ""/access_key = "${{ secrets.PHP_VERSION_BENCHMARK_AWS_ACCESS_KEY }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
99
135
sed -i 's/secret_key = ""/secret_key = "${{ secrets.PHP_VERSION_BENCHMARK_AWS_SECRET_KEY }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
136
+ sed -i 's/github_token = ""/github_token = "${{ secrets.GITHUB_TOKEN }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
100
137
- name : Setup PHP config - baseline PHP version
101
- if : github.repository == 'php/php-src' && github.event_name != 'workflow_dispatch'
102
138
run : |
103
139
set -e
104
140
105
141
BASELINE_SHORT_SHA="$(echo "${{ env.BASELINE_COMMIT }}" | cut -c1-4)"
106
142
107
- cat << EOF > /php-version-benchmarks/config/php/baseline.ini
143
+ cat << EOF > . /php-version-benchmarks/config/php/baseline.ini
108
144
PHP_NAME="PHP - baseline@$BASELINE_SHORT_SHA"
109
145
PHP_ID=php_baseline
110
146
111
147
PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
112
148
PHP_BRANCH=${{ env.BRANCH }}
113
149
PHP_COMMIT=${{ env.BASELINE_COMMIT }}
114
150
115
- PHP_OPCACHE=2
151
+ PHP_OPCACHE=${{ env.BASELINE_OPCACHE }}
116
152
PHP_JIT=0
117
153
EOF
118
- - name : Setup PHP config - baseline PHP version with JIT (manual only)
119
- if : github.repository == 'php/php-src' && github. event_name == 'workflow_dispatch' && inputs.jit == '1'
154
+ - name : Setup PHP config - baseline PHP version with JIT
155
+ if : github.event_name == 'workflow_dispatch' && inputs.jit == '1'
120
156
run : |
121
157
set -e
122
158
123
159
BASELINE_SHORT_SHA="$(echo "${{ env.BASELINE_COMMIT }}" | cut -c1-4)"
124
-
125
- cat << EOF > /php-version-benchmarks/config/php/baseline.ini
160
+
161
+ cat << EOF > . /php-version-benchmarks/config/php/baseline.ini
126
162
PHP_NAME="PHP - baseline@$BASELINE_SHORT_SHA (JIT)"
127
163
PHP_ID=php_baseline_jit
128
164
129
165
PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
130
166
PHP_BRANCH=${{ env.BRANCH }}
131
167
PHP_COMMIT=${{ env.BASELINE_COMMIT }}
132
168
133
- PHP_OPCACHE=2
169
+ PHP_OPCACHE=${{ env.BASELINE_OPCACHE }}
134
170
PHP_JIT=${{ env.JIT }}
135
171
EOF
136
172
137
173
git clone ./php-version-benchmarks/tmp/php_baseline/ ./php-version-benchmarks/tmp/php_baseline_jit
138
- - name : Setup PHP config - previous PHP version (scheduled only)
139
- if : github.repository == 'php/php-src' && github. event_name != 'workflow_dispatch'
174
+ - name : Setup PHP config - previous PHP version
175
+ if : github.event_name != 'workflow_dispatch'
140
176
run : |
141
177
set -e
142
178
143
- YEAR="$(date '+%Y')"
144
- DATABASE="./php-version-benchmarks/docs/results/$YEAR/database.tsv"
179
+ DATABASE="./php-version-benchmarks/docs/results/${{ env.YEAR }}/database.tsv"
145
180
if [ -f "$DATABASE" ]; then
146
181
LAST_RESULT_SHA="$(tail -n 2 "$DATABASE" | head -n 1 | cut -f 6)"
147
182
else
148
183
YESTERDAY="$(date -d "-2 day 23:59:59" '+%Y-%m-%d %H:%M:%S')"
149
- LAST_RESULT_SHA="$(cd ./php-version-benchmarks/tmp/php_${{ env.BRANCH }}/ && git --no-pager log --until="$YESTERDAY" -n 1 --pretty='%H')"
184
+ LAST_RESULT_SHA="$(cd ./php-version-benchmarks/tmp/php_${{ env.ID }}/ && git --no-pager log --until="$YESTERDAY" -n 1 --pretty='%H')"
150
185
fi
151
186
152
- cat << EOF > /php-version-benchmarks/config/php/previous.ini
187
+ cat << EOF > . /php-version-benchmarks/config/php/previous.ini
153
188
PHP_NAME="PHP - previous ${{ env.BRANCH }}"
154
- PHP_ID=php_${{ env.BRANCH }}_previous
189
+ PHP_ID=php_previous
155
190
156
191
PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
157
192
PHP_BRANCH=${{ env.BRANCH }}
@@ -164,35 +199,35 @@ jobs:
164
199
run : |
165
200
set -e
166
201
167
- cat << EOF > /php-version-benchmarks/config/php/this.ini
202
+ cat << EOF > . /php-version-benchmarks/config/php/this.ini
168
203
PHP_NAME="PHP - ${{ env.BRANCH }}"
169
- PHP_ID=php_${{ env.BRANCH }}
204
+ PHP_ID=php_${{ env.ID }}
170
205
171
206
PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
172
207
PHP_BRANCH=${{ env.BRANCH }}
173
208
PHP_COMMIT=${{ env.COMMIT }}
174
209
175
- PHP_OPCACHE=1
210
+ PHP_OPCACHE=${{ env.OPCACHE }}
176
211
PHP_JIT=0
177
212
EOF
178
213
- name : Setup PHP config - benchmarked PHP version with JIT
179
214
if : env.JIT == '1'
180
215
run : |
181
216
set -e
182
217
183
- cat << EOF > /php-version-benchmarks/config/php/this_jit.ini
218
+ cat << EOF > . /php-version-benchmarks/config/php/this_jit.ini
184
219
PHP_NAME="PHP - ${{ env.BRANCH }} (JIT)"
185
- PHP_ID=php_${{ env.BRANCH }}_jit
220
+ PHP_ID=php_${{ env.ID }}_jit
186
221
187
222
PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
188
223
PHP_BRANCH=${{ env.BRANCH }}
189
224
PHP_COMMIT=${{ env.COMMIT }}
190
225
191
- PHP_OPCACHE=1
226
+ PHP_OPCACHE=${{ env.OPCACHE }}
192
227
PHP_JIT=${{ env.JIT }}
193
228
EOF
194
229
195
- git clone ./php-version-benchmarks/tmp/php_${{ env.BRANCH }}/ ./php-version-benchmarks/tmp/php_${{ env.BRANCH }}_jit
230
+ git clone ./php-version-benchmarks/tmp/php_${{ env.ID }}/ ./php-version-benchmarks/tmp/php_${{ env.ID }}_jit
196
231
- name : Setup test config
197
232
run : |
198
233
set -e
@@ -221,17 +256,21 @@ jobs:
221
256
fi
222
257
git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}"
223
258
git push
259
+ - name : Upload artifact
260
+ if : github.event_name == 'workflow_dispatch'
261
+ uses : actions/upload-artifact@v4
262
+ with :
263
+ name : results
264
+ path : ./php-version-benchmarks/docs/results/${{ env.YEAR }}
265
+ retention-days : 30
224
266
- name : Comment results
225
- if : github.repository != 'php/php-src' && github. event_name == 'workflow_dispatch'
267
+ if : github.event_name == 'workflow_dispatch'
226
268
env :
227
269
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
228
270
run : |
229
- PR_NUMBER=$(gh pr list --head "${{ inputs.branch }}" --state open --json number --jq '.[0].number')
230
- if [ ! -z "$PR_NUMBER" ]; then
231
- YEAR="$(date '+%Y')"
232
- NEWEST_RESULT_DIRECTORY=$(ls -td ./php-version-benchmarks/docs/results/$YEAR/*/ | head -1)
233
- gh pr comment $PR_NUMBER --body-file "$NEWEST_RESULT_DIRECTORY/result.md"
234
- fi
271
+ cd ./php-version-benchmarks/tmp/php_${{ env.ID }}
272
+ NEWEST_RESULT_DIRECTORY=$(ls -td ${{ github.workspace }}/php-version-benchmarks/docs/results/${{ env.YEAR }}/*/ | head -1)
273
+ gh pr comment ${{ inputs.pull_request }} --body-file "${NEWEST_RESULT_DIRECTORY}result.md" --repo ${{ env.REPOSITORY }}
235
274
- name : Cleanup
236
275
if : always()
237
276
run : |
0 commit comments