-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
169 lines (126 loc) · 3.5 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
# Allow referring to environment variables defined in .env.
# See: https://lithic.tech/blog/2020-05/makefile-dot-env
ifneq (,$(wildcard ./.env))
include .env
export
endif
.PHONY: assets
# Allow non-Docker overrides for CI.
_DOCKER_EXEC_PHP = docker-compose exec php
_SYMFONY = ${_DOCKER_EXEC_PHP} symfony
BIN_PHP = ${_DOCKER_EXEC_PHP} php
BIN_CONSOLE = ${_SYMFONY} console
BIN_COMPOSER = ${_SYMFONY} composer
NPM = ${_DOCKER_EXEC_PHP} npm
##
## ----------------
## General
## ----------------
##
all: help
help: ## Display this message
@grep -E '(^[a-zA-Z0-9_\-\.]+:.*?##.*$$)|(^##)' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m## /[33m/'
install: build start install_deps dbinstall assets ## Bootstrap project
install_deps: ## Install dependencies
make composer CMD="install -n --prefer-dist"
$(NPM) install
update_deps:
make composer CMD="update"
$(NPM) update
start: ## Start container
docker-compose up -d
docker-compose start
stop: ## Stop containers
docker-compose stop
ps: ## Display containers
docker-compose ps
restart: stop start ## Restart containers
build: ## Build containers
docker-compose build
rm: ## Remove containers
make stop
docker-compose rm
##
## ----------------
## Database
## ----------------
##
dbinstall: ## Setup databases
make dbmigrate
make console CMD="doctrine:database:create --env=test --if-not-exists"
make dbmigrate ARGS="--env=test"
make dbfixtures
make suggestions
dbmigration: ## Generate new db migration
${BIN_CONSOLE} doctrine:migrations:diff
dbmigrate: ## Run db migration
${BIN_CONSOLE} doctrine:migrations:migrate -n --all-or-nothing ${ARGS}
dbshell: ## Connect to the database
docker-compose exec database psql ${DATABASE_URL}
dbfixtures: ## Load tests fixtures
make console CMD="doctrine:fixtures:load --env=test -n --purge-with-truncate"
suggestions: ## Import shopping suggestions to Meilisearch
make console CMD="app:meilisearch:suggestions"
##
## ----------------
## Executable
## ----------------
##
composer: ## Run composer commands
${BIN_COMPOSER} ${CMD}
console: ## Run console command
${BIN_CONSOLE} ${CMD}
cc: ## Run clear cache command
${BIN_CONSOLE} cache:clear
watch: ## Watch assets
$(NPM) run watch
assets: ## Build assets
$(NPM) run build
shell: ## Connect to the container
docker-compose exec php bash
##
## ----------------
## Quality
## ----------------
##
# Individual tools
phpstan: ## PHP Stan
${BIN_PHP} ./vendor/bin/phpstan analyse -l 5 --xdebug src
php_lint: ## PHP linter
${BIN_PHP} ./vendor/bin/php-cs-fixer fix -n ${ARGS}
twig_lint: ## Twig linter
${BIN_CONSOLE} lint:twig -n
psr_lint: ## Check PSR autoloading
${BIN_COMPOSER} dump-autoload --strict-psr
# All-in-one commands
check: ## Run checks
make php_lint ARGS="--dry-run"
make psr_lint
make twig_lint
make phpstan
${BIN_CONSOLE} doctrine:schema:validate
format: php_lint ## Format code
##
## ----------------
## Tests
## ----------------
##
test: ## Run the test suite
${BIN_PHP} ${OPTIONS} ./bin/phpunit ${ARGS}
test_cov: ## Run the test suite (with code coverage)
make test OPTIONS="-d xdebug.mode=coverage" ARGS="--coverage-text --coverage-clover coverage.xml"
test_unit: ## Run unit tests only
${BIN_PHP} ./bin/phpunit --testsuite=Unit ${ARGS}
test_integration: ## Run integration tests only
${BIN_PHP} ./bin/phpunit --testsuite=Integration ${ARGS}
##
## ----------------
## CI
## ----------------
##
ci: ## Run CI steps
make install_deps
make assets
make dbinstall
make check
make test_cov