-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
258 lines (194 loc) · 11.4 KB
/
Copy pathMakefile
File metadata and controls
258 lines (194 loc) · 11.4 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
.DEFAULT_GOAL = help
.PHONY : help purge-runtime setup-dev setup-prod upgrade-dev upgrade-prod install prod warmup purge reset load-fixtures upgrade node_modules backup backup-db backup-files restore-db verify-restore-baseline verify-restore env-check update-security-advisories
# Executables
COMPOSER = composer
NPM = npm
DOCKER = docker
SYMFONY = symfony
# Alias
CONSOLE = $(SYMFONY) console
PROD_ENV = APP_ENV=prod APP_DEBUG=0
# Vendor executables
PHPUNIT = ./bin/phpunit
PHPSTAN = ./vendor/bin/phpstan
PHP_CS_FIXER = ./vendor/bin/php-cs-fixer
PSALM = ./vendor/bin/psalm
RECTOR = ./vendor/bin/rector
DEPTRAC = ./vendor/bin/deptrac
SWISS_KNIFE = ./vendor/bin/swiss-knife
SWISS_KNIFE_FINALIZE_OPTS = --skip-mocked --skip-file 'src/**/Domain/Entity/*' --skip-file 'src/**/Infrastructure/Entity/*'
TWIG_CS_FIXER = ./vendor/bin/twig-cs-fixer
## —— 🎵 🐳 The Symfony Docker makefile 🐳 🎵 ——————————————————————————————————
help: ## Outputs this help screen
@grep -E '(^[a-zA-Z0-9\./_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
## —— Project setup 🚀 ——————————————————————————————————————————————————————————
setup-dev: ## Full dev install (fresh DB, fixtures, test DB, npm)
@$(COMPOSER) install --no-interaction
@$(SYMFONY) composer setup-env
@$(SYMFONY) composer setup-test-env
@$(CONSOLE) asset-map:compile
@$(MAKE) node_modules
setup-prod: ## Prod-like install (empty DB, no fixtures, requires .env.local)
@$(PROD_ENV) $(COMPOSER) install --prefer-dist --no-dev --no-progress --no-interaction --no-scripts
rm -rf var/cache/* public/assets/*
@$(PROD_ENV) $(CONSOLE) importmap:install
@$(PROD_ENV) $(CONSOLE) assets:install public
@$(PROD_ENV) $(CONSOLE) asset-map:compile
@$(PROD_ENV) $(CONSOLE) cache:clear
@$(PROD_ENV) $(CONSOLE) cache:warmup
@$(SYMFONY) composer setup-database
upgrade-dev: ## Update deps and schema (dev, keeps existing DB data)
@$(COMPOSER) install --no-interaction --no-scripts
@$(CONSOLE) doctrine:migrations:migrate --no-interaction --allow-no-migration
@$(SYMFONY) composer upgrade-test-env
@$(CONSOLE) importmap:install
@$(CONSOLE) asset-map:compile
@$(CONSOLE) cache:clear
@$(CONSOLE) cache:warmup
@$(MAKE) node_modules
upgrade-prod: ## Update deps and schema (prod-like, keeps existing DB data)
@$(PROD_ENV) $(COMPOSER) install --prefer-dist --no-dev --no-progress --no-interaction --no-scripts
@$(PROD_ENV) $(CONSOLE) doctrine:migrations:migrate --no-interaction --allow-no-migration
rm -rf public/assets/*
@$(CONSOLE) importmap:install
@$(PROD_ENV) $(CONSOLE) asset-map:compile
@$(PROD_ENV) $(CONSOLE) cache:clear
@$(PROD_ENV) $(CONSOLE) cache:warmup
install: setup-dev ## Alias for setup-dev; use upgrade-dev for an existing mirror DB
prod: setup-prod ## Alias for setup-prod
upgrade: ## Pick upgrade-dev or upgrade-prod explicitly
@echo "Use 'make upgrade-dev' or 'make upgrade-prod'." >&2
@exit 1
warmup: ## Warm cache and compiled assets only (does not touch the database)
@$(CONSOLE) asset-map:compile
@$(CONSOLE) cache:warmup
## —— Composer 🧙 ——————————————————————————————————————————————————————————————
vendor: composer.lock ## Install vendors according to the current composer.lock file
@$(COMPOSER) install --prefer-dist --no-dev --no-progress --no-interaction
update-security-advisories: ## Refresh roave/security-advisories (ignored by Dependabot)
@$(COMPOSER) update roave/security-advisories --no-interaction
## —— Node / npm 📦 ———————————————————————————————————————————————————————————
node_modules: package-lock.json ## Install npm dev dependencies according to package-lock.json
@$(NPM) install
## —— Docker 🐳 ————————————————————————————————————————————————————————————————
start: build up ## Build and start the containers
build: ## Builds the Docker images
@$(DOCKER) compose build --pull --no-cache
up: ## Start the docker hub in detached mode (no logs)
@$(DOCKER) compose up --detach
down: ## Stop the docker hub
@$(DOCKER) compose down --remove-orphans
logs: ## Show live logs
@$(DOCKER) compose logs --tail=0 --follow
## —— Symfony 🎵 ———————————————————————————————————————————————————————————————
compile: ## Execute some tasks before deployment
rm -rf public/assets/*
@$(CONSOLE) asset-map:compile
@$(CONSOLE) cache:clear
@$(CONSOLE) cache:warmup
consume: ## Consume messages from symfony messenger
@$(CONSOLE) messenger:consume async_priority_high async_priority_low async_mail scheduler_default -vv
## —— Backups 💾 ———————————————————————————————————————————————————————————————
backup-db: ## PostgreSQL dump to var/backups (uses Docker database service when running)
@./bin/ops/backup-database.sh
backup-files: ## Archive var/imports and public/uploads/media to var/backups
@./bin/ops/backup-files.sh
backup: backup-db backup-files ## Full backup (database + files)
restore-db: ## Restore DB from BACKUP_FILE=var/backups/....dump RESTORE_CONFIRM=yes
@if [ -z "$(BACKUP_FILE)" ]; then echo "Set BACKUP_FILE=var/backups/ivena-stats-db-....dump" >&2; exit 1; fi
@if [ "$(RESTORE_CONFIRM)" != "yes" ]; then echo "Set RESTORE_CONFIRM=yes to confirm destructive restore." >&2; exit 1; fi
@RESTORE_CONFIRM=yes BACKUP_FILE="$(BACKUP_FILE)" ./bin/ops/restore-database.sh
verify-restore-baseline: ## Save DB metrics snapshot for restore drill
@./bin/ops/verify-restore.sh baseline
verify-restore: ## Compare current DB metrics with saved baseline (exit 1 on mismatch)
@./bin/ops/verify-restore.sh verify
env-check: ## Validate environment variables (dev profile; use --check-profile=beta on server)
@$(CONSOLE) app:env:check --skip-database
fixtures: ## Load dev demo fixtures (replaces existing fixture data)
@$(SYMFONY) composer load-fixtures
TRANS_DOMAINS := messages statistics allocation import user content onboarding feedback engagement admin shared errors validators
trans: ## Extract EN translations (messages domain only)
@$(CONSOLE) translation:extract messages --dump-messages --force --sort=asc en
trans-de: ## Extract missing DE translation skeletons (messages domain)
@$(CONSOLE) translation:extract messages --dump-messages --force --sort=asc de
trans-all: ## Extract EN translations for all application domains
@for domain in $(TRANS_DOMAINS); do \
$(CONSOLE) translation:extract $$domain --dump-messages --force --sort=asc en || exit 1; \
done
trans-de-all: ## Extract missing DE translation skeletons for all application domains
@for domain in $(TRANS_DOMAINS); do \
$(CONSOLE) translation:extract $$domain --dump-messages --force --sort=asc de || exit 1; \
done
## —— Coding standards ✨ ——————————————————————————————————————————————————————
lint: lint-container lint-php lint-twig lint-trans lint-js static-analysis ## Run continuous integration pipeline
cs: rector fix-php ## Run all coding standards checks
ci: check-phpunit-suite-dirs swiss-knife rector fix-php fix-twig fix-js static-analysis
static-analysis: phpstan psalm ## Run the static analysis
fix-php: ## Fix files with php-cs-fixer
@$(PHP_CS_FIXER) fix
fix-twig: ## Fix files with twig-cs-fixer
@$(TWIG_CS_FIXER) --fix
lint-container: ## Lint translations
@$(CONSOLE) lint:container
lint-php: ## Lint files with php-cs-fixer
@$(PHP_CS_FIXER) fix --dry-run
lint-trans: ## Lint translations
@$(CONSOLE) lint:translations --locale=en
@$(CONSOLE) lint:translations --locale=de
lint-trans-de: ## Lint DE translation contents
@$(CONSOLE) lint:translations --locale=de
lint-twig: ## Lint files with twig-cs-fixer
@$(TWIG_CS_FIXER)
lint-js: ## Lint JavaScript (Prettier + ESLint)
@npm run check:js
fix-js: ## Fix JavaScript formatting and auto-fixable ESLint issues
@npm run format
@npm run lint:fix
phpstan: ## Run PHPStan
@$(PHPSTAN) analyse --memory-limit=-1
psalm: ## Run Psalm
@$(PSALM) --show-info=true
rector: ## Run Rector
@$(RECTOR)
deptrac: ## Run Deptrac architecture analysis
@$(DEPTRAC) analyse --no-progress
deptrac-baseline: ## Regenerate deptrac.baseline.yaml from current violations
@$(DEPTRAC) analyse --formatter=baseline --output=deptrac.baseline.yaml --no-progress
swiss-knife: ## Apply Swiss Knife fixes (conflicts, commented code, finalize)
@$(SWISS_KNIFE) check-conflicts . --exclude vendor --exclude var
@$(SWISS_KNIFE) check-commented-code src tests
@$(SWISS_KNIFE) finalize-classes src tests $(SWISS_KNIFE_FINALIZE_OPTS)
check-deprecations: ## Run deprecation checks (console + phpunit)
@./bin/check-deprecations
check-phpunit-suite-dirs: ## Fail if tests/{Context}/{Unit|Integration|Functional} drift from phpunit.dist.xml suites
@./bin/check-phpunit-suite-dirs
## —— Tests ✅ —————————————————————————————————————————————————————————————————
SUITE ?= all
PATH_ARG ?=
GROUP ?=
EXCLUDE_GROUP ?=
ARGS ?=
test: ## Run tests (SUITE=all|unit|integration|functional|functional-http|browser|fixtures|system|materialized-view, PATH_ARG=tests/…, GROUP=, EXCLUDE_GROUP=, ARGS=)
@SUITE=$(SUITE) PATH_ARG=$(PATH_ARG) GROUP=$(GROUP) EXCLUDE_GROUP=$(EXCLUDE_GROUP) ./bin/run-tests --stop-on-failure --no-coverage $(ARGS)
testdox: ## Run tests with testdox (same SUITE/PATH_ARG/GROUP/EXCLUDE_GROUP/ARGS as test)
@SUITE=$(SUITE) PATH_ARG=$(PATH_ARG) GROUP=$(GROUP) EXCLUDE_GROUP=$(EXCLUDE_GROUP) ./bin/run-tests --testdox --no-coverage $(ARGS)
coverage: ## Run tests with coverage (same SUITE/PATH_ARG/GROUP/EXCLUDE_GROUP/ARGS as test)
@XDEBUG_MODE=coverage SUITE=$(SUITE) PATH_ARG=$(PATH_ARG) GROUP=$(GROUP) EXCLUDE_GROUP=$(EXCLUDE_GROUP) ./bin/run-tests $(ARGS)
## —— Cleanup 🚮 ————————————————————————————————————————————————————————————————
purge-runtime: ## Remove compiled assets, uploads, imports, cache, and logs
@rm -rf public/assets/*
@find public/uploads/media -mindepth 1 ! -name '.gitkeep' ! -name '.htaccess' -delete 2>/dev/null || true
@rm -rf var/imports/*
@mkdir -p var/imports var/imports/rejects
@rm -rf var/cache/* var/logs/*
purge: purge-runtime ## Clear runtime files and empty DB (no fixtures)
@$(SYMFONY) composer setup-database
@$(MAKE) warmup
reset: purge-runtime ## Like purge plus demo fixtures
@$(SYMFONY) composer setup-database
@$(MAKE) warmup
@$(MAKE) load-fixtures
clear: ## Cleanup everything
@rm -rf vendor/*
@rm -rf public/assets/*
@rm -rf var/cache/* var/logs/*