This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
130 lines (114 loc) · 4.78 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
### start all ###
startAll = docker-compose up -d; \
docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction; \
docker-compose exec php bin/console hautelook:fixtures:load --no-interaction; \
docker-compose logs -f;
### start all ###
### dev database ###
generateDB = docker-compose exec php bin/console doctrine:database:drop --force --if-exists; \
docker-compose exec php bin/console doctrine:database:create; \
docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction;
### dev database ###
### lexik/jwt-authentication-bundle ###
generateJWT = docker-compose exec php bin/console lexik:jwt:generate-keypair --overwrite -n;
### lexik/jwt-authentication-bundle ###
### test database ###
generateTestsDB = docker-compose exec php bin/console --env=test doctrine:database:drop --force --if-exists; \
docker-compose exec php bin/console --env=test doctrine:database:create; \
docker-compose exec php bin/console --env=test doctrine:migrations:migrate --no-interaction;
### test database ###
help:
@echo "MAKEFILE HELP :"
@echo "\t - help: list all makefile commands"
@echo "\t - start: start docker's containers, execute database migrations, execute fixtures, show docker's logs and stop docker containers on terminate signal"
@echo "\t - stop: stop docker containers"
@echo "\t - install: make a docker build"
@echo "\t - kill-docker-builds: stop, kill and down docker's containers (remove JWT keys)"
@echo "\t - new-db: make a new database with the new migrations"
@echo "\t - jwt-keypair: regenerate JWT keys"
@echo "\t - tests: launch all tests"
@echo "\t - tests-security: launch security tests"
@echo "\t - tests-api: launch api tests"
@echo "\t - tests-command: launch command tests"
@echo "\t - fixtures: launch fixtures"
@echo "\t - fixtures-test: launch fixtures for tests"
start:
@bash -c "trap 'trap - SIGINT SIGTERM ERR; $(MAKE) stop-all; exit 1' SIGINT SIGTERM ERR; $(startAll)"
stop-all:
@docker-compose stop
install:
@docker-compose build --pull --no-cache
@cp -R -n api/.env api/.env.local
kill-docker-builds:
@docker-compose stop
@docker-compose kill
@docker-compose down --volumes --remove-orphans
@rm -rf api/config/jwt
new-db:
ifeq ($(shell docker-compose ps | wc -l),2)
@docker-compose up -d
@$(generateDB)
@docker-compose stop
else
@$(generateDB)
endif
jwt-keypair:
ifeq ($(shell docker-compose ps | wc -l),2)
@docker-compose up -d
@$(generateJWT)
@docker-compose stop
else
@$(generateJWT)
endif
tests:
ifeq ($(shell docker-compose ps | wc -l),2)
@docker-compose up -d
@$(generateTestsDB)
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
@bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; docker-compose exec php bin/phpunit"
@docker-compose stop
else
@$(generateTestsDB)
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
@docker-compose exec php bin/phpunit
endif
tests-security:
ifeq ($(shell docker-compose ps | wc -l),2)
@docker-compose up -d
@bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; docker-compose exec php bin/phpunit tests/Security"
@docker-compose stop
else
@docker-compose exec php bin/phpunit tests/Security
endif
tests-api:
ifeq ($(shell docker-compose ps | wc -l),2)
@docker-compose up -d
@$(generateTestsDB)
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
@bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; docker-compose exec php bin/phpunit tests/Api"
@docker-compose stop
else
@$(generateTestsDB)
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
@docker-compose exec php bin/phpunit tests/Api
endif
tests-command:
ifeq ($(shell docker-compose ps | wc -l),2)
@docker-compose up -d
@$(generateTestsDB)
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
@bash -c "trap 'trap - SIGINT SIGTERM ERR; docker-compose stop; exit 1' SIGINT SIGTERM ERR; docker-compose exec php bin/phpunit tests/Command"
@docker-compose stop
else
@$(generateTestsDB)
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction
@docker-compose exec php bin/phpunit tests/Command
endif
fixtures:
@docker-compose exec php bin/console doctrine:migrations:migrate --no-interaction
@docker-compose exec php bin/console hautelook:fixtures:load --no-interaction --purge-with-truncate
@echo "Fixtures loaded"
fixtures-test:
@docker-compose exec php bin/console --env=test doctrine:migrations:migrate --no-interaction
@docker-compose exec php bin/console --env=test hautelook:fixtures:load --no-interaction --purge-with-truncate
@echo "Fixtures loaded"