-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (57 loc) · 1.81 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
DOCKER_COMPOSE_EXISTS = $(shell which docker-compose > /dev/null && echo 1 || echo 0)
RUN_SERVICES = docker-compose -f docker-compose.local.yml up -d && docker exec quests_db bash -c "until pg_isready; do sleep 1; done" > /dev/null && sleep 5
LOCAL_DB = $(shell docker ps | grep quests_db > /dev/null && echo 1 || echo 0)
CARGO_RUN_SERVER_WATCH = RUST_LOG=debug cargo watch -x 'run --bin quests_server --'
CARGO_RUN_SERVER = RUST_LOG=debug cargo run --bin quests_server --
WATCH_EXISTS = $(shell which cargo-watch > /dev/null && echo 1 || echo 0)
INSTALL_WATCH = cargo install cargo-watch
export DATABASE_URL=postgres://postgres:postgres@localhost:5432/quests_db # due to docker-compose.local.yml
runservices:
ifeq ($(DOCKER_COMPOSE_EXISTS), 1)
@$(RUN_SERVICES)
else
@$(ERROR) "Install Docker in order to run the local DB"
@exit 1;
endif
destroyservices:
-@docker stop quests_db
-@docker stop quests_redis
-@docker rm quests_db
-@docker rm quests_redis
-@docker volume rm quests_quests_db_volume
test-db: TEST_PROJECT=-p quests_db
test-db: tests
test-message-broker: TEST_PROJECT=-p quests_message_broker
test-message-broker: tests
test-server: TEST_PROJECT=-p quests_server
test-server: tests
test-system: TEST_PROJECT=-p quests_system
test-system: tests
test-protocol:
-@cargo test --package quests_protocol
# run tests locally
tests:
ifeq ($(LOCAL_DB), 1)
@make destroyservices
@make runservices
-@cargo test $(TEST_PROJECT)
@docker stop quests_db
@make destroyservices
else
@make runservices
-@cargo test $(TEST_PROJECT)
@make destroyservices
endif
run-devserver:
ifeq ($(WATCH_EXISTS), 1)
@make runservices
@$(CARGO_RUN_SERVER_WATCH)
else
@echo "cargo-watch not found. installing..."
@$(INSTALL_WATCH)
@make runservices
@$(CARGO_RUN_SERVER_WATCH)
endif
run-server:
@make runservices
@$(CARGO_RUN_SERVER)