forked from sartography/spiff-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
179 lines (130 loc) · 4.21 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
USER_ID ?= $(shell id -u)
USER_NAME ?= $(shell id -un)
GROUP_ID ?= $(shell id -g)
GROUP_NAME ?= $(shell id -gn)
ME ?= $(USER_ID):$(GROUP_ID)
SUDO ?= sudo
ARENA_CONTAINER ?= spiff-arena
ARENA_DEV_OVERLAY ?= dev.docker-compose.yml
BACKEND_CONTAINER ?= spiffworkflow-backend
BACKEND_DEV_OVERLAY ?= spiffworkflow-backend/dev.docker-compose.yml
FRONTEND_CONTAINER ?= spiffworkflow-frontend
FRONTEND_DEV_OVERLAY ?= spiffworkflow-frontend/dev.docker-compose.yml
CONNECTOR_PROXY_CONTAINER ?= spiffworkflow-connector
CONNECTOR_PROXY_DEV_OVERLAY ?= connector-proxy-demo/dev.docker-compose.yml
YML_FILES := -f docker-compose.yml \
-f $(BACKEND_DEV_OVERLAY) \
-f $(FRONTEND_DEV_OVERLAY) \
-f $(CONNECTOR_PROXY_DEV_OVERLAY) \
-f $(ARENA_DEV_OVERLAY)
DOCKER_COMPOSE ?= RUN_AS=$(ME) docker compose $(YML_FILES)
IN_ARENA ?= $(DOCKER_COMPOSE) run --rm $(ARENA_CONTAINER)
IN_BACKEND ?= $(DOCKER_COMPOSE) run --rm $(BACKEND_CONTAINER)
IN_CONNECTOR_PROXY ?= $(DOCKER_COMPOSE) run --rm $(CONNECTOR_PROXY_CONTAINER)
IN_FRONTEND ?= $(DOCKER_COMPOSE) run --rm $(FRONTEND_CONTAINER)
SPIFFWORKFLOW_BACKEND_ENV ?= local_development
BACKEND_SQLITE_FILE ?= src/instance/db_$(SPIFFWORKFLOW_BACKEND_ENV).sqlite3
NODE_MODULES_DIR ?= spiffworkflow-frontend/node_modules
JUST ?=
ARGS ?=
all: dev-env start-dev run-pyl
@true
build-images:
$(DOCKER_COMPOSE) build \
--build-arg USER_ID=$(USER_ID) \
--build-arg USER_NAME=$(USER_NAME) \
--build-arg GROUP_ID=$(GROUP_ID) \
--build-arg GROUP_NAME=$(GROUP_NAME) \
$(JUST)
dev-env: stop-dev build-images poetry-i cp-poetry-i be-poetry-i be-db-clean fe-npm-i
@true
start-dev: stop-dev
$(DOCKER_COMPOSE) up -d
start-event-stream:
$(DOCKER_COMPOSE) up -d event-stream
stop-dev:
$(DOCKER_COMPOSE) down
be-clear-log-file:
$(IN_BACKEND) rm -f log/unit_testing.log
be-db-clean:
$(IN_BACKEND) ./bin/recreate_db clean
be-db-migrate:
$(IN_BACKEND) ./bin/recreate_db migrate
be-logs:
docker logs -f $(BACKEND_CONTAINER)
be-mypy:
$(IN_BACKEND) poetry run mypy src tests
be-poetry-i:
$(IN_BACKEND) poetry install
be-poetry-lock:
$(IN_BACKEND) poetry lock --no-update
be-poetry-rm:
@if [ -d "$(BACKEND_CONTAINER)/.venv" ]; then \
rm -rf "$(BACKEND_CONTAINER)/.venv"; \
fi
be-sh:
$(IN_BACKEND) /bin/bash
be-sqlite:
@if [ ! -f "$(BACKEND_CONTAINER)/$(BACKEND_SQLITE_FILE)" ]; then \
echo "SQLite database file does not exist: $(BACKEND_CONTAINER)/$(BACKEND_SQLITE_FILE)"; \
exit 1; \
fi
$(IN_BACKEND) sqlite3 $(BACKEND_SQLITE_FILE)
be-tests: be-clear-log-file
$(IN_BACKEND) poetry run pytest $(ARGS) tests/spiffworkflow_backend/$(JUST)
be-tests-par: be-clear-log-file
$(IN_BACKEND) poetry run pytest -n auto -x --random-order $(ARGS) tests/spiffworkflow_backend/$(JUST)
cp-sh:
$(IN_CONNECTOR_PROXY) /bin/bash
cp-poetry-i:
$(IN_CONNECTOR_PROXY) poetry install
cp-poetry-lock:
$(IN_CONNECTOR_PROXY) poetry lock --no-update
cp-logs:
docker logs -f $(CONNECTOR_PROXY_CONTAINER)
fe-lint-fix:
$(IN_FRONTEND) npm run lint:fix
fe-logs:
docker logs -f $(FRONTEND_CONTAINER)
fe-npm-clean:
@if [ -d "$(NODE_MODULES_DIR)" ]; then \
rm -rf "$(NODE_MODULES_DIR)"; \
fi
fe-npm-i:
$(IN_FRONTEND) npm i && git checkout -- spiffworkflow-frontend/package-lock.json
fe-npm-rm:
$(IN_FRONTEND) npm rm $(JUST)
fe-sh:
$(IN_FRONTEND) /bin/bash
fe-unimported:
$(IN_FRONTEND) npx unimported
git-debranch:
$(IN_ARENA) poetry run git-debranch
git-debranch-offline:
$(IN_ARENA) poetry run git-debranch --offline
poetry-i:
$(IN_ARENA) poetry install --no-root
poetry-rm:
@if [ -d ".venv" ]; then \
rm -rf ".venv"; \
fi
pre-commit:
$(IN_ARENA) poetry run pre-commit run --verbose --all-files
ruff:
$(IN_ARENA) poetry run ruff check --fix spiffworkflow-backend
run-pyl: fe-lint-fix ruff pre-commit be-mypy be-tests-par
@true
sh:
$(IN_ARENA) /bin/bash
take-ownership:
$(SUDO) chown -R $(ME) .
include event-stream/demo.mk
.PHONY: build-images dev-env \
start-dev stop-dev \
be-clear-log-file be-logs be-mypy be-poetry-i be-poetry-lock be-poetry-rm \
be-db-clean be-db-migrate be-sh be-sqlite be-tests be-tests-par \
cp-logs cp-poetry-i cp-poetry-lock \
fe-lint-fix fe-logs fe-npm-clean fe-npm-i fe-npm-rm fe-sh fe-unimported \
git-debranch git-debranch-offline \
poetry-i poetry-rm pre-commit ruff run-pyl \
take-ownership