Skip to content

Commit 76b64f7

Browse files
authored
PHPUnit 13 Support (#67)
1 parent b44b9ed commit 76b64f7

8 files changed

Lines changed: 185 additions & 134 deletions

.github/workflows/benchmark.yml

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions:
1212

1313
jobs:
1414
benchmark:
15-
15+
1616
runs-on: ubuntu-latest
1717

1818
steps:
@@ -26,21 +26,31 @@ jobs:
2626
- name: Setup PHP
2727
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f
2828
with:
29-
php-version: '8.4'
29+
php-version: '8.5'
3030
extensions: zip, curl, mbstring, xml
3131
coverage: none
32+
tools: composer:v2
33+
34+
# Step 2.1: Install PHPBench globally
35+
- name: Install PHPBench
36+
run: |
37+
composer global require phpbench/phpbench:^1.6 --prefer-dist --no-progress --no-interaction
38+
PHPBENCH_BIN="$(composer global config bin-dir --absolute)/phpbench"
39+
echo "PHPBENCH_BIN=$PHPBENCH_BIN" >> "$GITHUB_ENV"
40+
"$PHPBENCH_BIN" --version
3241
3342
# Step 3: Install dependencies for PR branch
3443
- name: Install Composer dependencies
3544
run: |
36-
composer install --prefer-dist --no-progress --no-suggest
37-
composer require --dev phpbench/phpbench
45+
# Remove dependency artifacts that can leak across branch switches in CI
46+
git clean -ffdx -- composer.lock vendor
47+
composer install --prefer-dist --no-progress
3848
3949
# Step 4: Run benchmarks on PR branch
4050
- name: Run benchmarks on PR branch
4151
run: |
4252
mkdir -p tests/Benchmark
43-
./vendor/bin/phpbench run tests/Benchmark \
53+
"$PHPBENCH_BIN" run tests/Benchmark \
4454
--report=default \
4555
--tag=pr \
4656
--retry-threshold=5 \
@@ -54,17 +64,41 @@ jobs:
5464
env:
5565
BASE_REF: ${{ github.base_ref }}
5666

67+
# Step 5.1: Diagnose Composer state on base branch
68+
- name: Diagnose Composer state (base)
69+
run: |
70+
echo "Commit: $(git rev-parse --short HEAD)"
71+
echo "Base ref: origin/$BASE_REF"
72+
echo "phpunit/phpunit constraint in composer.json:"
73+
grep -n '"phpunit/phpunit"' composer.json || true
74+
75+
if [ -f composer.lock ]; then
76+
echo "composer.lock present before cleanup"
77+
php -r '$lock = json_decode(file_get_contents("composer.lock"), true); $version = "not-found"; foreach (($lock["packages-dev"] ?? []) as $pkg) { if (($pkg["name"] ?? "") === "phpunit/phpunit") { $version = $pkg["version"] ?? "unknown"; break; } } echo "locked phpunit/phpunit: {$version}\n";'
78+
else
79+
echo "composer.lock missing before cleanup"
80+
fi
81+
82+
echo "ignore status for composer.lock:"
83+
git check-ignore -v composer.lock || true
84+
85+
echo "git status snapshot:"
86+
git status --short -- composer.json composer.lock vendor || true
87+
env:
88+
BASE_REF: ${{ github.base_ref }}
89+
5790
# Step 6: Install dependencies for base branch
5891
- name: Install Composer dependencies (base)
5992
run: |
60-
composer install --prefer-dist --no-progress --no-suggest
61-
composer require --dev phpbench/phpbench
93+
# Ensure install uses only files from the checked out base branch
94+
git clean -ffdx -- composer.lock vendor
95+
composer install --prefer-dist --no-progress
6296
6397
# Step 7: Run benchmarks on base branch
6498
- name: Run benchmarks on base branch
6599
run: |
66100
mkdir -p tests/Benchmark
67-
./vendor/bin/phpbench run tests/Benchmark \
101+
"$PHPBENCH_BIN" run tests/Benchmark \
68102
--report=default \
69103
--tag=base \
70104
--retry-threshold=5 \
@@ -76,12 +110,19 @@ jobs:
76110
env:
77111
HEAD_REF: ${{ github.head_ref }}
78112

113+
# Step 8.1: Reinstall dependencies for PR branch
114+
- name: Install Composer dependencies (PR, comparison)
115+
run: |
116+
# Prevent base branch dependency artifacts from affecting PR comparison run
117+
git clean -ffdx -- composer.lock vendor
118+
composer install --prefer-dist --no-progress
119+
79120
# Step 9: Compare benchmarks
80121
- name: Compare benchmarks with baseline
81122
id: compare
82123
run: |
83124
mkdir -p tests/Benchmark
84-
./vendor/bin/phpbench run tests/Benchmark \
125+
"$PHPBENCH_BIN" run tests/Benchmark \
85126
--report=aggregate \
86127
--ref=base \
87128
--retry-threshold=5 \

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@ composer.lock
33
*.cache
44
clover.xml
55
junit-logfile.xml
6+
tmp/
7+
8+
# Agents
9+
.agents/
10+
.claude/
11+
.windsurf/
12+
skills-lock.json

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require-dev": {
13-
"phpunit/phpunit": "^4.8 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0"
13+
"phpunit/phpunit": "^4.8 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0"
1414
},
1515
"autoload": {
1616
"psr-4": {
@@ -19,5 +19,8 @@
1919
"files": [
2020
"src/helpers.php"
2121
]
22+
},
23+
"scripts": {
24+
"test": ["@php vendor/bin/phpunit"]
2225
}
2326
}

0 commit comments

Comments
 (0)