-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
318 lines (253 loc) · 11.8 KB
/
Copy pathMakefile
File metadata and controls
318 lines (253 loc) · 11.8 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
##
## InvoicePlane v2 — Development Makefile
## ──────────────────────────────────────────────────────────────────────────────
##
## QUICK START
## make test Run the full PHPUnit suite (all tests)
## make smoke Run only @group smoke tests (fast sanity check)
## make unit Run only unit tests
## make feature Run only feature (Filament/Livewire) tests
## make artisan-test Run tests via `php artisan test`
##
## TARGETED RUNS (by module)
## make test-core make test-invoices make test-quotes
## make test-products make test-payments make test-projects
## make test-clients make test-expenses
##
## TARGETED RUNS (by group)
## make test-group GROUP=smoke|crud|unit|validation|multi-tenancy|...
##
## TARGETED RUNS (by filter)
## make filter FILTER="InvoiceModelTest" exact class name
## make filter FILTER="InvoiceModelTest::it_" specific method prefix
##
## COVERAGE
## make coverage HTML coverage report → build/coverage/
## make coverage-text Text-mode summary in terminal
## make coverage-clover Clover XML (for CI)
##
## ARTISAN TEST VARIANTS
## make artisan-test Full suite via artisan
## make artisan-smoke Smoke group via artisan
## make artisan-filter FILTER= Single test via artisan
## make artisan-parallel Parallel test run via artisan
##
## CI / UTILITIES
## make ci Full suite in a single command (same as CI pipeline)
## make clean Remove PHPUnit cache, coverage, and temp artefacts
## make help Print this help text
##
## ENVIRONMENT VARIABLES (all have sane defaults; override on the CLI)
## PHP Path to the PHP binary (default: php)
## PHPUNIT Path to PHPUnit binary (default: vendor/bin/phpunit)
## CONFIG PHPUnit XML config file (default: phpunit.xml)
## FILTER Test filter passed to --filter
## GROUP Test group passed to --group
## SUITE Test suite name passed to --testsuite (Unit | Feature)
## MODULE Module directory name (e.g. Invoices, Products)
## STOP Set to 1 to stop on first failure: make test STOP=1
##
## ──────────────────────────────────────────────────────────────────────────────
# ── Configurable defaults ──────────────────────────────────────────────────────
PHP ?= php
PHPUNIT ?= vendor/bin/phpunit
CONFIG ?= phpunit.xml
FILTER ?=
GROUP ?=
SUITE ?=
MODULE ?=
STOP ?=
# ── Internal helpers ───────────────────────────────────────────────────────────
# Build optional flag strings; only include a flag when the variable is set.
_filter = $(if $(FILTER),--filter "$(FILTER)")
_group = $(if $(GROUP),--group "$(GROUP)")
_suite = $(if $(SUITE),--testsuite "$(SUITE)")
_stop = $(if $(STOP),--stop-on-failure)
# The core PHPUnit invocation (all optional flags appended).
_phpunit = APP_ENV=testing $(PHPUNIT) --configuration $(CONFIG) \
--exclude-group failing,troubleshooting $(_stop) $(_filter) $(_group) $(_suite)
# The core artisan invocation.
_artisan = APP_ENV=testing $(PHP) artisan test --exclude-group failing,troubleshooting
.DEFAULT_GOAL := help
.PHONY: help test unit feature smoke ci \
filter group suite \
test-core test-invoices test-quotes test-products \
test-payments test-projects test-clients test-expenses \
test-group \
coverage coverage-text coverage-clover \
artisan-test artisan-smoke artisan-filter artisan-parallel \
clean
# ── Help ──────────────────────────────────────────────────────────────────────
help:
@grep -E '^##' $(MAKEFILE_LIST) | sed 's/^## //'
# ── Full suite ────────────────────────────────────────────────────────────────
docker-test:
docker exec ivpldock-workspace-1 bash -c "cd /var/www/projects/ip2 && DB_HOST=mariadb php artisan test --exclude-groups=failing,troubleshooting"
## ─── Full suite ───────────────────────────────────────────────────────────────
test:
$(_phpunit)
## Run only the Unit test suite (Modules/*/Tests/Unit)
unit:
$(_phpunit) --testsuite Unit
## Run only the Feature test suite (Modules/*/Tests/Feature)
feature:
$(_phpunit) --testsuite Feature
## Run only @group smoke tests (fast sanity check, uses phpunit.smoke.xml)
smoke:
APP_ENV=testing $(PHPUNIT) --configuration phpunit.smoke.xml
## ─── Stop on first failure ────────────────────────────────────────────────────
## Full suite, stop on the first failure or error
test-bail:
$(_phpunit) --stop-on-failure --stop-on-error
## Unit suite, stop on the first failure or error
unit-bail:
$(_phpunit) --testsuite Unit --stop-on-failure --stop-on-error
## Feature suite, stop on the first failure or error
feature-bail:
$(_phpunit) --testsuite Feature --stop-on-failure --stop-on-error
# ── Flexible filter / group / suite targets ───────────────────────────────────
## Run tests matching a class or method name (usage: make filter FILTER=MyTest)
filter:
$(_phpunit) $(_filter)
## Run tests in a named group (usage: make group GROUP=smoke)
group:
$(_phpunit) $(_group)
## Run a specific test suite by name (usage: make suite SUITE=Unit)
suite:
$(_phpunit) $(_suite)
# ── Per-module targets ────────────────────────────────────────────────────────
## Run all tests in Modules/Core
test-core:
$(_phpunit) --filter "Modules\\\\Core\\\\"
## Run all tests in Modules/Invoices
test-invoices:
$(_phpunit) --filter "Modules\\\\Invoices\\\\"
## Run all tests in Modules/Quotes
test-quotes:
$(_phpunit) --filter "Modules\\\\Quotes\\\\"
## Run all tests in Modules/Products
test-products:
$(_phpunit) --filter "Modules\\\\Products\\\\"
## Run all tests in Modules/Payments
test-payments:
$(_phpunit) --filter "Modules\\\\Payments\\\\"
## Run all tests in Modules/Projects
test-projects:
$(_phpunit) --filter "Modules\\\\Projects\\\\"
## Run all tests in Modules/Clients
test-clients:
$(_phpunit) --filter "Modules\\\\Clients\\\\"
## Run all tests in Modules/Expenses
test-expenses:
$(_phpunit) --filter "Modules\\\\Expenses\\\\"
## Run tests in an arbitrary module (usage: make test-module MODULE=Invoices)
test-module:
$(_phpunit) --filter "Modules\\\\$(MODULE)\\\\"
# ── Per-group targets ─────────────────────────────────────────────────────────
## Run @group smoke tests
test-smoke:
$(_phpunit) --group smoke
## Run @group crud tests
test-crud:
$(_phpunit) --group crud
## Run @group unit tests
test-unit-group:
$(_phpunit) --group unit
## Run @group validation tests
test-validation:
$(_phpunit) --group validation
## Run @group multi-tenancy tests
test-multi-tenancy:
$(_phpunit) --group multi-tenancy
## Run @group export tests
test-export:
$(_phpunit) --group export
## Run @group security tests
test-security:
$(_phpunit) --group security
## Run @group numbering tests
test-numbering:
$(_phpunit) --group numbering
## Run @group authentication tests
test-authentication:
$(_phpunit) --group authentication
## Run @group edge-cases tests
test-edge-cases:
$(_phpunit) --group edge-cases
## Run @group modals tests
test-modals:
$(_phpunit) --group modals
## Run tests in an arbitrary group (usage: make test-group GROUP=crud)
test-group:
$(_phpunit) --group "$(GROUP)"
# ── Exclude groups ─────────────────────────────────────────────────────────────
## Run all tests except the 'failing' group (useful during active development)
#test-no-failing:
# $(_phpunit) --exclude-group failing
## Run all tests except 'troubleshooting' and 'failing' groups
#test-stable:
# $(_phpunit) --exclude-group failing,troubleshooting
# ── Coverage ──────────────────────────────────────────────────────────────────
## Generate HTML coverage report in build/coverage/html/
coverage:
APP_ENV=testing XDEBUG_MODE=coverage $(PHPUNIT) \
--configuration $(CONFIG) \
--coverage-html build/coverage/html
@echo "Coverage report generated: build/coverage/html/index.html"
## Print a text-mode coverage summary to the terminal
coverage-text:
APP_ENV=testing XDEBUG_MODE=coverage $(PHPUNIT) \
--configuration $(CONFIG) \
--coverage-text
## Generate Clover XML coverage (for CI / SonarQube / Codecov)
coverage-clover:
APP_ENV=testing XDEBUG_MODE=coverage $(PHPUNIT) \
--configuration $(CONFIG) \
--coverage-clover build/coverage/clover.xml
@echo "Clover report: build/coverage/clover.xml"
## Generate coverage for a single module (usage: make coverage-module MODULE=Invoices)
coverage-module:
APP_ENV=testing XDEBUG_MODE=coverage $(PHPUNIT) \
--configuration $(CONFIG) \
--filter "Modules\\\\$(MODULE)\\\\" \
--coverage-text
# ── php artisan test variants ─────────────────────────────────────────────────
## Run the full test suite via php artisan test
artisan-test:
$(_artisan)
## Run only @group smoke tests via artisan
artisan-smoke:
$(_artisan) --group smoke
## Run only the Unit suite via artisan
artisan-unit:
$(_artisan) --testsuite Unit
## Run only the Feature suite via artisan
artisan-feature:
$(_artisan) --testsuite Feature
## Run a specific test via artisan (usage: make artisan-filter FILTER=MyTest)
artisan-filter:
$(_artisan) --filter "$(FILTER)"
## Run tests in parallel via artisan (requires ext-pcntl)
artisan-parallel:
$(_artisan) --parallel
## Run artisan test with compact output
artisan-pretty:
$(_artisan) --compact
## Run artisan test and stop on first failure
artisan-bail:
$(_artisan) --bail
# ── CI / pipeline ─────────────────────────────────────────────────────────────
## Full CI run: complete PHPUnit suite, stop on failure, no caching
ci:
APP_ENV=testing $(PHPUNIT) \
--configuration $(CONFIG) \
--exclude-group failing,troubleshooting
--stop-on-failure \
--stop-on-error \
--cache-result-file /dev/null
# ── Utilities ─────────────────────────────────────────────────────────────────
## Remove PHPUnit result cache, coverage build artefacts, and temp files
clean:
rm -f .phpunit.result.cache
rm -rf build/coverage
@echo "Cleaned up PHPUnit cache and coverage artefacts."