-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
226 lines (163 loc) · 7.07 KB
/
Makefile
File metadata and controls
226 lines (163 loc) · 7.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
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
DOCKER=docker
DOCKER_COMPOSE=$(DOCKER) compose
DOCKER_COMPOSE_ALL=$(DOCKER) compose --profile="*"
DOCKER_PHP_CONTAINER=php
DOCKER_BUILD=$(DOCKER_COMPOSE) --file compose.build.yaml
EXEC_PHP=$(DOCKER_COMPOSE) exec --user=www-data $(DOCKER_PHP_CONTAINER)
RUN_PHP=$(DOCKER_COMPOSE) run --rm $(DOCKER_PHP_CONTAINER)
RUN_PHP_ALONE=$(DOCKER_COMPOSE) run --no-deps --rm $(DOCKER_PHP_CONTAINER)
COMPOSER=$(EXEC_PHP) composer
CONSOLE=$(EXEC_PHP) bin/console
test-%: RUN_PHP=$(DOCKER_COMPOSE) run --rm --env APP_ENV=test --env XDEBUG_MODE=off $(DOCKER_PHP_CONTAINER)
test-%: CONSOLE=$(RUN_PHP) bin/console
test-%: COMPOSER=$(RUN_PHP) composer
##
###--------------#
### Docker #
###--------------#
##
up: ## Create and start containers
$(DOCKER_COMPOSE) up -d
@echo "\n##################"
@echo "#### Services ####"
@echo "##################\n"
@echo "- Traefik : http://traefik.esv.localhost"
@echo "- Api : http://api.esv.localhost"
@echo "- Maildev : http://mail.esv.localhost"
up-all: ## Create and start containers from all profiles
$(DOCKER_COMPOSE_ALL) up -d
@echo "\n##################"
@echo "#### Services ####"
@echo "##################\n"
@echo "- Traefik : http://traefik.esv.localhost"
@echo "- Api : http://api.esv.localhost"
@echo "- Maildev : http://mail.esv.localhost"
@echo "- Adminer : http://adminer.esv.localhost"
stop: ## Stop all containers
$(DOCKER_COMPOSE_ALL) stop
pull: ## Pull service images
$(DOCKER_COMPOSE_ALL) pull
down: ## Stops containers and removes containers, networks, volumes, and images created by `up`.
$(DOCKER_COMPOSE_ALL) down --volumes
sh: ## Connect to php container
$(EXEC_PHP) sh
build: ## Build all images
$(DOCKER_BUILD) build
bash: sh ## Alias for sh
start: up ## Alias for up
start-all: up-all ## Alias for up-all
install: pull compose.override.yaml up vendor db-schema-force generate-keypair db-fixtures ## Install the project
test-install: pull vendor generate-keypair db-create db-schema-force db-fixtures ## Install the project for test environment.
.PHONY: up stop down pull sh build bash start start-all install test-install
##
###----------------#
### Doctrine #
###----------------#
##
db-create: ## Creates the configured database.
$(CONSOLE) doctrine:database:create --if-not-exists
db-drop: ## Drops the configured database
$(CONSOLE) doctrine:database:drop --force --if-exists
db-migrate: ## Execute a migration to the latest available version.
$(CONSOLE) doctrine:migrations:migrate --allow-no-migration --no-interaction --all-or-nothing
db-validate: ## Validate the doctrine ORM mapping
$(CONSOLE) doctrine:schema:validate
db-schema: ## Dumps the SQL needed to update the database schema to match the current mapping metadata.
$(CONSOLE) doctrine:schema:update --dump-sql
db-schema-force: ## Executes the SQL needed to update the database schema to match the current mapping metadata.
$(CONSOLE) doctrine:schema:update --force
test-db-schema-force: db-schema-force ## Executes the SQL needed to update the database schema to match the current mapping metadata for test environment.
db-diff: ## Creates a new migration based on database changes
$(CONSOLE) make:migration
db-update: db-diff db-migrate ## Execute db-diff & db-migrate
db-fixtures: ## Load data fixtures to your database
$(CONSOLE) doctrine:fixtures:load --no-interaction
db-fixtures-%: ## Load data fixtures to your database with a custom size
$(DOCKER_COMPOSE) exec --user=www-data --env FIXTURES_SIZE=$* $(DOCKER_PHP_CONTAINER) php bin/console doctrine:fixtures:load --no-interaction --no-debug
test-db-fixtures: db-fixtures ## Load data fixtures to your database for test environment
fixtures: db-fixtures ## Alias for db-fixtures
LAST_MIGRATION := $(shell ls -t migrations/ | head -n 1 | sed 's/\.php$$//' | sed 's/^/DoctrineMigrations\\\\/')
db-execute-up: ## Execute the latest migration versions up manually.
$(CONSOLE) doctrine:migrations:execute --up --no-interaction "${LAST_MIGRATION}"
db-execute-down: ## Execute the latest migration versions down manually.
$(CONSOLE) doctrine:migrations:execute --down --no-interaction "${LAST_MIGRATION}"
.PHONY: db-create db-drop db-migrate db-validate db-schema db-schema-force test-db-schema-force db-diff db-update
.PHONY: db-fixtures test-db-fixtures fixtures db-execute-up db-execute-down
##
###-------------#
### Tests #
###-------------#
##
test-smoke: ## Run smoke tests
$(RUN_PHP) bin/phpunit --no-extensions --testsuite smoke
test-debug: cc ## Run tests with debug group/tags
$(RUN_PHP) bin/phpunit --group debug
test-functional: ## Run functional tests
$(RUN_PHP) bin/phpunit --testsuite functional
tests: test-smoke test-functional ## Execute all tests
ts: test-smoke ## Alias for test-smoke
tf: test-functional ## Alias for test-functional
.PHONY: test-smoke test-debug tests test-functional ts tf
##
###-----------------#
### Q&A tools #
###-----------------#
##
lint-config: ## Lint yaml for config directory
$(CONSOLE) lint:yaml config
lint-container: ## Ensures that arguments injected into services match type declarations
$(CONSOLE) lint:container
lint: lint-config lint-container ## Lint twig and yaml files
PHP_CS_FIXER=docker run --user $$(id -u):$$(id -g) --rm -v "./:/code" -w /code ghcr.io/php-cs-fixer/php-cs-fixer:3-php8.3
cs: ## Check php code style
$(PHP_CS_FIXER) fix --diff --dry-run
fix-cs: ## Fix php code style
$(PHP_CS_FIXER) fix
phpstan: ## Analyze php code
$(RUN_PHP_ALONE) ./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=1G
stan: phpstan ## Alias for phpstan
qa: cs phpstan composer-validate ## Run all Q&A tools
.PHONY: cs fix-cs phpstan qa stan
##
###----------------#
### Composer #
###----------------#
##
composer-validate: ## Validates a composer.json and composer.lock.
$(COMPOSER) validate
composer-update: ## Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file
$(COMPOSER) update $(package)
composer-require: ## Adds required packages to your composer.json and installs them (Ex: package=orm composer-require)
$(COMPOSER) require $(package)
.PHONY: composer-validate composer-update composer-require
##
###----------------------------#
### Rules based on files #
###----------------------------#
##
vendor: composer.lock ## Install dependencies
$(COMPOSER) install
compose.override.yaml: compose.override.yaml.dist ## Create compose.override.yaml
cp compose.override.yaml.dist compose.override.yaml
##
###-------------#
### Utils #
###-------------#
##
cc: ## Clear cache
$(CONSOLE) cache:clear
cc-rm: ## Clear cache by rm -rf
rm -rf var/cache
config/jwt/public.pem: ## Generate public/private keys for jwt.
$(CONSOLE) lexik:jwt:generate-keypair
generate-keypair: config/jwt/public.pem ## Generate public/private keys for jwt.
.PHONY: cc cc-rm generate-keypair
##
###---------------------#
### Help & Others #
###---------------------#
##
.DEFAULT_GOAL := help
help: ## Display help messages from parent Makefile
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-20s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
.PHONY: help