-
Notifications
You must be signed in to change notification settings - Fork 773
Expand file tree
/
Copy pathcontinuous-integration-perf.yml
More file actions
88 lines (75 loc) · 2.85 KB
/
continuous-integration-perf.yml
File metadata and controls
88 lines (75 loc) · 2.85 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
name: Continuous Integration (perf)
on:
push:
paths-ignore:
- 'bin/**'
- 'docs/**'
pull_request:
paths-ignore:
- 'bin/**'
- 'docs/**'
workflow_dispatch:
inputs:
baseline:
description: 'Baseline mode. latest: compare against latest benchmarks; rebaseline: store new baseline.'
type: choice
default: 'latest'
options:
- 'latest'
- 'rebaseline'
jobs:
tests:
name: Benchmarks
runs-on: ubuntu-latest
continue-on-error: true # This job is experimental
permissions:
contents: write
pull-requests: write
strategy:
matrix:
php-version:
- "8.5"
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: true
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: xdebug
- name: Install Dependencies
run: composer install --prefer-dist ${{ matrix.composer-extra-arguments }}
- name: Fetch Benchmarks
run: |
git fetch origin benchmarks
mkdir -p .phpbench
git checkout origin/benchmarks -- .phpbench || echo "No previous benchmarks found"
- name: Run Benchmarks
run: |
# Baseline does not exist or rebaseline requested. Generate it.
if [ -z "$(ls -A .phpbench)" ] || [ "${{ github.event.inputs.baseline || 'latest' }}" = "rebaseline" ]; then
vendor/bin/phpbench run --report=aggregate --progress=plain --store --tag=${GITHUB_SHA}
# On main branch push, update baseline with tolerance for failures.
elif [ "${GITHUB_REF}" = "refs/heads/main" ] && [ "${GITHUB_EVENT_NAME}" = "push" ]; then
vendor/bin/phpbench run --report=aggregate --progress=plain --store --tag=${GITHUB_SHA} --ref=latest --tolerate-failure
# On other branches, compare against latest baseline, fails if worse.
else
vendor/bin/phpbench run --report=aggregate --progress=plain --store --tag=${GITHUB_SHA} --ref=latest
fi
# Generate report for human consumption
vendor/bin/phpbench report --report=aggregate --ref=latest |
tail -n+2 | head -n-2 | tr '+' '|' > report.md
cat report.md
- name: Commit Benchmark Results
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout benchmarks
mv -f report.md latest.md
git add .phpbench latest.md
git commit -m "Store benchmark results [skip ci]" || echo "No changes to commit"
git push origin benchmarks