Skip to content

Commit f5cbe34

Browse files
committed
Fix issues
1 parent 0d31d89 commit f5cbe34

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

.github/workflows/push.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ jobs:
223223
uses: actions/checkout@v3
224224
with:
225225
fetch-depth: 0
226+
- name: git checkout benchmarking-data
227+
uses: actions/checkout@v3
228+
with:
229+
repository: iluuu1994/php-benchmark-data
230+
ssh-key: ${{ secrets.BENCHMARK_DATA_DEPLOY_KEY }}
231+
path: benchmark/repos/data
226232
- name: apt
227233
run: |
228234
set -x
@@ -263,15 +269,10 @@ jobs:
263269
run: make -j$(/usr/bin/nproc) >/dev/null
264270
- name: make install
265271
uses: ./.github/actions/install-linux
266-
- name: Prepare SSH key
272+
- name: Setup
267273
run: |
268-
mkdir -p ~/.ssh
269-
echo "${{ secrets.BENCHMARK_DATA_DEPLOY_KEY }}" > ~/.ssh/id_ed25519
270-
chmod 600 ~/.ssh/id_ed25519
271274
git config --global user.name "Benchmark"
272275
git config --global user.email "benchmark@php.net"
273-
- name: Setup
274-
run: |
275276
sudo service mysql start
276277
mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress"
277278
mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;"
@@ -282,6 +283,17 @@ jobs:
282283
echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
283284
- name: Benchmark
284285
run: php benchmark/benchmark.php true
286+
- name: Store result
287+
if: github.event_name == 'push'
288+
run: |
289+
set -x
290+
cd benchmark/repos/data
291+
git add .
292+
if git diff --cached --quiet; then
293+
exit 0
294+
fi
295+
git commit -m "Add result for ${{ github.repository }}@${{ steps.determine-commit.outputs.sha }}"
296+
git push
285297
- name: Show diff
286298
if: github.event_name == 'pull_request'
287299
run: >-

benchmark/benchmark.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,32 @@
22

33
require_once __DIR__ . '/shared.php';
44

5-
$commitResult = ($argv[1] ?? 'false') === 'true';
5+
$storeResult = ($argv[1] ?? 'false') === 'true';
66
$phpCgi = $argv[2] ?? dirname(PHP_BINARY) . '/php-cgi';
77
if (!file_exists($phpCgi)) {
88
fwrite(STDERR, "php-cgi not found\n");
99
exit(1);
1010
}
1111

1212
function main() {
13-
global $commitResult;
13+
global $storeResult;
1414

1515
$data = [];
1616
$data['bench.php'] = runBench();
1717
$data['symfony_demo'] = runSymfonyDemo();
1818
$data['wordpress_6.2'] = runWordpress();
1919
$result = json_encode($data, JSON_PRETTY_PRINT) . "\n";
2020

21-
if ($commitResult) {
22-
commitResult($result);
23-
} else {
24-
fwrite(STDOUT, $result);
21+
fwrite(STDOUT, $result);
22+
23+
if ($storeResult) {
24+
storeResult($result);
2525
}
2626
}
2727

28-
function commitResult(string $result) {
28+
function storeResult(string $result) {
2929
$repo = __DIR__ . '/repos/data';
3030
cloneRepo($repo, 'git@github.com:iluuu1994/php-benchmark-data.git');
31-
runCommand(['git', 'pull', '--end-of-options', 'origin'], $repo);
3231

3332
$commitHash = getPhpSrcCommitHash();
3433
$dir = $repo . '/' . substr($commitHash, 0, 2) . '/' . $commitHash;
@@ -37,10 +36,6 @@ function commitResult(string $result) {
3736
mkdir($dir, 0755, true);
3837
}
3938
file_put_contents($summaryFile, $result);
40-
41-
runCommand(['git', 'add', '--end-of-options', $summaryFile], $repo);
42-
runCommand(['git', 'commit', '--allow-empty', '-m', 'Add result for php/php-src@' . $commitHash, '--author', 'Benchmark <benchmark@php.net>'], $repo);
43-
runCommand(['git', 'push'], $repo);
4439
}
4540

4641
function getPhpSrcCommitHash(): string {

0 commit comments

Comments
 (0)