-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
Makefile
279 lines (208 loc) · 9.44 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/php-cs-fixer/bin/php-cs-fixer
DOCKER_COMPOSE=docker compose
DOCKER_COMPOSE_EXEC=$(DOCKER_COMPOSE) exec --no-TTY
ifeq ("$(CI)", "true")
MYSQL_BIN=mysql --user=root --password=password --port=3307
MONGO_BIN=mongosh --username=root --password=password --port=27018
else
MYSQL_BIN=$(DOCKER_COMPOSE_EXEC) mysql mysql --user=root --password=password --host=host.docker.internal --port=3307
MONGO_BIN=$(DOCKER_COMPOSE_EXEC) mongo mongosh --username=root --password=password --host=host.docker.internal --port=27017
endif
.DEFAULT_GOAL := help
.PHONY: help
help:
@echo "\033[33mUsage:\033[0m\n make TARGET\n\n\033[32m#\n# Commands\n#---------------------------------------------------------------------------\033[0m\n"
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | awk 'BEGIN {FS = ":"}; {printf "\033[33m%s:\033[0m%s\n", $$1, $$2}'
#
# Commands
#---------------------------------------------------------------------------
.PHONY: clean
clean: ## Removes all created artefacts
clean:
$(MYSQL_BIN) --execute="DROP DATABASE IF EXISTS fidry_alice_data_fixtures;"
$(MAKE) refresh_mongodb_db
git clean --exclude=.idea/ -ffdx
.PHONY: refresh_mysql_db
refresh_mysql_db: ## Refresh the MySQL database used
refresh_mysql_db:
$(MYSQL_BIN) -e "DROP DATABASE IF EXISTS fidry_alice_data_fixtures; CREATE DATABASE fidry_alice_data_fixtures;"
.PHONY: refresh_mongodb_db
refresh_mongodb_db: ## Refresh the MongoDB database used
refresh_mongodb_db:
$(MONGO_BIN) --eval "db.getMongo().getDBNames().filter(dbName => !['admin', 'config', 'local'].includes(dbName)).forEach(dbName => db.getSiblingDB(dbName).dropDatabase())"
.PHONY: refresh_phpcr
refresh_phpcr: ## Refresh the MongoDB PHPCR database used
refresh_phpcr: vendor-bin/doctrine_phpcr/bin/phpcrodm
$(MYSQL_BIN) -e "DROP DATABASE IF EXISTS fidry_alice_data_fixtures; CREATE DATABASE fidry_alice_data_fixtures;"
php vendor-bin/doctrine_phpcr/bin/phpcrodm jackalope:init:dbal --force
php vendor-bin/doctrine_phpcr/bin/phpcrodm doctrine:phpcr:register-system-node-types
.PHONY: remove_sf_cache
remove_sf_cache: ## Removes cache generated by Symfony
remove_sf_cache:
rm -rf fixtures/Bridge/Symfony/cache/*
.PHONY: cs
cs: ## Run the CS Fixer
cs: remove_sf_cache \
vendor/bamarni \
vendor-bin/php-cs-fixer/vendor
$(PHP_CS_FIXER) fix
.PHONY: start_databases
start_databases: ## Start Docker containers
start_databases:
$(DOCKER_COMPOSE) up --detach --build --force-recreate --renew-anon-volumes
.PHONY: stop_databases
stop_databases: ## Stop Docker containers
stop_databases:
$(DOCKER_COMPOSE) stop
#
# Tests
#---------------------------------------------------------------------------
.PHONY: test
test: ## Run all the tests
test: test_core \
test_doctrine_bridge \
test_doctrine_odm_bridge \
test_doctrine_phpcr_bridge \
test_eloquent_bridge \
test_symfony_bridge \
test_symfony_doctrine_bridge \
test_symfony_doctrine_bridge_proxy_manager \
test_symfony_eloquent_bridge \
test_symfony_eloquent_bridge_proxy_manager
.PHONY: test_core
test_core: ## Run the tests for the core library
test_core: vendor/phpunit
bin/phpunit
.PHONY: test_doctrine_bridge
test_doctrine_bridge: ## Run the tests for the Doctrine bridge
test_doctrine_bridge: vendor/bamarni \
vendor-bin/doctrine/vendor/phpunit
$(MAKE) remove_sf_cache
$(MAKE) refresh_mysql_db
vendor-bin/doctrine/bin/doctrine orm:schema-tool:create
vendor-bin/doctrine/bin/phpunit -c phpunit_doctrine.xml.dist
.PHONY: test_doctrine_odm_bridge
test_doctrine_odm_bridge: ## Run the tests for the Doctrine ODM bridge
test_doctrine_odm_bridge: vendor/bamarni \
vendor-bin/doctrine_mongodb/vendor/phpunit
$(MAKE) remove_sf_cache
$(MAKE) refresh_mongodb_db
vendor-bin/doctrine_mongodb/bin/phpunit -c phpunit_doctrine_mongodb.xml.dist
.PHONY: test_doctrine_phpcr_bridge
test_doctrine_phpcr_bridge: ## Run the tests for the Doctrine Mongodb PHPCR bridge
test_doctrine_phpcr_bridge: vendor/bamarni \
vendor-bin/doctrine_mongodb/vendor/phpunit
$(MAKE) remove_sf_cache
$(MAKE) refresh_phpcr
vendor-bin/doctrine_phpcr/bin/phpunit -c phpunit_doctrine_phpcr.xml.dist
.PHONY: test_eloquent_bridge
test_eloquent_bridge: ## Run the tests for the Eloquent bridge
test_eloquent_bridge: vendor/bamarni \
vendor-bin/eloquent/vendor/phpunit
$(MAKE) remove_sf_cache
$(MAKE) refresh_mysql_db
php bin/eloquent_migrate
vendor-bin/eloquent/bin/phpunit -c phpunit_eloquent.xml.dist
.PHONY: test_symfony_bridge
test_symfony_bridge: ## Run the tests for the Symfony bridge
test_symfony_bridge: vendor/bamarni \
vendor-bin/symfony/vendor/phpunit
$(COVERS_VALIDATOR) -c phpunit_symfony.xml.dist
$(MAKE) remove_sf_cache
vendor-bin/symfony/bin/phpunit -c phpunit_symfony.xml.dist
.PHONY: test_symfony_doctrine_bridge
test_symfony_doctrine_bridge: ## Run the tests for the Symfony Doctrine bridge
test_symfony_doctrine_bridge: vendor/bamarni \
vendor-bin/symfony/vendor/phpunit
$(MAKE) remove_sf_cache
$(MAKE) refresh_mysql_db
$(MAKE) refresh_mongodb_db
$(MAKE) refresh_phpcr
php bin/console doctrine:schema:create --kernel=DoctrineKernel
vendor-bin/symfony/bin/phpunit -c phpunit_symfony_doctrine.xml.dist
.PHONY: test_symfony_eloquent_bridge
test_symfony_eloquent_bridge: ## Run the tests for the Symfony Eloquent bridge
test_symfony_eloquent_bridge: vendor/bamarni \
bin/console \
vendor-bin/symfony/vendor/phpunit
$(MAKE) remove_sf_cache
$(MAKE) refresh_mysql_db
php bin/console eloquent:migrate:install --kernel=EloquentKernel
vendor-bin/symfony/bin/phpunit -c phpunit_symfony_eloquent.xml.dist
.PHONY: test_symfony_doctrine_bridge_proxy_manager
test_symfony_doctrine_bridge_proxy_manager: ## Run the tests for the Symfony Doctrine bridge with Proxy Manager
test_symfony_doctrine_bridge_proxy_manager: vendor/bamarni \
bin/console \
vendor-bin/proxy-manager/vendor/phpunit
$(MAKE) remove_sf_cache
$(MAKE) refresh_mysql_db
$(MAKE) refresh_mongodb_db
$(MAKE) refresh_phpcr
php bin/console doctrine:schema:create --kernel=DoctrineKernel
vendor-bin/proxy-manager/bin/phpunit -c phpunit_symfony_proxy_manager_with_doctrine.xml.dist
.PHONY: test_symfony_eloquent_bridge_proxy_manager
test_symfony_eloquent_bridge_proxy_manager: ## Run the tests for the Symfony Eloquent bridge with Proxy Manager
test_symfony_eloquent_bridge_proxy_manager: vendor/bamarni \
bin/console \
vendor-bin/proxy-manager/vendor/phpunit
$(MAKE) remove_sf_cache
$(MAKE) refresh_mysql_db
php bin/console eloquent:migrate:install --kernel=EloquentKernel
vendor-bin/proxy-manager/bin/phpunit -c phpunit_symfony_proxy_manager_with_eloquent.xml.dist
#
# Rules from files
#---------------------------------------------------------------------------
composer.lock: composer.json
@echo composer.lock is not up to date.
vendor/phpunit: composer.lock
composer update $(COMPOSER_FLAGS)
touch $@
vendor/bamarni: composer.lock
composer update $(COMPOSER_FLAGS)
touch $@
vendor-bin/php-cs-fixer/composer.lock: vendor-bin/php-cs-fixer/composer.json
@echo php-cs-fixer composer.lock is not up to date.
vendor-bin/php-cs-fixer/vendor: vendor-bin/php-cs-fixer/composer.lock
composer bin php-cs-fixer update $(COMPOSER_FLAGS)
touch $@
vendor-bin/doctrine/composer.lock: vendor-bin/doctrine/composer.json
@echo vendor-bin/doctrine/composer.lock is not up to date.
vendor-bin/doctrine/vendor/phpunit: vendor-bin/doctrine/composer.lock
composer bin doctrine update $(COMPOSER_FLAGS)
touch $@
vendor-bin/doctrine_mongodb/composer.lock: vendor-bin/doctrine_mongodb/composer.json
@echo vendor-bin/doctrine_mongodb/composer.lock is not up to date.
vendor-bin/doctrine_mongodb/vendor/phpunit: vendor-bin/doctrine_mongodb/composer.lock
composer bin doctrine_mongodb update $(COMPOSER_FLAGS) || true
composer bin doctrine_mongodb update $(COMPOSER_FLAGS)
touch $@
vendor-bin/doctrine_phpcr/composer.lock: vendor-bin/doctrine_phpcr/composer.json
@echo vendor-bin/doctrine_phpcr/composer.lock is not up to date.
vendor-bin/doctrine_phpcr/vendor/phpunit: vendor-bin/doctrine_phpcr/composer.lock
composer bin doctrine_phpcr update $(COMPOSER_FLAGS)
touch $@
vendor-bin/doctrine_phpcr/bin/phpcrodm: vendor-bin/doctrine_phpcr/composer.lock
composer bin doctrine_phpcr update $(COMPOSER_FLAGS)
touch $@
vendor-bin/eloquent/composer.lock: vendor-bin/eloquent/composer.json
@echo vendor-bin/eloquent/composer.lock is not up to date.
vendor-bin/eloquent/vendor/phpunit: vendor-bin/eloquent/composer.lock
composer bin eloquent update $(COMPOSER_FLAGS) || true
composer bin eloquent update $(COMPOSER_FLAGS)
touch $@
vendor-bin/symfony/composer.lock: vendor-bin/symfony/composer.json
@echo vendor-bin/symfony/composer.lock is not up to date.
vendor-bin/symfony/vendor/phpunit: vendor-bin/symfony/composer.lock
composer bin symfony update $(COMPOSER_FLAGS) || true
composer bin symfony update $(COMPOSER_FLAGS)
touch $@
bin/console: vendor-bin/symfony/composer.lock
composer bin symfony update $(COMPOSER_FLAGS) || true
composer bin symfony update $(COMPOSER_FLAGS)
touch $@
vendor-bin/proxy-manager/composer.lock: vendor-bin/proxy-manager/composer.json
@echo vendor-bin/proxy-manager/composer.lock is not up to date.
vendor-bin/proxy-manager/vendor/phpunit: vendor-bin/proxy-manager/composer.lock
composer bin proxy-manager update $(COMPOSER_FLAGS) || true
composer bin proxy-manager update $(COMPOSER_FLAGS)
touch $@