Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Benchmark

on:
pull_request:
branches: [main]

permissions:
pull-requests: write

jobs:
benchmark:
name: Performance Regression Check
runs-on: ubuntu-latest

steps:
- name: Checkout PR branch
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Benchmark base branch
run: |
git checkout ${{ github.event.pull_request.base.sha }}
composer install --no-interaction --prefer-dist --quiet
vendor/bin/phpbench run --tag=base --store --progress=dots

- name: Benchmark PR branch
run: |
git checkout ${{ github.event.pull_request.head.sha }}
composer install --no-interaction --prefer-dist --quiet
vendor/bin/phpbench run --tag=pr --store --ref=base --report=aggregate --progress=dots > benchmark-result.txt 2>&1 || true

- name: Read benchmark result
id: bench
run: |
{
echo "result<<BENCH_EOF"
cat benchmark-result.txt
echo "BENCH_EOF"
} >> "$GITHUB_OUTPUT"

- name: Find existing comment
uses: peter-evans/find-comment@v4
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: github-actions[bot]
body-includes: "## Benchmark Results"

- name: Post benchmark results
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
## Benchmark Results

Comparison of `${{ github.head_ref }}` against `${{ github.base_ref }}` (`${{ github.event.pull_request.base.sha }}`).

```
${{ steps.bench.outputs.result }}
```

<sub>Generated by phpbench against commit ${{ github.event.pull_request.head.sha }}</sub>
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.phpunit.result.cache
composer.lock
/.php-cs-fixer.cache
.phpbench/
.env
.idea
build/
build/
Loading
Loading