-
Notifications
You must be signed in to change notification settings - Fork 1
169 lines (138 loc) · 6.31 KB
/
ci.yml
File metadata and controls
169 lines (138 loc) · 6.31 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
161
162
163
164
165
166
167
168
169
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ──────────────────────────────────────────────────────────────────
# Static Analysis — PHPStan
# ──────────────────────────────────────────────────────────────────
phpstan:
name: "PHPStan (level 8)"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
coverage: none
tools: composer:v2
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-php8.2-${{ hashFiles('**/composer.lock') }}
restore-keys: composer-${{ runner.os }}-php8.2-
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Run PHPStan
run: vendor/bin/phpstan analyse --error-format=github
# ──────────────────────────────────────────────────────────────────
# Test Matrix — PHP 8.2, 8.3, 8.4 × latest deps / lowest deps
# ──────────────────────────────────────────────────────────────────
tests:
name: "PHPUnit (${{ matrix.php }}, ${{ matrix.deps }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ "8.2", "8.3", "8.4" ]
deps: [ "latest", "lowest" ]
exclude:
# lowest deps with bleeding-edge PHP is noisy — skip it
- php: "8.4"
deps: "lowest"
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, pcntl, posix
coverage: ${{ matrix.php == '8.3' && matrix.deps == 'latest' && 'xdebug' || 'none' }}
tools: composer:v2
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-php${{ matrix.php }}-${{ matrix.deps }}-${{ hashFiles('**/composer.lock') }}
restore-keys: composer-${{ runner.os }}-php${{ matrix.php }}-
- name: Install latest dependencies
if: matrix.deps == 'latest'
run: composer install --no-interaction --prefer-dist --no-progress
- name: Install lowest dependencies
if: matrix.deps == 'lowest'
run: composer update --no-interaction --prefer-dist --no-progress --prefer-lowest
- name: Run tests (with coverage)
if: matrix.php == '8.3' && matrix.deps == 'latest'
run: vendor/bin/phpunit --coverage-clover=build/coverage/clover.xml
- name: Run tests (no coverage)
if: matrix.php != '8.3' || matrix.deps != 'latest'
run: vendor/bin/phpunit --no-coverage
- name: Upload coverage to Codecov
if: matrix.php == '8.3' && matrix.deps == 'latest'
uses: codecov/codecov-action@v6
with:
files: build/coverage/clover.xml
fail_ci_if_error: false
# ──────────────────────────────────────────────────────────────────
# Code Style — PHP CS Fixer (future gate, currently informational)
# ──────────────────────────────────────────────────────────────────
codestyle:
name: "Code Style (dry-run)"
runs-on: ubuntu-latest
continue-on-error: true # informational until .php-cs-fixer.php is added
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
coverage: none
tools: composer:v2, cs2pr
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Check if php-cs-fixer is installed
id: check-fixer
run: |
if [ -f vendor/bin/php-cs-fixer ]; then
echo "installed=true" >> $GITHUB_OUTPUT
else
echo "installed=false" >> $GITHUB_OUTPUT
fi
- name: Run PHP CS Fixer (dry-run)
if: steps.check-fixer.outputs.installed == 'true'
run: vendor/bin/php-cs-fixer fix --dry-run --diff --format=checkstyle | cs2pr
# ──────────────────────────────────────────────────────────────────
# Security Audit
# ──────────────────────────────────────────────────────────────────
security:
name: "Security Audit"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Composer audit
run: composer audit --no-interaction