forked from s-stolz/algotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (85 loc) · 3.43 KB
/
Copy pathMakefile
File metadata and controls
107 lines (85 loc) · 3.43 KB
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
ifneq ($(wildcard .venv/bin/python),)
PYTHON ?= .venv/bin/python
else
PYTHON ?= python
endif
COMPOSE ?= docker compose --env-file config/.env.shared
SERVICE ?=
DETACH ?= 0
UP_FLAGS ?=
TEST_BACKEND ?= all
TEST_BACKEND_FROM_GOAL := $(firstword $(filter-out test,$(MAKECMDGOALS)))
ifneq ($(strip $(TEST_BACKEND_FROM_GOAL)),)
TEST_BACKEND := $(TEST_BACKEND_FROM_GOAL)
endif
.PHONY: ensure-pyyaml config validate-config up up-detached up-build up-build-detached build down restart logs ps venvs venv venv-root venvs-recreate venvs-check test backtester ingestion-service broker-service indicator_engine
ifeq ($(DETACH),1)
UP_FLAGS += -d
endif
ensure-pyyaml:
@$(PYTHON) -c "import yaml" >/dev/null 2>&1 || { \
echo "PyYAML missing for $(PYTHON); installing..."; \
$(PYTHON) -m pip install pyyaml; \
}
config: ensure-pyyaml
$(PYTHON) scripts/generate_env.py --force
validate-config: ensure-pyyaml
$(PYTHON) scripts/generate_env.py --validate
up: config
$(COMPOSE) up $(UP_FLAGS)
up-detached: config
$(COMPOSE) up -d
up-build: config
$(COMPOSE) up --build $(UP_FLAGS)
up-build-detached: config
$(COMPOSE) up --build -d
build: config
$(COMPOSE) build
down:
$(COMPOSE) down
restart: config
$(COMPOSE) down
$(COMPOSE) up $(UP_FLAGS)
logs:
$(COMPOSE) logs -f
ps:
$(COMPOSE) ps
venvs:
./scripts/setup_venvs.sh all
venv:
@if [ -z "$(SERVICE)" ]; then \
echo "Usage: make venv SERVICE=<service-name|root>"; \
exit 1; \
fi
./scripts/setup_venvs.sh $(SERVICE)
venv-root:
./scripts/setup_venvs.sh root
venvs-recreate:
./scripts/setup_venvs.sh --recreate all
venvs-check:
./scripts/check_venvs.sh all
test:
@status=0; \
if [ "$(TEST_BACKEND)" = "all" ] || [ "$(TEST_BACKEND)" = "backtester" ]; then \
echo "Running backtester tests..."; \
(cd backtester && py_bin="$(PYTHON)"; [ ! -x "$$py_bin" ] && py_bin="python"; [ -x .venv/bin/python ] && py_bin=".venv/bin/python"; PYTHONPATH=src $$py_bin -m unittest discover -s test/signals -p "test_*.py") || status=1; \
fi; \
if [ "$(TEST_BACKEND)" = "all" ] || [ "$(TEST_BACKEND)" = "ingestion-service" ]; then \
echo "Running ingestion-service tests..."; \
(cd ingestion-service && py_bin="$(PYTHON)"; [ ! -x "$$py_bin" ] && py_bin="python"; [ -x .venv/bin/python ] && py_bin=".venv/bin/python"; $$py_bin -m unittest discover -s tests -p "test_*.py") || status=1; \
fi; \
if [ "$(TEST_BACKEND)" = "all" ] || [ "$(TEST_BACKEND)" = "broker-service" ]; then \
echo "Running broker-service tests..."; \
(cd broker-service && py_bin="$(PYTHON)"; [ ! -x "$$py_bin" ] && py_bin="python"; [ -x .venv/bin/python ] && py_bin=".venv/bin/python"; $$py_bin -m unittest discover -s tests -p "test_*.py") || status=1; \
fi; \
if [ "$(TEST_BACKEND)" = "all" ] || [ "$(TEST_BACKEND)" = "indicator_engine" ]; then \
echo "Running indicator_engine tests..."; \
(cd libs/indicator_engine && py_bin="$(PYTHON)"; [ ! -x "$$py_bin" ] && py_bin="python"; [ -x .venv/bin/python ] && py_bin=".venv/bin/python"; $$py_bin -m unittest discover -s tests -p "test_*.py") || status=1; \
fi; \
if [ "$(TEST_BACKEND)" != "all" ] && [ "$(TEST_BACKEND)" != "backtester" ] && [ "$(TEST_BACKEND)" != "ingestion-service" ] && [ "$(TEST_BACKEND)" != "broker-service" ] && [ "$(TEST_BACKEND)" != "indicator_engine" ]; then \
echo "Invalid backend '$(TEST_BACKEND)'. Use: make test [backtester|ingestion-service|broker-service|indicator_engine]"; \
exit 1; \
fi; \
exit $$status
backtester ingestion-service broker-service indicator_engine:
@: