-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
232 lines (181 loc) · 6.53 KB
/
Makefile
File metadata and controls
232 lines (181 loc) · 6.53 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
.PHONY: format
format:
cargo fmt --all
.PHONY: lints
lints:
cargo clippy --workspace --all-targets -- -D warnings
lints.pedantic:
cargo clippy --workspace --all-targets -- -D warnings -W clippy::pedantic -A clippy::must_use_candidate -A clippy::missing_errors_doc
####### TOML tests
.PHONY: test.toml
test.toml:
cargo test -p opsml-toml -- --nocapture --test-threads=1
####### CLI tests
.PHONY: test.cli
test.cli:
cargo test -p opsml-cli -- --nocapture --test-threads=1
####### SQL tests
.PHONY: test.sql.sqlite
test.sql.sqlite:
cargo test -p opsml-sql test_sqlite -- --nocapture --test-threads=1
.PHONY: test.sql.enum
test.sql.enum:
cargo test -p opsml-sql test_enum -- --nocapture --test-threads=1
.PHONY: build.postgres
build.postgres:
docker compose down --volumes
docker compose up -d --build postgres --wait
.PHONY: test.sql.postgres
test.sql.postgres: build.postgres
cargo test -p opsml-sql test_postgres -- --nocapture --test-threads=1
.PHONY: build.mysql
build.mysql:
docker compose down --volumes
docker compose up -d --build mysql --wait
.PHONY: test.sql.mysql
test.sql.mysql: build.mysql
cargo test -p opsml-sql test_mysql -- --nocapture --test-threads=1
docker compose down --volumes
.PHONY: test.sql
test.sql: test.sql.sqlite test.sql.enum test.sql.postgres test.sql.mysql
test.service:
cargo test -p opsml-service -- --nocapture --test-threads=1
######## Storage tests
.PHONY: test.storage.local.server
test.storage.local.server:
cargo test -p opsml-storage test_local_storage_server -- --nocapture --test-threads 1
######## Collective Unit Tests
##.PHONY: test.unit
##test.unit: test.toml test.cli test.sql test.storage.server test.utils
######## Server tests
.PHONY: start.server
start.server: stop.server build.ui
cargo build -p opsml-server
./target/debug/opsml-server
start.server.background: stop.server build.ui
cargo build -p opsml-server
./target/debug/opsml-server &
.PHONY: stop.server
stop.server:
-lsof -ti:3000 | xargs kill -9 2>/dev/null || true
# rm -f opsml.db || true
# rm -rf opsml_registries || true
######## Storage tests
.PHONY: test.storage.client
test.storage.client:
cargo test -p opsml-storage test_local_storage_client -- --nocapture
.PHONY: test.storage.server
test.storage.server:
cargo test -p opsml-storage test_local_storage_server -- --nocapture --test-threads 1
.PHONY: test.utils
test.utils:
cargo test -p opsml-utils -- --nocapture
.PHONY: test.opsml.server
test.server:
cargo test -p opsml-server test_opsml_server -- --nocapture --test-threads=1
.PHONY: test.opsml.registry.client
test.opsml.registry.client:
cargo test --features server -p opsml-registry test_registry_client -- --nocapture --test-threads=1
.PHONY: test.version
test.version:
cargo test -p opsml-version -- --nocapture --test-threads=1
.PHONY: test.unit
test.unit: test.toml test.cli test.sql test.storage.server test.server test.utils test.version
###### UI ######
UI_DIR = crates/opsml_server/opsml_ui
PY_DIR = py-opsml
ui.update.deps:
cd $(UI_DIR) && pnpm update
.PHONY: ui.install.deps
install.ui.deps:
cd $(UI_DIR) && pnpm install
.PHONY: ui.install.deps.prod
install.ui.deps.prod:
# remove existing node_modules
rm -rf $(UI_DIR)/node_modules
# install only production dependencies
cd $(UI_DIR) && pnpm install --prod
.PHONY: build.ui
build.ui:
cd $(UI_DIR) && pnpm install
cd $(UI_DIR) && pnpm build
ui.dev:
cd $(UI_DIR) && pnpm run dev
populate.cards:
cd $(PY_DIR) && uv run python -m dev.populate_cards
.PHONY: changelog
prepend.changelog:
# get version from Cargo.toml
@VERSION=$(shell grep '^version =' Cargo.toml | cut -d '"' -f 2) && \
git cliff --unreleased --tag $$VERSION --prepend CHANGELOG.md
###### Development & Production - Separate Servers ######
.PHONY: dev.backend
dev.backend:
cargo build -p opsml-server
OPSML_SERVER_PORT=8080 ./target/debug/opsml-server
.PHONY: dev.frontend
dev.frontend:
cd $(UI_DIR) && pnpm run dev
.PHONY: build.backend
build.backend:
cargo build -p opsml-server --target
.PHONY: start.backend
start.backend: build.backend
OPSML_SERVER_PORT=8080 ./target/release/opsml-server
.PHONY: start.frontend
start.frontend: build.ui
cd $(UI_DIR) && node build/index.js
.PHONY: dev.both
dev.both:
@echo "Starting both servers in development mode..."
@echo "Backend API: http://localhost:8080"
@echo "Frontend SSR: http://localhost:3000"
@make -j2 dev.backend dev.frontend
.PHONY: start.both
start.both:
@echo "Starting both servers in production mode..."
@echo "Backend API: http://localhost:8080"
@echo "Frontend SSR: http://localhost:3000"
@make -j2 dev.backend start.frontend
.PHONY: stop.both
stop.both:
-lsof -ti:3000 | xargs kill -9 2>/dev/null || true
-lsof -ti:8080 | xargs kill -9 2>/dev/null || true
###### Scouter Integration
###### Service B (Scouter) is expected to run independently on port 8000.
###### Service A (opsml) exposes its backend on 8090 and frontend on 3000.
###### Stopping Service B will NOT affect Service A — opsml degrades gracefully
###### (Scouter-backed features show as unavailable; core UI keeps working).
######
###### Usage:
###### Terminal 1: make dev.both.scouter (starts opsml backend + frontend)
###### Terminal 2: cd <scouter> && make start.server
###### To stop opsml only: make stop.both.scouter
.PHONY: dev.backend.scouter
dev.backend.scouter:
cargo build -p opsml-server
OPSML_SERVER_PORT=8090 SCOUTER_SERVER_URI=http://localhost:8000 ./target/debug/opsml-server
.PHONY: dev.both.scouter
dev.both.scouter: stop.both.scouter
@echo "Building opsml backend..."
@cargo build -p opsml-server
@echo "Starting backend on port 8090 (Scouter integration: http://localhost:8000)"
@echo "Starting frontend on port 3000"
@# Run backend as an independent background process (separate process group so
@# Ctrl-C on the frontend does not propagate to it).
@OPSML_SERVER_PORT=8090 SCOUTER_SERVER_URI=http://localhost:8000 \
nohup ./target/debug/opsml-server > /tmp/opsml-backend.log 2>&1 & \
echo $$! > /tmp/opsml-backend.pid && \
echo "Backend PID: $$(cat /tmp/opsml-backend.pid) — logs: /tmp/opsml-backend.log"
@# Frontend runs in the foreground; kill it with Ctrl-C when done.
cd $(UI_DIR) && OPSML_SERVER_PORT=8090 pnpm run dev
.PHONY: stop.both.scouter
stop.both.scouter:
@# Kill by saved PID first (clean shutdown), then fall back to port scan.
-[ -f /tmp/opsml-backend.pid ] && kill $$(cat /tmp/opsml-backend.pid) 2>/dev/null || true
-rm -f /tmp/opsml-backend.pid
-lsof -ti:8090 | xargs kill -9 2>/dev/null || true
-lsof -ti:3000 | xargs kill -9 2>/dev/null || true
.PHONY: logs.backend.scouter
logs.backend.scouter:
tail -f /tmp/opsml-backend.log