-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
180 lines (158 loc) · 4.54 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
## see:
## https://www.gnu.org/software/make/manual/html_node/index.html
## https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
## https://docs.php.earth/interop/make/
# variables
.DEFAULT_GOAL := help
.PHONY : help start stop install update require bash logs test
CONTAINERS = template-php
CONTAINER_NAME = template-php
CONTAINER_OPTIONS = -it
RUN = docker exec $(CONTAINER_OPTIONS) $(CONTAINER_NAME)
#PHPUNIT_FILE = phpunit.xml.dist
PHPMD_FILE = phpmd.xml
PHPSTAN_FILE = phpstan.neon
CHURN_FILE = churn.yml
COLOR_RESET = \033[0m
COLOR_INFO = \033[32m
COLOR_COMMENT = \033[33m
## Help
help:
@printf "${COLOR_COMMENT}Usage:${COLOR_RESET}\n"
@printf " make [target]\n\n"
@printf "${COLOR_COMMENT}Available targets:${COLOR_RESET}\n"
@awk '/^[a-zA-Z\-\_0-9\.@]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${COLOR_INFO}%-16s${COLOR_RESET} %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## Start docker containers
start:
@echo "Starting docker containers"
@echo "---------------------------"
@echo
docker-compose -f docker/docker-compose.yml up -d --build --remove-orphans
@echo
## Stop docker containers
stop:
@echo "Stopping docker containers"
@echo "---------------------------"
@echo
docker stop $(CONTAINERS)
@echo
## Install PHP dependencies
install: start composer.json $(wildcard composer.lock)
@echo "Installing PHP dependencies"
@echo "---------------------------"
@echo
$(RUN) composer install
@echo
## Update PHP dependencies
update: start composer.json $(wildcard composer.lock)
@echo "Updating PHP dependencies"
@echo "---------------------------"
@echo
$(RUN) composer update
@echo
## Require new PHP dependencies. Example: make require PACKAGE=phpstan/phpstan ENV=--dev
require: start composer.json
@echo "Require new PHP dependencies:"
@echo "---------------------------"
@echo
$(RUN) composer require $(ENV) $(PACKAGE)
@echo
## Access docker container bash
bash: start
@echo "Access docker container bash"
@echo "---------------------------"
@echo
$(RUN) bash
## Show docker container logs
logs: start
@echo "Show docker container logs"
@echo "---------------------------"
@echo
docker logs -f -n20 $(CONTAINER_NAME)
## Run all tests (PHP Unit, Behat, PHP_CodeSniffer, PHPStan, PHP Mess Detector, Deptrac, ...)
test: start vendor test-phpunit test-behat test-phpcs test-phpstan test-phpmd test-phpmnd test-phpcpd test-churn test-phpdd test-deptrac
## Run PHP Unit Tests
test-phpunit: start bin/phpunit
@echo "Run PHP Unit Tests"
@echo "---------------------------"
@echo
$(RUN) bin/phpunit
@echo
## Run Behat Tests
test-behat: start bin/behat
@echo "Run Behat Tests"
@echo "---------------------------"
@echo
$(RUN) bin/behat
@echo
## Run PHP_CodeSniffer and detect violations of a defined coding standard
test-phpcs: start bin/phpcs
@echo "Run PHP_CodeSniffer: phpcs"
@echo "---------------------------"
@echo
$(RUN) bin/phpcs src/ tests/
@echo
## Run PHP_CodeSniffer and automatically correct coding standard violations
test-phpcbf: start bin/phpcbf
@echo "Run PHP_CodeSniffer: phpcbf"
@echo "---------------------------"
@echo
$(RUN) bin/phpcbf src/ tests/
@echo
## Run PHPStan
test-phpstan: start bin/phpstan
@echo "Run PHPStan"
@echo "---------------------------"
@echo
$(RUN) bin/phpstan analyse -c $(PHPSTAN_FILE)
@echo
## Run PHP Mess Detector
test-phpmd: start bin/phpmd
@echo "Run PHP Mess Detector"
@echo "---------------------------"
@echo
$(RUN) bin/phpmd src/ text $(PHPMD_FILE)
@echo
## Run PHP Magic Number Detector
test-phpmnd: start bin/phpmnd
@echo "Run PHP Magic Number Detector"
@echo "---------------------------"
@echo
$(RUN) bin/phpmnd src tests --progress --extensions=all
@echo
## Run PHP Copy Paste Detector
test-phpcpd: start bin/phpcpd
@echo "Run PHP Copy Paste Detector"
@echo "---------------------------"
@echo
$(RUN) bin/phpcpd ./ --exclude=var --exclude=vendor --fuzzy --min-lines=5
@echo
## Run Churn-php
test-churn: start bin/churn
@echo "Run Churn-php"
@echo "---------------------------"
@echo
$(RUN) bin/churn run --configuration=$(CHURN_FILE)
@echo
## Run PhpDeprecationDetector
test-phpdd: start bin/phpdd
@echo "Run PhpDeprecationDetector"
@echo "---------------------------"
@echo
$(RUN) bin/phpdd src/ tests/
@echo
## Run Deptrac
test-deptrac: start bin/deptrac
@echo "Run Deptrac"
@echo "---------------------------"
@echo
$(RUN) bin/deptrac analyse
@echo