-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
80 lines (60 loc) · 2.47 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
DC=docker-compose
PHP_CONTAINER=php
EXEC_PHP=$(DC) exec $(PHP_CONTAINER) php
.DEFAULT_GOAL := help
.PHONY: help
help : Makefile # Print commands 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/'
##
## Project commands
##----------------------------------------------------------------------------------------------------------------------
.PHONY: install logs shell
logs: ## View containers logs.
$(DC) logs -f $(filter-out $@,$(MAKECMDGOALS))
shell: ## Run bash shell in php container.
$(DC) exec $(PHP_CONTAINER) sh
prune:
$(DC) down -v
install-local: ## Install project
@echo "Down project if exist"
$(MAKE) prune
@echo "Build & Run container"
$(DC) up -d --build
@echo "Install dependencies"
$(MAKE) composer install
@echo "Init database"
$(MAKE) data-fixtures
##
## Symfony commands
##----------------------------------------------------------------------------------------------------------------------
.PHONY: composer console data-fixtures
composer: ## Run composer in php container.
$(DC) exec php composer $(filter-out $@,$(MAKECMDGOALS))
console: ## Run symfony console in php container.
$(EXEC_PHP) php bin/console $(filter-out $@,$(MAKECMDGOALS))
data-fixtures: ## Execute doctrine fixtures.
$(EXEC_PHP) bin/console doctrine:mongodb:fixtures:load -n
##
## Quality tools
##----------------------------------------------------------------------------------------------------------------------
.PHONY: fix check-cs phpstan cpd md unit ci
fix: ## Run php cs fixer
$(DC) exec -e PHP_CS_FIXER_IGNORE_ENV=1 php ./vendor/bin/php-cs-fixer fix -vvv --config=.php-cs-fixer.dist.php --cache-file=.php-cs-fixer.cache
check-cs: ## Run php cs fixer
$(DC) exec -e PHP_CS_FIXER_IGNORE_ENV=1 php ./vendor/bin/php-cs-fixer fix -vvv --config=.php-cs-fixer.dist.php --cache-file=.php-cs-fixer.cache --dry-run
phpstan: ## Run phpstan code static analyze
$(EXEC_PHP) ./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=256M
cpd: ## Run phpcpd to detect duplicated code source
$(DC) exec php phpcpd --fuzzy src
md: ## Run phpmd to detect code smells
$(DC) exec php phpmd src,tests ansi phpmd.xml.dist
unit: ## Run unit tests
$(EXEC_PHP) vendor/bin/phpunit
unit-coverage: ## Run unit tests with code coverage generate
$(EXEC_PHP) vendor/bin/phpunit --coverage-text
ci: ## Run all tests and code quality
$(MAKE) fix
$(MAKE) cpd
$(MAKE) md
$(MAKE) phpstan
$(MAKE) unit