1
1
.PHONY : $(filter-out vendor bin/tools/phpstan/vendor bin/tools/cs-fixer/vendor,$(MAKECMDGOALS ) )
2
2
3
+ .DEFAULT_GOAL := help
4
+
5
+ # DB variables
3
6
MYSQL_URL="mysql://root:root@mysql:3306/zenstruck_foundry?charset =utf8"
4
7
MONGO_URL="mongodb://mongo:mongo@mongo:27017/mongo?compressors=disabled&gssapiServiceName=mongodb&authSource =mongo"
5
8
9
+ # Default test context variables
10
+ USE_FOUNDRY_BUNDLE =1
11
+ USE_ORM =1
12
+ USE_ODM =1
13
+ USE_DAMA_DOCTRINE_TEST_BUNDLE =1
14
+ SYMFONY_REQUIRE =6.0.*
15
+
16
+ # Override test context variables with `.env` file
17
+ ifneq (,$(wildcard .env) )
18
+ include .env
19
+ export $(shell sed 's/=.*//' .env)
20
+ endif
21
+
22
+ ifeq ($(USE_DAMA_DOCTRINE_TEST_BUNDLE ) ,1)
23
+ PHPUNIT_CONFIG_FILE='phpunit-dama-doctrine.xml.dist'
24
+ else
25
+ PHPUNIT_CONFIG_FILE='phpunit.xml.dist'
26
+ endif
27
+
28
+ # Define docker executable
6
29
ifeq ($(shell docker --help | grep "compose") ,)
7
30
DOCKER_COMPOSE_BIN=docker-compose
8
31
else
9
32
DOCKER_COMPOSE_BIN=docker compose
10
33
endif
11
34
35
+ # Create special context for CI
12
36
INTERACTIVE: =$(shell [ -t 0 ] && echo 1)
13
37
ifdef INTERACTIVE
14
38
CI='false'
15
39
DOCKER_COMPOSE=$(DOCKER_COMPOSE_BIN)
16
- DC_EXEC=$(DOCKER_COMPOSE) exec -e USE_FOUNDRY_BUNDLE=1 -e DATABASE_URL=${MYSQL_URL} -e MONGO_URL=${MONGO_URL}
40
+ DC_EXEC=$(DOCKER_COMPOSE) exec -e USE_FOUNDRY_BUNDLE=${USE_FOUNDRY_BUNDLE} -e DATABASE_URL=${MYSQL_URL} -e MONGO_URL=${MONGO_URL}
17
41
else
18
42
CI='true'
19
43
DOCKER_COMPOSE=$(DOCKER_COMPOSE_BIN) -f docker-compose.yaml -f docker-compose.ci.yaml
20
- DC_EXEC=$(DOCKER_COMPOSE) exec -e USE_FOUNDRY_BUNDLE=1 -e DATABASE_URL=${MYSQL_URL} -e MONGO_URL=${MONGO_URL} -T
44
+ # CI needs to be ran in no-tty mode
45
+ DC_EXEC=$(DOCKER_COMPOSE) exec -e USE_FOUNDRY_BUNDLE=${USE_FOUNDRY_BUNDLE} -e DATABASE_URL=${MYSQL_URL} -e MONGO_URL=${MONGO_URL} -T
21
46
endif
22
47
23
48
DOCKER_PHP =${DC_EXEC} php
24
49
25
- .DEFAULT_GOAL := help
26
-
27
- UID = $(shell id -u)
28
-
29
- DOCKER_IS_UP = $(shell $(DOCKER_COMPOSE ) ps | grep "Up (healthy) ")
30
-
31
- ARGS := $(wordlist 2,$(words $(MAKECMDGOALS ) ) ,$(MAKECMDGOALS ) )
32
- $(eval $(RUN_ARGS ) :;@:)
33
-
34
50
# From inside the containers, docker host ip is different in linux and macos
35
51
UNAME_S := $(shell uname -s)
36
52
ifeq ($(UNAME_S ) ,Linux)
@@ -43,19 +59,11 @@ endif
43
59
help :
44
60
@fgrep -h " ###" $(MAKEFILE_LIST ) | fgrep -v fgrep | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
45
61
46
- validate : fixcs sca test-full database-validate-mapping # ## Run fixcs, sca, full test suite and validate migrations
47
-
48
- test-full : docker-start vendor # ## Run full PHPUnit (MySQL + Mongo)
49
- @$(eval filter ?= '.')
50
- @${DC_EXEC} -e USE_ORM=1 -e USE_ODM=1 php vendor/bin/simple-phpunit --configuration phpunit-dama-doctrine.xml.dist --filter=$(filter )
51
-
52
- test-mysql : docker-start vendor # ## Run PHPUnit with MySQL
53
- @$(eval filter ?= '.')
54
- @${DC_EXEC} -e USE_ORM=1 php vendor/bin/simple-phpunit --configuration phpunit-dama-doctrine.xml.dist --filter=$(filter )
62
+ validate : fixcs sca test database-validate-mapping # ## Run fixcs, sca, full test suite and validate migrations
55
63
56
- test-mongo : docker-start vendor # ## Run PHPUnit with Mongo
64
+ test : docker-start vendor # ## Run PHPUnit tests suite
57
65
@$(eval filter ?= '.')
58
- @${DC_EXEC} -e USE_ODM=1 php vendor/bin/simple-phpunit --configuration phpunit.xml.dist --filter=$(filter )
66
+ @${DC_EXEC} -e USE_ORM= ${USE_ORM} -e USE_ODM=${USE_ODM} php vendor/bin/simple-phpunit --configuration ${PHPUNIT_CONFIG_FILE} --filter=$(filter )
59
67
60
68
fixcs : docker-start bin/tools/cs-fixer/vendor # ## Run PHP-CS-Fixer
61
69
@${DOCKER_PHP} bin/tools/cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer --no-interaction --diff -v fix
@@ -84,8 +92,11 @@ database-drop-schema: docker-start vendor ### Drop database schema
84
92
@${DOCKER_PHP} vendor/bin/doctrine-migrations migrations:sync-metadata-storage # prevents the next command to fail if migrations table does not exist
85
93
@${DOCKER_PHP} bin/doctrine dbal:run-sql " TRUNCATE doctrine_migration_versions" --quiet
86
94
87
- vendor : composer.json $(wildcard composer.lock)
88
- @${DOCKER_PHP} composer update
95
+ vendor : composer.json $(wildcard composer.lock) $(wildcard .env)
96
+ @${DC_EXEC} -e SYMFONY_REQUIRE=${SYMFONY_REQUIRE} php composer update --prefer-dist
97
+
98
+ UID = $(shell id -u)
99
+ DOCKER_IS_UP = $(shell $(DOCKER_COMPOSE ) ps | grep "Up (healthy) ")
89
100
90
101
docker-start : # ## Build and run containers
91
102
ifeq ($(DOCKER_IS_UP ) ,)
@@ -104,6 +115,9 @@ docker-stop: ### Stop containers
104
115
docker-purge : docker-stop # ## Purge containers
105
116
@$(DOCKER_COMPOSE ) down --volumes
106
117
118
+ ARGS := $(wordlist 2,$(words $(MAKECMDGOALS ) ) ,$(MAKECMDGOALS ) )
119
+ $(eval $(RUN_ARGS ) :;@:)
120
+
107
121
composer : # ## Run composer command
108
122
@${DC_EXEC} php composer $(ARGS )
109
123
0 commit comments