forked from systemsdk/docker-nginx-php-symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
208 lines (155 loc) · 6.26 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
dir=${CURDIR}
ifndef APP_ENV
include .env
# Determine if .env.local file exist
ifneq ("$(wildcard .env.local)","")
include .env.local
endif
endif
symfony_user=-u www-data
project=-p ${COMPOSE_PROJECT_NAME}
service=${COMPOSE_PROJECT_NAME}:latest
openssl_bin:=$(shell which openssl)
interactive:=$(shell [ -t 0 ] && echo 1)
ifneq ($(interactive),1)
optionT=-T
endif
ifeq ($(GITLAB_CI),1)
# Determine additional params for phpunit in order to generate coverage badge on GitLabCI side
phpunitOptions=--coverage-text --colors=never
endif
build:
@docker-compose -f docker-compose.yml build
build-test:
@docker-compose -f docker-compose-test-ci.yml build
build-staging:
@docker-compose -f docker-compose-staging.yml build
build-prod:
@docker-compose -f docker-compose-prod.yml build
start:
@docker-compose -f docker-compose.yml $(project) up -d
start-test:
@docker-compose -f docker-compose-test-ci.yml $(project) up -d
start-staging:
@docker-compose -f docker-compose-staging.yml $(project) up -d
start-prod:
@docker-compose -f docker-compose-prod.yml $(project) up -d
stop:
@docker-compose -f docker-compose.yml $(project) down
stop-test:
@docker-compose -f docker-compose-test-ci.yml $(project) down
stop-staging:
@docker-compose -f docker-compose-staging.yml $(project) down
stop-prod:
@docker-compose -f docker-compose-prod.yml $(project) down
restart: stop start
restart-test: stop-test start-test
restart-staging: stop-staging start-staging
restart-prod: stop-prod start-prod
env-prod:
@make exec cmd="composer dump-env prod"
env-staging:
@make exec cmd="composer dump-env staging"
ssh:
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony bash
ssh-nginx:
@docker-compose $(project) exec nginx /bin/sh
ssh-supervisord:
@docker-compose $(project) exec supervisord bash
ssh-mysql:
@docker-compose $(project) exec mysql bash
ssh-rabbitmq:
@docker-compose $(project) exec rabbitmq /bin/sh
exec:
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony $$cmd
exec-bash:
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony bash -c "$(cmd)"
exec-by-root:
@docker-compose $(project) exec $(optionT) symfony $$cmd
report-prepare:
mkdir -p $(dir)/reports/coverage
report-clean:
rm -rf $(dir)/reports/*
wait-for-db:
@make exec cmd="php bin/console db:wait"
composer-install-no-dev:
@make exec-bash cmd="COMPOSER_MEMORY_LIMIT=-1 composer install --optimize-autoloader --no-dev"
composer-install:
@make exec-bash cmd="COMPOSER_MEMORY_LIMIT=-1 composer install --optimize-autoloader"
composer-update:
@make exec-bash cmd="COMPOSER_MEMORY_LIMIT=-1 composer update"
info:
@make exec cmd="php --version"
@make exec cmd="bin/console about"
logs:
@docker logs -f ${COMPOSE_PROJECT_NAME}_symfony
logs-nginx:
@docker logs -f ${COMPOSE_PROJECT_NAME}_nginx
logs-supervisord:
@docker logs -f ${COMPOSE_PROJECT_NAME}_supervisord
logs-mysql:
@docker logs -f ${COMPOSE_PROJECT_NAME}_mysql
logs-rabbitmq:
@docker logs -f ${COMPOSE_PROJECT_NAME}_rabbitmq
drop-migrate:
@make exec cmd="php bin/console doctrine:schema:drop --full-database --force"
@make exec cmd="php bin/console doctrine:schema:drop --full-database --force --env=test"
@make migrate
migrate-no-test:
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction --all-or-nothing"
migrate:
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction --all-or-nothing"
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction --all-or-nothing --env=test"
fixtures:
@make exec cmd="php bin/console doctrine:fixtures:load --env=test"
messenger-setup-transports:
@make exec cmd="php bin/console messenger:setup-transports"
phpunit:
@make exec-bash cmd="rm -rf ./var/cache/test* && bin/console cache:warmup --env=test && ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-html reports/coverage $(phpunitOptions) --coverage-clover reports/clover.xml --log-junit reports/junit.xml"
###> php-coveralls ###
report-code-coverage: ## update code coverage on coveralls.io. Note: COVERALLS_REPO_TOKEN should be set on CI side.
@make exec-bash cmd="export COVERALLS_REPO_TOKEN=${COVERALLS_REPO_TOKEN} && php ./vendor/bin/php-coveralls -v --coverage_clover reports/clover.xml --json_path reports/coverals.json"
###< php-coveralls ###
###> phpcs ###
phpcs: ## Run PHP CodeSniffer
@make exec-bash cmd="./vendor/bin/phpcs --version && ./vendor/bin/phpcs --standard=PSR12 --colors -p src tests"
###< phpcs ###
###> ecs ###
ecs: ## Run Easy Coding Standard
@make exec-bash cmd="./vendor/bin/ecs --version && ./vendor/bin/ecs --clear-cache check src tests"
ecs-fix: ## Run The Easy Coding Standard to fix issues
@make exec-bash cmd="./vendor/bin/ecs --version && ./vendor/bin/ecs --clear-cache --fix check src tests"
###< ecs ###
###> phpmetrics ###
phpmetrics:
@make exec-by-root cmd="make phpmetrics-process"
phpmetrics-process: ## Generates PhpMetrics static analysis, should be run inside symfony container
@mkdir -p reports/phpmetrics
@if [ ! -f reports/junit.xml ] ; then \
printf "\033[32;49mjunit.xml not found, running tests...\033[39m\n" ; \
./vendor/bin/phpunit -c phpunit.xml.dist --coverage-html reports/coverage --coverage-clover reports/clover.xml --log-junit reports/junit.xml ; \
fi;
@echo "\033[32mRunning PhpMetrics\033[39m"
@php ./vendor/bin/phpmetrics --version
@php ./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
###< phpmetrics ###
###> php copy/paste detector ###
phpcpd:
@make exec cmd="php phpcpd.phar --fuzzy src tests"
###< php copy/paste detector ###
###> php mess detector ###
phpmd:
@make exec cmd="php ./vendor/bin/phpmd src text phpmd_ruleset.xml --suffixes php"
###< php mess detector ###
###> PHPStan static analysis tool ###
phpstan:
@echo "\033[32mRunning PHPStan - PHP Static Analysis Tool\033[39m"
@make exec cmd="bin/console cache:clear --env=test"
@make exec cmd="./vendor/bin/phpstan --version"
@make exec cmd="./vendor/bin/phpstan analyze src tests"
###< PHPStan static analysis tool ###
###> Phpinsights PHP quality checks ###
phpinsights:
@echo "\033[32mRunning PHP Insights\033[39m"
@make exec cmd="php -d error_reporting=0 ./vendor/bin/phpinsights analyse --no-interaction --min-quality=100 --min-complexity=85 --min-architecture=100 --min-style=100"
###< Phpinsights PHP quality checks ###