-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (116 loc) · 4.07 KB
/
ci.yml
File metadata and controls
141 lines (116 loc) · 4.07 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
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: read
env:
PHP_PRIMARY: '8.5'
jobs:
validate:
name: Validate composer.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_PRIMARY }}
tools: composer:v2
- run: composer validate --strict
tests:
name: Tests / PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: validate
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4', '8.5', '8.6']
steps:
- uses: actions/checkout@v6
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: ${{ matrix.php == env.PHP_PRIMARY && 'xdebug' || 'none' }}
tools: composer:v2
- name: Cache Composer packages
uses: actions/cache@v4
with:
path: vendor
key: php-${{ matrix.php }}-${{ hashFiles('composer.json') }}
restore-keys: php-${{ matrix.php }}-
- run: composer install --no-interaction --no-progress --prefer-dist
- name: Run tests
if: matrix.php != env.PHP_PRIMARY
run: vendor/bin/phpunit --colors=always
- name: Run tests with coverage
if: matrix.php == env.PHP_PRIMARY
run: vendor/bin/phpunit --colors=always --coverage-text
env:
XDEBUG_MODE: coverage
phpstan:
name: PHPStan
runs-on: ubuntu-latest
needs: validate
steps:
- uses: actions/checkout@v6
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_PRIMARY }}
tools: composer:v2
- name: Cache Composer packages
uses: actions/cache@v4
with:
path: vendor
key: php-${{ env.PHP_PRIMARY }}-${{ hashFiles('composer.json') }}
restore-keys: php-${{ env.PHP_PRIMARY }}-
- run: composer install --no-interaction --no-progress --prefer-dist
- run: vendor/bin/phpstan analyse --no-progress --error-format=github
benchmark:
name: Benchmark
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_PRIMARY }}
coverage: none
extensions: curl, dom, mbstring, tokenizer, xml
ini-values: opcache.enable_cli=1, opcache.jit=1255, opcache.jit_buffer_size=128M
tools: composer:v2
- name: Cache Composer packages
uses: actions/cache@v4
with:
path: vendor
key: php-${{ env.PHP_PRIMARY }}-bench-${{ hashFiles('composer.json') }}
restore-keys: php-${{ env.PHP_PRIMARY }}-bench-
- run: composer install --no-interaction --no-progress --prefer-dist
- name: Benchmark baseline (master)
if: github.event_name == 'pull_request'
run: |
git checkout ${{ github.event.pull_request.base.sha }}
if [ ! -f phpbench.json ]; then
echo "No phpbench.json on base — skipping baseline"
git checkout ${{ github.event.pull_request.head.sha }}
exit 0
fi
composer install --no-interaction --no-progress --prefer-dist --quiet
vendor/bin/phpbench run --tag=baseline --progress=plain
git checkout ${{ github.event.pull_request.head.sha }}
composer install --no-interaction --no-progress --prefer-dist --quiet
- name: Benchmark (compare with baseline)
if: github.event_name == 'pull_request'
run: |
if vendor/bin/phpbench report --ref=baseline > /dev/null 2>&1; then
vendor/bin/phpbench run --ref=baseline --report=default --progress=plain
else
echo "No baseline available — running without comparison"
vendor/bin/phpbench run --report=default --progress=plain
fi
- name: Benchmark
if: github.event_name == 'push'
run: vendor/bin/phpbench run --report=default --progress=plain