-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathMakefile
210 lines (164 loc) · 6.33 KB
/
Makefile
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
DOCKER_COMPOSE = docker-compose
EXEC = $(DOCKER_COMPOSE) exec
EXEC_PHP = $(DOCKER_COMPOSE) exec php
EXEC_NODE = $(DOCKER_COMPOSE) exec node
SYMFONY = $(EXEC_PHP) bin/console
COMPOSER = $(EXEC_PHP) composer
##
## Project
## -------
##
build:
@$(DOCKER_COMPOSE) pull --parallel --quiet --ignore-pull-failures 2> /dev/null
$(DOCKER_COMPOSE) build --pull
kill:
$(DOCKER_COMPOSE) kill
$(DOCKER_COMPOSE) down --volumes --remove-orphans
install: ## Install and start the project
install: docker-compose.override.yml build start vendor rsa-keys db
reset: ## Stop and start a fresh install of the project
reset: kill install
start: ## Start the project
$(DOCKER_COMPOSE) up -d --remove-orphans --no-recreate
stop: ## Stop the project
$(DOCKER_COMPOSE) stop
clean: ## Stop the project and remove generated files
clean: kill
rm -rf docker-compose.override.yml config/jwt/*.pem vendor
no-docker:
$(eval DOCKER_COMPOSE := \#)
$(eval EXEC_PHP := )
$(eval EXEC_JS := )
.PHONY: build kill install reset start stop clean no-docker
##
## Utils
## -----
##
wait-for-db:
$(EXEC_PHP) php -r "set_time_limit(60);for(;;){if(@fsockopen('mysql',3306)){break;}echo \"Waiting for MySQL\n\";sleep(1);}"
db: ## Reset the database and load fixtures
db: vendor wait-for-db
$(SYMFONY) doctrine:database:drop --if-exists --force
$(SYMFONY) doctrine:database:create --if-not-exists
$(SYMFONY) doctrine:migrations:migrate --no-interaction --allow-no-migration
$(SYMFONY) doctrine:fixtures:load --no-interaction
migration: ## Generate a new doctrine migration
migration: vendor
$(SYMFONY) doctrine:migrations:diff
db-validate-schema: ## Validate the doctrine ORM mapping
db-validate-schema: vendor
$(SYMFONY) doctrine:schema:validate
.PHONY: db migration watch
# rules based on files
#composer.lock: composer.json
# $(COMPOSER) update --lock --no-scripts --no-interaction
vendor: composer.lock
$(COMPOSER) install
docker-compose.override.yml: docker-compose.override.yml.dist
@if [ -f docker-compose.override.yml ]; \
then\
echo '\033[1;41m/!\ The docker-compose.override.yml.dist file has changed. Please check your docker-compose.override.yml file (this message will not be displayed again).\033[0m';\
touch docker-compose.override.yml;\
exit 1;\
else\
echo cp docker-compose.override.yml.dist docker-compose.override.yml;\
cp docker-compose.override.yml.dist docker-compose.override.yml;\
fi
rsa-keys: ## Generate RSA keys needed for JWT encoding / decoding
rsa-keys:
@if [ -f config/jwt/private.pem ]; \
then\
rm config/jwt/private.pem;\
fi
@if [ -f config/jwt/public.pem ]; \
then\
rm config/jwt/public.pem;\
fi
$(EXEC_PHP) openssl genrsa -out config/jwt/private.pem -aes256 -passout pass:passphrase 4096
$(EXEC_PHP) openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem -passin pass:passphrase
##
## Quality assurance
## -----------------
##
ci: ## Run all quality insurance checks (tests, code styles, linting, security, static analysis...)
#ci: php-cs-fixer phpcs phpmd phpmnd phpstan psalm lint validate-composer validate-mapping security test test-coverage
ci: php-cs-fixer phpcs phpmd phpstan rector.dry psalm lint validate-composer validate-mapping security test test-coverage
ci.local: ## Run quality insurance checks from inside the php container
ci.local: no-docker ci
lint: ## Run lint check
lint:
$(SYMFONY) lint:yaml config/ --parse-tags
$(SYMFONY) lint:yaml fixtures/
$(SYMFONY) lint:yaml translations/
$(SYMFONY) lint:container
phpcs: ## Run phpcode_sniffer
phpcs:
$(EXEC_PHP) vendor/bin/phpcs
php-cs-fixer: ## Run PHP-CS-FIXER
php-cs-fixer:
$(EXEC_PHP) vendor/bin/php-cs-fixer fix --verbose
php-cs-fixer.dry-run: ## Run php-cs-fixer in dry-run mode
php-cs-fixer.dry-run:
$(EXEC_PHP) vendor/bin/php-cs-fixer fix --verbose --diff --dry-run
phpmd: ## Run PHPMD
phpmd:
$(EXEC_PHP) vendor/bin/phpmd src/,tests/ text phpmd.xml.dist
#phpmnd: ## Run PHPMND
#phpmnd:
# $(EXEC_PHP) vendor/bin/phpmnd src --extensions=default_parameter
phpstan: ## Run PHPSTAN
phpstan:
$(EXEC_PHP) vendor/bin/phpstan analyse
rector.dry: ## Dry-run rector
rector.dry:
$(EXEC_PHP) vendor/bin/rector process --dry-run
rector: ## Run RECTOR
rector:
$(EXEC_PHP) vendor/bin/rector process
psalm: ## Run PSALM
psalm:
$(EXEC_PHP) vendor/bin/psalm
security: ## Run security-checker
security:
$(EXEC_PHP) symfony security:check --no-interaction
test: ## Run phpunit tests
test:
$(EXEC_PHP) vendor/bin/phpunit
test-coverage: ## Run phpunit tests with code coverage (phpdbg)
test-coverage: test-coverage-pcov
test-coverage-phpdbg: ## Run phpunit tests with code coverage (phpdbg)
test-coverage-phpdbg:
$(EXEC_PHP) phpdbg -qrr ./vendor/bin/phpunit --coverage-html=var/coverage
test-coverage-pcov: ## Run phpunit tests with code coverage (pcov - uncomment extension in dockerfile)
test-coverage-pcov:
$(EXEC_PHP) vendor/bin/phpunit --coverage-html=var/coverage
test-coverage-xdebug: ## Run phpunit tests with code coverage (xdebug - uncomment extension in dockerfile)
test-coverage-xdebug:
$(EXEC_PHP) vendor/bin/phpunit --coverage-html=var/coverage
test-coverage-xdebug-filter: ## Run phpunit tests with code coverage (xdebug with filter - uncomment extension in dockerfile)
test-coverage-xdebug-filter:
$(EXEC_PHP) vendor/bin/phpunit --dump-xdebug-filter var/xdebug-filter.php
$(EXEC_PHP) vendor/bin/phpunit --prepend var/xdebug-filter.php --coverage-html=var/coverage
test-deprecations-log: ## Run phpunit default test suite with deprecations logging to external file
test-deprecations-log:
$(EXEC) php rm -f var/deprecations.log
$(EXEC) --env SYMFONY_DEPRECATIONS_HELPER='logFile=var/deprecations.log' php vendor/bin/phpunit
specs: ## Run postman collection tests
specs:
$(EXEC_NODE) ./spec/api-spec-test-runner.sh
specs.local: ## Run postman collection tests
specs.local:
symfony local:server:start --no-tls -d
APIURL=http://127.0.0.1:8000/api ./spec/api-spec-test-runner.sh
symfony local:server:stop
validate-composer: ## Validate composer.json and composer.lock
validate-composer:
$(EXEC_PHP) composer validate
$(EXEC_PHP) composer normalize --dry-run
validate-mapping: ## Validate doctrine mapping
validate-mapping:
$(SYMFONY) doctrine:schema:validate --skip-sync -vvv --no-interaction
.DEFAULT_GOAL := help
help:
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
.PHONY: help