-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
166 lines (126 loc) · 5.73 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
##----------------------------------------------------------------------------------------------------------------------
##------------------------------------------------------ Makefile ------------------------------------------------------
##----------------------------------------------------------------------------------------------------------------------
DC=docker compose
PHP_CONTAINER=php
NODE_CONTAINER=front
EXEC_PHP=$(DC) exec $(PHP_CONTAINER) php
EXEC_NODE=$(DC) exec $(NODE_CONTAINER)
.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/'
##
## Docker commands
##----------------------------------------------------------------------------------------------------------------------
.PHONY: build down logs shell-php shell-node install-local prune up ps
build:
$(DC) build
down:
$(DC) down
prune:
$(DC) down -v
logs: ## View containers logs.
$(DC) logs -f $(filter-out $@,$(MAKECMDGOALS))
shell-php: ## Run bash shell in php container.
$(DC) exec $(PHP_CONTAINER) sh
shell-node: ## Run bash shell in node container.
$(DC) exec $(NODE_CONTAINER) sh
# todo complete this job including the installation of node server
install-local: ## Install project on dev local project
@echo "Ensure local project does not exist"
$(MAKE) prune
@echo "Build project container"
$(MAKE) build
$(MAKE) up
@echo "Install project"
@echo "Clean all non static directories"
$(DC) exec php rm -rf symfony/vendor/* symfony/var/* symfony/*.cache
sleep 15
$(EXEC_PHP) exec php composer install
$(MAKE) migration
$(EXEC_PHP) bin/console php bin/console app:legal-statuses:import
$(EXEC_PHP) bin/console doctrine:fixtures:load -n
up:
$(DC) up -d --force-recreate
ps:
$(DC) ps -a
##
## Symfony commands
##----------------------------------------------------------------------------------------------------------------------
.PHONY: composer console migration data-fixtures
composer: ## Run composer in php container.
$(EXEC_PHP) composer $(filter-out $@,$(MAKECMDGOALS))
console: ## Run symfony console in php container.
$(EXEC_PHP) php bin/console $(filter-out $@,$(MAKECMDGOALS))
migration: ## Execute doctrine migration.
$(EXEC_PHP) bin/console doctrine:migration:migrate -n
data-fixtures: ## Execute doctrine fixtures.
$(EXEC_PHP) bin/console doctrine:fixtures:load -n
##
## Tests
##----------------------------------------------------------------------------------------------------------------------
.PHONY: php-unit-tests php-unit-tests-coverage node-unit-tests node-unit-tests-coverage
php-unit-tests: ## Run php unit tests.
$(EXEC_PHP) vendor/bin/phpunit
# todo update generated URL
php-unit-tests-coverage: ## Run php unit tests with code coverage generate.
$(EXEC_PHP) vendor/bin/phpunit --coverage-html=public/coverage/html/unit --coverage-php=public/coverage/php/phpunit.cov
@echo "See coverage result here : https://symfony.localhost/coverage/html/unit/index.html"
node-unit-tests: ## Run typescript unit tests.
$(EXEC_NODE) yarn test # todo: replace with test:clover
node-unit-tests-coverage: ## Run typescript unit tests with code coverage generate.
$(EXEC_NODE) yarn test:coverage
@echo "See coverage result here : http://localhost:3000/coverage/lcov-report/index.html"
##
## Code quality
##----------------------------------------------------------------------------------------------------------------------
.PHONY: fix fix-dry-run phpstan lint prettier prettier-check
fix: ## Runs the CS fixer to fix the project coding style.
$(EXEC_PHP) vendor/bin/php-cs-fixer fix -vvv --config=.php-cs-fixer.dist.php --cache-file=.php-cs-fixer.cache $(filter-out $@,$(MAKECMDGOALS))
fix-dry-run: ## Runs the CS fixer to sniff the project coding style (without fix).
$(EXEC_PHP) vendor/bin/php-cs-fixer fix -vvv --config=.php-cs-fixer.dist.php --cache-file=.php-cs-fixer.cache --dry-run
cpd: ## Run phpcpd to detect duplicated code source
$(DC) exec php phpcpd src
md: ## Run phpmd to detect code smells
$(DC) exec php phpmd src,tests ansi phpmd.xml.dist
phpstan: ## Run phpstan analyses.
$(EXEC_PHP) ./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=512M
lint: ## Run the ESLinter to analyse typescript code.
$(EXEC_NODE) yarn lint
prettier: ## Run the prettier to fix typescript code quality.
$(EXEC_NODE) yarn prettier
prettier-check: ## Run the prettier to check typescript code quality.
$(EXEC_NODE) yarn prettier:check
##
## Continuous integration
##----------------------------------------------------------------------------------------------------------------------
.PHONY: ci ci-php ci-node
ci-php: ## Execute tests and code quality for PHP container.
$(MAKE) php-unit-tests
$(MAKE) fix-dry-run
$(MAKE) phpstan
ci-node: ## Execute tests and code quality for node container.
$(MAKE) prettier
$(MAKE) lint
$(MAKE) node-unit-tests
ci: ## Execute all tests and linters in a single command.
$(MAKE) ci-php
$(MAKE) ci-node
##
## Security
##----------------------------------------------------------------------------------------------------------------------
.PHONY: security-php security-node security
security-php: ## Identify vulnerabilities in PHP dependencies.
$(DC) exec $(PHP_CONTAINER) symfony security:check
security-node: ## Identify vulnerabilities in node packages.
$(EXEC_NODE) yarn audit
security: ## Identify vulnerabilities in PHP and node packages.
$(MAKE) security-php
$(MAKE) security-node
##
##* Run SQL
##----------------------------------------------------------------------------------------------------------------------
.PHONY: sql
sql: ## Executes arbitrary SQL with default connection
$(EXEC_PHP) php bin/console dbal:run-sql "$(filter-out $@,$(MAKECMDGOALS))"