-
Notifications
You must be signed in to change notification settings - Fork 584
160 lines (133 loc) · 6.04 KB
/
Copy pathbench.yml
File metadata and controls
160 lines (133 loc) · 6.04 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
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
160
name: "Benchmark"
on:
pull_request:
paths:
- 'src/**'
- '.github/workflows/bench.yml'
- 'tests/bench/**'
push:
branches:
- "2.2.x"
paths:
- 'src/**'
- '.github/workflows/bench.yml'
- 'tests/bench/**'
concurrency:
group: bench-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
baseline:
name: "Baseline (PHP ${{ matrix.php-version }})"
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.5"
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- name: "Checkout base branch"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Install PHP"
uses: "shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240" # 2.37.2
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: pecl
extensions: ds,mbstring
ini-file: development
ini-values: memory_limit=-1
- name: "Downgrade PHPUnit"
if: matrix.php-version == '7.4'
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 doctrine/instantiator:^1.0 --update-with-dependencies --ignore-platform-reqs"
- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0
# tests/composer.json pins the Composer platform to PHP 8.2, which would make
# Composer resolve PHPBench's Symfony dependencies to versions that cannot
# even be parsed on PHP 7.4. Unsetting it resolves against the real PHP version.
- name: "Downgrade PHPBench"
if: matrix.php-version == '7.4'
run: |
composer config --unset platform.php --working-dir=tests
composer require --dev phpbench/phpbench:1.2.14 phpunit/phpunit:^9.6 brianium/paratest:^6.5 --update-with-all-dependencies --working-dir=tests
- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0
if: matrix.php-version != '7.4'
with:
working-directory: "tests/"
- uses: ./.github/actions/downgrade-code
with:
php-version: "${{ matrix.php-version }}"
- name: "Run phpbench baseline"
run: "tests/vendor/bin/phpbench run --dump-file=tests/bench/storage/baseline-${{ matrix.php-version }}.xml --ansi"
# Before committing an artifact as the new baseline, compare the <baseline-machine>
# values (md5, file_rw) in it with the ones in the currently committed baseline.
# GitHub runners differ in speed by up to 2x, and a baseline recorded on a fast
# runner makes every later run look like a regression.
- name: "Upload baseline artifact"
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: phpbench-baseline-${{ matrix.php-version }}
path: tests/bench/storage/baseline-${{ matrix.php-version }}.xml
test:
name: "Test (PHP ${{ matrix.php-version }})"
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
# phpbench 1.2.14 is the last version supporting PHP 7.4
# and it does not have the aggregate-preview report 'my-report' extends
- php-version: "7.4"
report: "aggregate"
- php-version: "8.5"
report: "my-report"
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- name: "Checkout"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Install PHP"
uses: "shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240" # 2.37.2
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: pecl
extensions: ds,mbstring
ini-file: development
ini-values: memory_limit=-1
- name: "Downgrade PHPUnit"
if: matrix.php-version == '7.4'
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 doctrine/instantiator:^1.0 --update-with-dependencies --ignore-platform-reqs"
- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0
# tests/composer.json pins the Composer platform to PHP 8.2, which would make
# Composer resolve PHPBench's Symfony dependencies to versions that cannot
# even be parsed on PHP 7.4. Unsetting it resolves against the real PHP version.
- name: "Downgrade PHPBench"
if: matrix.php-version == '7.4'
run: |
composer config --unset platform.php --working-dir=tests
composer require --dev phpbench/phpbench:1.2.14 phpunit/phpunit:^9.6 brianium/paratest:^6.5 --update-with-all-dependencies --working-dir=tests
- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0
if: matrix.php-version != '7.4'
with:
working-directory: "tests/"
- uses: ./.github/actions/downgrade-code
with:
php-version: "${{ matrix.php-version }}"
# PHPBench does not fail when the baseline file is missing, it just runs
# with an empty baseline and every assertion passes
- name: "Check that the baseline exists"
run: |
test -f tests/bench/storage/baseline-${{ matrix.php-version }}.xml \
|| (echo "Missing tests/bench/storage/baseline-${{ matrix.php-version }}.xml, download it from the phpbench-baseline-${{ matrix.php-version }} artifact of the Baseline job and commit it." && exit 1)
- name: "Run phpbench test"
run: "tests/vendor/bin/phpbench run --file=tests/bench/storage/baseline-${{ matrix.php-version }}.xml --report=${{ matrix.report }} --ansi"