forked from tarlepp/symfony-flex-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
174 lines (149 loc) · 6.27 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
ifndef APP_ENV
include .env
endif
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -E '^[a-zA-Z-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "[32m%-27s[0m %s\n", $$1, $$2}'
###> symfony/framework-bundle ###
CONSOLE := $(shell which bin/console)
sf_console:
ifndef CONSOLE
@printf "Run \033[32mcomposer require cli\033[39m to install the Symfony console.\n"
endif
cache-clear: ## Clears the cache
ifdef CONSOLE
@bin/console cache:clear --no-warmup
else
@rm -rf var/cache/*
endif
.PHONY: cache-clear
cache-warmup: cache-clear ## Warms up an empty cache
ifdef CONSOLE
@bin/console cache:warmup
else
@printf "Cannot warm up the cache (needs symfony/console).\n"
endif
.PHONY: cache-warmup
serve_as_sf: sf_console
ifndef CONSOLE
@${MAKE} serve_as_php
endif
@bin/console list | grep server:start > /dev/null || ${MAKE} serve_as_php
@bin/console server:start
@printf "Quit the server with \033[32;49mbin/console server:stop\033[39m\n"
serve_as_php:
@printf "\033[32;49mServer listening on http://127.0.0.1:8000\033[39m\n"
@printf "Quit the server with CTRL-C.\n"
@printf "Run \033[32mcomposer require symfony/web-server-bundle\033[39m for a better web server.\n"
php -S 127.0.0.1:8000 -t public
serve: ## Runs a local web server
@${MAKE} serve_as_sf
.PHONY: sf_console serve serve_as_sf serve_as_php
###< symfony/framework-bundle ###
###> lexik/jwt-authentication-bundle ###
OPENSSL_BIN := $(shell which openssl)
generate-jwt-keys: ## Generates JWT auth keys
ifndef OPENSSL_BIN
$(error "Unable to generate keys (needs OpenSSL)")
endif
@echo "\033[32mGenerating RSA keys for JWT\033[39m"
@mkdir -p config/jwt
@openssl genrsa -passout pass:${JWT_PASSPHRASE} -out ${SECRET_KEY} -aes256 4096
@openssl rsa -passin pass:${JWT_PASSPHRASE} -pubout -in ${SECRET_KEY} -out ${PUBLIC_KEY}
@chmod 664 ${SECRET_KEY}
@chmod 664 ${PUBLIC_KEY}
@echo "\033[32mRSA key pair successfully generated\033[39m"
###< lexik/jwt-authentication-bundle ###
###> phpunit ###
PHPDBG := $(shell which phpdbg)
run-tests: ## Runs all tests via phpunit (Uses phpdbg if that is installed)
ifndef PHPDBG
@${MAKE} run-tests-php
else
@${MAKE} run-tests-phpdbg
endif
run-tests-fastest: ## Runs all test via fastest (Uses phpdbg if that is installed)
ifndef PHPDBG
@${MAKE} run-tests-fastest-php
else
@${MAKE} run-tests-fastest-phpdbg
endif
run-tests-php: ## Runs all tests via phpunit (pure PHP)
@echo "\033[32mRunning test with PhpUnit in single thread (pure PHP)\033[39m"
@php ./vendor/bin/phpunit --version
@mkdir -p build/logs
@bin/console cache:clear --env=test
@./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --log-junit build/logs/junit.xml
run-tests-phpdbg: ## Runs all tests via phpunit (phpdbg)
@echo "\033[32mRunning test with PhpUnit in single thread (phpdbg)\033[39m"
@php ./vendor/bin/phpunit --version
@mkdir -p build/logs
@bin/console cache:clear --env=test
@phpdbg -qrr ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --log-junit build/logs/junit.xml
run-tests-fastest-php: ## Runs all test via fastest (pure PHP)
@echo "\033[32mRunning tests with liuggio/fastest + PhpUnit in multiple threads (pure PHP)\033[39m"
@mkdir -p build/fastest
@bin/console cache:clear --env=test
@find tests/ -name "*Test.php" | php ./vendor/bin/fastest -v -p 8 -o -b "php ./tests/bootstrap.php" "php ./vendor/bin/phpunit {} -c phpunit.fastest.xml --coverage-php build/fastest/{n}.cov --log-junit build/fastest/{n}.xml";
run-tests-fastest-phpdbg: ## Runs all test via fastest (phpdbg)
@echo "\033[32mRunning tests with liuggio/fastest + PhpUnit in multiple threads (phpdbg)\033[39m"
@mkdir -p build/fastest
@bin/console cache:clear --env=test
@find tests/ -name "*Test.php" | php ./vendor/bin/fastest -v -p 8 -o -b "php ./tests/bootstrap.php" "phpdbg -qrr -d memory_limit=4096M ./vendor/bin/phpunit {} -c phpunit.fastest.xml --coverage-php build/fastest/{n}.cov --log-junit build/fastest/{n}.xml";
merge-clover: ## Creates clover from fastest run
@./vendor/bin/phpcov merge ./build/fastest/ --clover=./build/logs/clover.xml
merge-junit: ## Creates JUnit xml from fastest run
@php merge-phpunit-xml.php ./build/fastest/ ./build/logs/junit.xml
###< phpunit ###
infection: ## Runs Infection to codebase
@echo "\033[32mRunning Infection to codebase (pure PHP)\033[39m"
@mkdir -p build/infection
@bin/console cache:clear --env=test
@./vendor/bin/infection --threads=8 --only-covered --show-mutations --test-framework-options="--testsuite=Functional,Integration,Unit"
###> phpmetrics ###
phpmetrics: ## Generates PhpMetrics static analysis
@mkdir -p build/phpmetrics
@if [ ! -f build/logs/junit.xml ] ; then \
printf "\033[32;49mclover.xml not found running tests...\033[39m\n" ; \
make run-tests or make run-tests-fastests ; \
fi;
@echo "\033[32mRunning PhpMetrics\033[39m"
@php ./vendor/bin/phpmetrics --version
@./vendor/bin/phpmetrics --junit=build/logs/junit.xml --report-html=build/phpmetrics .
###< phpmetrics ###
###> phpcs ###
phpcs: ## Runs PHP CodeSniffer
@echo "\033[32mRunning PhpCodeSniffer\033[39m"
@php ./vendor/bin/phpcs --version
@php ./vendor/bin/phpcs --standard=PSR2 --colors -p src
###< phpcs ###
###> ecs ###
ecs: ## Runs The Easiest Way to Use Any Coding Standard
@echo "\033[32mRunning EasyCodingStandard\033[39m"
@php ./vendor/bin/ecs --version
@php -d error_reporting=0 ./vendor/bin/ecs --clear-cache --no-progress-bar check src
###< ecs ###
###> psalm ###
psalm: ## Runs Psalm static analysis tool
@echo "\033[32mRunning Psalm - A static analysis tool for PHP\033[39m"
@php ./vendor/bin/psalm --version
@php ./vendor/bin/psalm --no-cache
###< psalm ###
###> phpstan ###
phpstan: ## Runs PHPStan static analysis tool
@echo "\033[32mRunning PHPStan - PHP Static Analysis Tool\033[39m"
@./vendor/bin/phpstan --version
@./vendor/bin/phpstan analyze --level 7 src
###< phpstan ###
###> clear vendor-bin ###
clear-vendor-bin: ## Runs PHPStan static analysis tool
@echo "\033[32mClearing vendor-bin dependencies\033[39m"
@find -type d -name vendor | grep vendor-bin | xargs rm -rf
@echo "\033[32mremember to run 'composer update' command after this\033[39m"
###< clear vendor-bin ###
###> check vendor-bin ###
check-vendor-dependencies: ## Checks if any vendor dependency can be updated
@echo "\033[32mChecking dependencies\033[39m"
@bin/console check-vendor-dependencies
###< clear vendor-bin ###