-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
132 lines (99 loc) · 2.56 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
NGINX_TEST_PORT=8839
COMPOSE=docker-compose
COMPOSE_PROD=$(COMPOSE) -f docker-compose.yml -f docker-compose.prod.yml
TEST_BASE_URL=http://nginx:80/api
TEST_PROJECT=liquidator-test
FRONTEND_RUN=$(COMPOSE) run --rm frontend
FRONTEND_TEST_PROJECT=$(COMPOSE) --project-name=$(TEST_PROJECT)
FRONTEND_TEST_EXEC=$(FRONTEND_TEST_PROJECT) exec -e REACT_APP_BASE_URL=$(TEST_BASE_URL) frontend
FRONTEND_TEST_RUN=$(FRONTEND_TEST_PROJECT) run --rm -e REACT_APP_BASE_URL=$(TEST_BASE_URL) frontend
BACKEND_RUN=$(COMPOSE) run --rm backend
BACKEND_MANAGE=$(BACKEND_RUN) python manage.py
PROD_BACKEND_MANAGE=$(COMPOSE_PROD) run --rm backend python manage.py
ifeq ($(OS),Windows_NT)
TEST_NGINX_PREFIX=
else
TEST_NGINX_PREFIX=NGINX_PORT=$(NGINX_TEST_PORT)
endif
.PHONY: all
all: migrate up
.PHONY: prod
prod: build prod-migrate
$(COMPOSE_PROD) up
.PHONY: prod-background
prod-background: build prod-migrate
$(COMPOSE_PROD) up -d
.PHONY: prod-down
prod-logs:
$(COMPOSE_PROD) logs
.PHONY: prod-down
prod-down:
$(COMPOSE_PROD) down
.PHONY: build
build:
$(COMPOSE) build
.PHONY: up
up:
$(COMPOSE) up
.PHONY: background
background:
$(COMPOSE) up -d
.PHONY: stop
stop:
$(COMPOSE) stop
.PHONY: down
down:
$(COMPOSE) down
.PHONY: logs
logs:
$(COMPOSE) logs
.PHONY: test
test: test-backend test-frontend-all
### FRONTEND ###
.PHONY: tslint
tslint:
$(FRONTEND_RUN) tslint -p . $(YCMD)
.PHONY: test-frontend
test-frontend:
$(FRONTEND_RUN) yarn test $(YCMD)
.PHONY: test-frontend-api
test-frontend-api:
$(TEST_NGINX_PREFIX) $(FRONTEND_TEST_PROJECT) up -d
$(FRONTEND_TEST_PROJECT) exec backend python manage.py migrate
$(FRONTEND_TEST_PROJECT) exec backend python manage.py flush --no-input
$(FRONTEND_TEST_RUN) yarn test:api $(YCMD)
$(FRONTEND_TEST_PROJECT) logs
$(FRONTEND_TEST_PROJECT) stop
.PHONY: test-frontend-all
test-frontend-all: test-frontend test-frontend-api
.PHONY: test-frontend-logs
test-frontend-logs:
$(FRONTEND_TEST_PROJECT) logs
### BACKEND ###
.PHONY: makemigrations
makemigrations:
$(BACKEND_MANAGE) makemigrations $(DCMD)
.PHONY: migrate
migrate:
$(BACKEND_MANAGE) migrate $(DCMD)
.PHONY: prod-migrate
prod-migrate:
$(PROD_BACKEND_MANAGE) migrate $(DCMD)
.PHONY: createsuperuser
createsuperuser:
$(BACKEND_MANAGE) createsuperuser $(DCMD)
.PHONY: startapp
startapp:
$(BACKEND_MANAGE) startapp $(APP) $(DCMD)
.PHONY: update-backend
update-backend:
$(BACKEND_RUN) pip install -r requirements.txt $(DCMD)
.PHONY: test-backend
test-backend:
$(BACKEND_MANAGE) test $(DCMD)
.PHONY: shell
shell:
$(BACKEND_MANAGE) shell $(DCMD)
.PHONY: flake
flake:
$(BACKEND_RUN) flake8 $(DCMD)