-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
246 lines (183 loc) · 10.2 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
.DEFAULT_GOAL := help
.PHONY: help
DOCKER_COMP = docker compose
DOCKER_COMP_FILE_TOOLS = docker-compose.tools.yml
DATABASE_USER = histologe
DATABASE_NAME = histologe_db
PATH_DUMP_SQL = data/dump.sql
PHPUNIT = ./vendor/bin/phpunit
SYMFONY = php bin/console
NPX = npx
NPM = npm
help:
@grep -E '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
## Service management
build: ## Install local environement
@bash -l -c 'make .check .env .destroy .setup run .sleep composer create-db npm-install npm-build mock-stop mock-start'
run: ## Start containers
@echo -e '\e[1;32mStart containers\032'
@bash -l -c '$(DOCKER_COMP) up -d'
@echo -e '\e[1;32mContainers running\032'
down: ## Shutdown containers
@echo -e '\e[1;32mStop containers\032'
@bash -l -c '$(DOCKER_COMP) down'
@echo -e '\e[1;32mContainers stopped\032'
sh: ## Log to phpfpm container
@echo -e '\e[1;32mLog to phpfpm container\032'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_phpfpm sh'
worker: ## Log to php-worker container
@echo -e '\e[1;32mLog to phpworker container\032'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_phpworker sh'
mysql: ## Log to mysql container
@echo -e '\e[1;32mLog to mysql container\032[0m'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_mysql mysql -u histologe -phistologe histologe_db'
redis: ## Log to redis container
@echo -e '\e[1;32mLog to redis container\032[0m'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_redis sh'
redis-cli: ## Log to redis-cli
@echo -e '\e[1;32mLog to redis-cli\032[0m'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_redis redis-cli'
redis-stat: ## Collect stat redis
@echo -e '\e[1;32mCollect stat-redis\032[0m'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_redis redis-cli --stat'
worker-status:## Get status worker
@echo -e '\e[1;32mGet status worker\032'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_phpworker supervisorctl status all'
worker-start: ## Start worker
@echo -e '\e[1;32mStart worker\032'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_phpworker supervisorctl start all'
worker-stop: ## Stop worker
@echo -e '\e[1;32mStop worker\032'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_phpworker supervisorctl stop all'
worker-exec-failed: ## Consume failed queue
@echo -e '\e[1;32mConsume failed queue\032'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_phpworker php bin/console messenger:consume failed -vvv'
worker-consume: ## Consume local queue for debug
@echo -e '\e[1;32mConsume queue\032'
@bash -l -c '$(DOCKER_COMP) exec -it histologe_phpworker php bin/console messenger:consume async_priority_high async -vvv'
mock-start: ## Start Mock server
@${DOCKER_COMP} start histologe_wiremock && sleep 5
@${DOCKER_COMP} exec -it histologe_phpfpm sh -c "cd tools/wiremock/src/Mock && php AppMock.php"
mock-stop: ## Stop Mock server
@${DOCKER_COMP} stop histologe_wiremock
logs: ## Show container logs
@$(DOCKER_COMP) logs --follow
.env:
@bash -l -c 'cp .env.sample .env'
.check:
@echo "\033[31mWARNING!!!\033[0m Executing this script will reinitialize the project and all of its data"
@( read -p "Are you sure you wish to continue? [y/N]: " sure && case "$$sure" in [yY]) true;; *) false;; esac )
.destroy:
@echo "\033[33mRemoving containers ...\033[0m"
@$(DOCKER_COMP) rm -v --force --stop || true
@echo "\033[32mContainers removed!\033[0m"
.setup:
@echo "\033[33mBuilding containers ...\033[0m"
@$(DOCKER_COMP) build
@echo "\033[32mContainers built!\033[0m"
## Database
create-db: ## Create database
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:database:drop --force --no-interaction || true"
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:database:create --no-interaction"
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev messenger:setup-transports --no-interaction"
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:migrations:migrate --no-interaction"
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:fixtures:load --no-interaction"
create-db-test: ## Create test database
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=test doctrine:database:drop --force --no-interaction || true"
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=test doctrine:database:create --no-interaction"
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=test doctrine:migrations:migrate --no-interaction"
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=test doctrine:fixtures:load --no-interaction"
drop-db: ## Drop database
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:database:drop --force --no-interaction"
load-data: ## Load database from dump
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:database:drop --force --no-interaction || true"
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:database:create --no-interaction"
@$(DOCKER_COMP) exec -T histologe_mysql mysql -u $(DATABASE_USER) -phistologe $(DATABASE_NAME) < $(PATH_DUMP_SQL)
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:migrations:migrate --no-interaction"
migration: ## Generate migration
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev make:migration --no-interaction"
generate-migration: ## Generate empty migration
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:migrations:generate"
load-migrations: ## Play migrations
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:migrations:migrate --no-interaction"
execute-migration: ## Execute migration: make execute-migration name=Version20231027135554 direction=up
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:migrations:execute DoctrineMigrations\\\$(name) --$(direction) --no-interaction"
load-fixtures: ## Load database from fixtures
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(SYMFONY) --env=dev doctrine:fixtures:load --no-interaction"
## Executable
composer: ## Install composer dependencies
@$(DOCKER_COMP) exec -it histologe_phpfpm composer install --no-interaction --optimize-autoloader
@echo "\033[33mInstall tools dependencies ...\033[0m"
@$(DOCKER_COMP) exec -it histologe_phpfpm composer install --working-dir=tools/php-cs-fixer --no-interaction --optimize-autoloader
@$(DOCKER_COMP) exec -it histologe_phpfpm composer install --working-dir=tools/wiremock --no-interaction --optimize-autoloader
require: ## Symfony require
@$(DOCKER_COMP) exec -it histologe_phpfpm composer require
npm-install: ## Install the dependencies in the local node_modules folder
@$(DOCKER_COMP) exec -it histologe_phpfpm $(NPM) install
npm-build: ## Build the dependencies in the local node_modules folder
@$(DOCKER_COMP) exec -it histologe_phpfpm $(NPM) run build
npm-watch: ## Watch files for changes
@$(DOCKER_COMP) exec -it histologe_phpfpm $(NPM) run watch
clear-cache: ## Clear cache prod: make-clear-cache env=[dev|prod|test]
@$(DOCKER_COMP) exec -it histologe_phpfpm $(SYMFONY) c:c --env=$(env)
npm-newman-install: ## Install newman CLI
@bash -l -c 'cd tools/newman && npm install'
cc: clear-cache
clear-pool: ## Clear cache pool: make clear-pool pool=[pool_name]
@$(DOCKER_COMP) exec -it histologe_phpfpm $(SYMFONY) cache:pool:clear $(pool)
console: ## Execute application command
@echo $(SYMFONY) app:$(app)
@$(DOCKER_COMP) exec -it histologe_phpfpm $(SYMFONY) app:$(app)
symfony: ## Execute symfony command: make symfony cmd="make:entity Signalement"
@echo $(SYMFONY) $(cmd)
@$(DOCKER_COMP) exec -it histologe_phpfpm $(SYMFONY) $(cmd)
upload: ## Push objects to S3 Bucket
./scripts/upload-s3.sh $(action) $(zip) $(debug)
sync-sish: ## Synchronize sish status and intervention
@$(DOCKER_COMP) exec histologe_phpfpm sh ./scripts/sync-esabora-sish.sh
## Quality
test: ## Run all tests
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "$(PHPUNIT) $(FILE) --stop-on-failure --testdox -d memory_limit=-1"
test-coverage: ## Generate phpunit coverage report in html
@$(DOCKER_COMP) exec histologe_phpfpm sh -c "XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html coverage -d memory_limit=-1"
e2e: ## Run E2E tests
@$(NPX) cypress open
stan: ## Run PHPStan
@$(DOCKER_COMP) exec -it histologe_phpfpm composer stan
cs-check: ## Check source code with PHP-CS-Fixer
@$(DOCKER_COMP) exec -it histologe_phpfpm composer cs-check
cs-fix: ## Fix source code with PHP-CS-Fixer
@$(DOCKER_COMP) exec -it histologe_phpfpm composer cs-fix
es-vue-fix: ## Fix vue source code with es-lint --fix
@$(DOCKER_COMP) exec -it histologe_phpfpm npm run es-vue-fix
es-js-fix: ## Fix vanilla js source code with es-lint --fix
@$(DOCKER_COMP) exec -it histologe_phpfpm npm run es-js-fix
## Tools
tools-build: ## [Tools] Install tools (Matomo, ...) local environement
@bash -l -c 'make .check .tools-destroy .tools-setup tools-run'
tools-run: ## [Tools] Start tools containers
@echo -e '\e[1;32mStart tools containers\032'
@bash -l -c '$(DOCKER_COMP) -f $(DOCKER_COMP_FILE_TOOLS) up -d'
@echo -e '\e[1;32mContainers tools running\032'
tools-down: ## [Tools] Shutdown tools containers
@echo -e '\e[1;32mStop tools containers\032'
@bash -l -c '$(DOCKER_COMP) -f $(DOCKER_COMP_FILE_TOOLS) down'
@echo -e '\e[1;32mContainers tools stopped\032'
tools-logs: ## [Tools] Show container-tools logs
@$(DOCKER_COMP) -f $(DOCKER_COMP_FILE_TOOLS) logs --follow
matomo-disable-ssl: ## Disable ssl use for matomo local instance
@docker exec -it histologe-matomo_app-1 sh /var/www/html/update-config-ini.sh
scalingo-update-cli: ## Install/Update Scalingo CLI
@bash -l -c 'curl -O https://cli-dl.scalingo.com/install && bash install && scalingo --version'
run-concurrency-request: ## Run concurrency request based postman collection
@bash -l -c 'node ./tools/newman/run_concurrency_request.js nb=$(nb)'
.tools-destroy:
@echo "\033[33mRemoving tools containers ...\033[0m"
@$(DOCKER_COMP) -f $(DOCKER_COMP_FILE_TOOLS) rm -v --force --stop || true
@echo "\033[32mContainers removed!\033[0m"
.tools-setup:
@echo "\033[33mBuilding tools containers ...\033[0m"
@$(DOCKER_COMP) -f $(DOCKER_COMP_FILE_TOOLS) build
@echo "\033[32mContainers built!\033[0m"
.sleep:
@sleep 30