-
Notifications
You must be signed in to change notification settings - Fork 340
275 lines (249 loc) · 9.21 KB
/
lint-and-analyse-php.yml
File metadata and controls
275 lines (249 loc) · 9.21 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: Linters
# If a pull-request is pushed then cancel all previously running jobs related
# to that pull-request
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened]
branches:
- develop
permissions:
contents: read
jobs:
lint:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6.2.0
with:
python-version: "3.13"
- run: pip install --upgrade tox
- name: Run commitizen (https://commitizen-tools.github.io/commitizen/)
run: tox -e cz
- name: Run config-check
run: tox -e config-check
- name: Run doc8
run: tox -e doc8
- name: Install shellcheck and shfmt
run: sudo apt-get update && sudo apt-get install -y shellcheck shfmt
- name: Run shellcheck
run: |
find . -name '*.sh' -not -path './vendor/*' -not -path './node_modules/*' \
-exec shellcheck --severity style {} +
- name: Run shfmt (indent=4)
run: |
if ! find . -name '*.sh' -not -path './vendor/*' -not -path './node_modules/*' \
-exec shfmt -d -i 4 -ci {} +; then
echo ""
echo "=========================================="
echo " shfmt found shell script formatting issues."
echo " To fix them locally, run:"
echo ""
echo " find . -name '*.sh' -not -path './vendor/*' -not -path './node_modules/*' -exec shfmt -w -i 4 -ci {} +"
echo ""
echo " Then commit the changes."
echo "=========================================="
exit 1
fi
- name: Ensure no merge-commits in the Pull Request (PR)
if: github.event_name == 'pull_request'
run: |
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
echo "GITHUB_BASE_REF: ${GITHUB_BASE_REF}"
echo "HEAD_SHA: ${HEAD_SHA}"
git fetch origin "${GITHUB_BASE_REF}"
MERGE_COMMITS=$(git rev-list --merges origin/${GITHUB_BASE_REF}..${HEAD_SHA})
if [[ -n "${MERGE_COMMITS}" ]]; then
echo ""
echo "=========================================="
echo "ERROR: The Pull Request (PR) contains a 'merge commit' which is not allowed: ${MERGE_COMMITS}"
echo "Please 'rebase' to remove the 'merge commit'"
echo "=========================================="
echo ""
exit 1
fi
markdownlint:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: markdownlint-cli2-action
uses: DavidAnson/markdownlint-cli2-action@v23
with:
config: 'docs/.markdownlint.yml'
globs: |
*.md
lint-php-files:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ["8.2", "8.3", "8.4", "8.5"]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Install Composer dependencies
uses: ramsey/composer-install@v4
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Lint PHP files
run: ./ci/ci-phplint
- name: Cache php-cs-fixer
if: matrix.php-version == '8.2'
uses: actions/cache@v5
with:
path: var/cache/.php-cs-fixer.cache
key: php-cs-fixer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.lock', '.php-cs-fixer.dist.php') }}
restore-keys: |
php-cs-fixer-${{ runner.os }}-${{ matrix.php-version }}-
- name: Check coding-standard (php-cs-fixer)
if: matrix.php-version == '8.2'
run: |
if ! composer phpcsfixer:lint; then
echo ""
echo "=========================================="
echo " php-cs-fixer found code style issues."
echo " To fix them locally, run:"
echo ""
echo " composer phpcsfixer:fix"
echo ""
echo " Then commit the changes."
echo "=========================================="
exit 1
fi
analyse-php:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- php-version: "8.5"
stan-label: "base"
composer-script: "phpstan"
stan-cache-dir: "base"
stan-config-file: "phpstan.neon"
- php-version: "8.5"
stan-label: "next"
composer-script: "phpstan_next"
stan-cache-dir: "next"
stan-config-file: "phpstan_next.neon"
name: analyse-php (${{ matrix.stan-label }})
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Install Composer dependencies
uses: ramsey/composer-install@v4
with:
custom-cache-suffix: ${{ matrix.stan-label }}
- name: Cache PHPStan result cache
uses: actions/cache@v5
with:
path: var/cache/phpstan/${{ matrix.stan-cache-dir }}
key: phpstan-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.stan-cache-dir }}-${{ hashFiles('composer.lock', matrix.stan-config-file) }}
restore-keys: |
phpstan-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.stan-cache-dir }}-
- name: Analyse files with PHPStan
run: |
if ! composer ${{ matrix.composer-script }} -- --error-format=github --no-progress --memory-limit 2G; then
echo "Primary PHPStan run failed. Running debug fallback..."
composer ${{ matrix.composer-script }} -- --debug -vvv --error-format=table --memory-limit 2G || true
exit 1
fi
# - name: Analyse files with Psalm
# # Allow the previous check to fail but not abort
# if: always()
# run: composer psalm -- --shepherd
lint-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Check formatting (Prettier)
run: |
if ! npm run lint:format; then
echo ""
echo "=========================================="
echo " Prettier found formatting issues."
echo " To fix them locally, run:"
echo ""
echo " npm run fix:format"
echo ""
echo " Then commit the changes."
echo ""
echo " If you haven't set up Node.js tooling yet, run:"
echo ""
echo " npm ci"
echo ""
echo " This installs the tools needed to run the"
echo " 'npm run fix:*' and 'npm run lint:*' commands."
echo " Requires Node.js (see package.json for minimum version)."
echo "=========================================="
exit 1
fi
- name: Lint JavaScript (ESLint)
run: |
if ! npm run lint:js; then
echo ""
echo "=========================================="
echo " ESLint found issues."
echo " To auto-fix what it can, run:"
echo ""
echo " npm run fix:js"
echo ""
echo " Then commit the changes."
echo ""
echo " If you haven't set up Node.js tooling yet, run:"
echo ""
echo " npm ci"
echo ""
echo " This installs the tools needed to run the"
echo " 'npm run fix:*' and 'npm run lint:*' commands."
echo " Requires Node.js (see package.json for minimum version)."
echo "=========================================="
exit 1
fi
- name: Lint CSS (Stylelint)
run: |
if ! npm run lint:css; then
echo ""
echo "=========================================="
echo " Stylelint found CSS issues."
echo " To auto-fix what it can, run:"
echo ""
echo " npm run fix:css"
echo ""
echo " Then commit the changes."
echo ""
echo " If you haven't set up Node.js tooling yet, run:"
echo ""
echo " npm ci"
echo ""
echo " This installs the tools needed to run the"
echo " 'npm run fix:*' and 'npm run lint:*' commands."
echo " Requires Node.js (see package.json for minimum version)."
echo "=========================================="
exit 1
fi