-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathMakefile
More file actions
237 lines (175 loc) · 9.13 KB
/
Copy pathMakefile
File metadata and controls
237 lines (175 loc) · 9.13 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
233
234
235
236
237
# ── Configuration ─────────────────────────────────────────────────────────────
TEST_ENGINE_CONFIG := sdk/fixtures/config-test.yaml
BRIDGE_BE_CONFIG := sdk/fixtures/config-bridge-backend.yaml
BRIDGE_CONFIG := sdk/fixtures/config-bridge.yaml
ENGINE_BIN := ./target/debug/iii
START_SCRIPT := bash scripts/start-iii.sh
STOP_SCRIPT := bash scripts/stop-iii.sh
III_URL := ws://localhost:49199
III_HTTP_URL := http://localhost:3199
PYTHON_SDK_DIR := sdk/packages/python/iii
LOCAL_BIN := $(HOME)/.local/bin
export III_TELEMETRY_ENABLED := false
.PHONY: install install-node install-python install-hooks \
engine-build engine-test coverage install-iii-worker engine-fmt-check \
engine-up engine-up-bridges engine-down \
init-build-x86 init-build-aarch64 init-build-all \
sandbox sandbox-debug \
test-sdk-node test-sdk-python test-sdk-rust test-sdk-all \
lint-python lint-rust lint-console lint \
fmt-check fmt-check-rust fmt-check-all \
typecheck-node typecheck-python typecheck \
build-node build-sdk-node build-console build \
fix fix-lint fix-fmt \
check ci-engine ci-sdk-node ci-sdk-python ci-sdk-rust \
ci-console ci-local cli-docs
# ── Setup ─────────────────────────────────────────────────────────────────────
install: install-node install-python
install-node:
pnpm install --frozen-lockfile
install-python:
cd $(PYTHON_SDK_DIR) && uv sync --extra dev
install-hooks:
git config core.hooksPath .githooks
@echo "[hooks] pre-commit installed (core.hooksPath=.githooks)"
# ── Engine ────────────────────────────────────────────────────────────────────
engine-build:
cargo build -p iii --all-features
# Build iii-worker and put it on PATH — the iii integration tests shell out to it.
install-iii-worker:
cargo build -p iii-worker
mkdir -p $(LOCAL_BIN)
install -m755 target/debug/iii-worker $(LOCAL_BIN)/iii-worker
# Mirrors the CI test set (Engine Coverage job). VM crates use default features
# (--all-features would pull in the KVM-only integration-vm/-oci suites); iii
# runs with --all-features. cargo test includes doctests.
engine-test: install-iii-worker
cargo test -p iii-worker -p iii-filesystem -p iii-network -p iii-init
cargo test -p iii --all-features
coverage: install-iii-worker ## Run the engine test suite under llvm-cov (same as CI), prints a report
@eval "$$(cargo llvm-cov show-env --export-prefix)" && \
cargo test -p iii-worker -p iii-filesystem -p iii-network -p iii-init && \
cargo test -p iii --all-features && \
cargo llvm-cov report
engine-fmt-check:
cargo fmt --all -- --check
engine-up:
$(START_SCRIPT) --binary $(ENGINE_BIN) --config $(TEST_ENGINE_CONFIG) --port 49199
engine-up-bridges: engine-up
$(START_SCRIPT) --binary $(ENGINE_BIN) \
--config $(BRIDGE_BE_CONFIG) --port 49198 \
--pid-file /tmp/iii-backend.pid --log-file /tmp/iii-backend.log
$(START_SCRIPT) --binary $(ENGINE_BIN) \
--config $(BRIDGE_CONFIG) --port 49197 \
--pid-file /tmp/iii-bridge.pid --log-file /tmp/iii-bridge.log
engine-down:
$(STOP_SCRIPT) /tmp/iii-engine.pid /tmp/iii-backend.pid /tmp/iii-bridge.pid
# ── Init Binary Cross-Compilation ────────────────────────────────────────────
INIT_CRATE := iii-init
WORKER_CRATE := iii-worker
WORKER_EMBED_FEATURES := embed-init,embed-libkrunfw
init-build-x86:
cargo build -p $(INIT_CRATE) --target x86_64-unknown-linux-musl --release
init-build-aarch64:
cargo build -p $(INIT_CRATE) --target aarch64-unknown-linux-musl --release
init-build-all: init-build-x86 init-build-aarch64
# ── Sandbox (init + engine/worker with embedded assets) ──────────────────────
# Auto-detects host arch for the correct musl init target.
UNAME_M := $(shell uname -m)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_M),x86_64)
INIT_TARGET := x86_64-unknown-linux-musl
else
INIT_TARGET := aarch64-unknown-linux-musl
endif
ifeq ($(UNAME_S),Darwin)
ifeq ($(UNAME_M),x86_64)
WORKER_TARGET := x86_64-apple-darwin
else
WORKER_TARGET := aarch64-apple-darwin
endif
else
ifeq ($(UNAME_M),x86_64)
WORKER_TARGET := x86_64-unknown-linux-gnu
else
WORKER_TARGET := aarch64-unknown-linux-gnu
endif
endif
sandbox: ## Release-like local build: init + engine + worker(embed-init,embed-libkrunfw)
cargo build -p $(INIT_CRATE) --target $(INIT_TARGET) --release
cargo build --release -p iii
cargo build -p $(WORKER_CRATE) --target $(WORKER_TARGET) --features $(WORKER_EMBED_FEATURES) --release
sandbox-debug: ## Release-like local debug: init + engine + worker(embed-init,embed-libkrunfw)
cargo build -p $(INIT_CRATE) --target $(INIT_TARGET) --release
cargo build -p iii
cargo build -p $(WORKER_CRATE) --target $(WORKER_TARGET) --features $(WORKER_EMBED_FEATURES)
# ── SDK Tests ─────────────────────────────────────────────────────────────────
test-sdk-node:
III_URL=$(III_URL) III_HTTP_URL=$(III_HTTP_URL) \
pnpm --filter iii-sdk test:coverage
test-sdk-python:
cd $(PYTHON_SDK_DIR) && \
III_URL=$(III_URL) III_HTTP_URL=$(III_HTTP_URL) \
uv run pytest -q
test-sdk-rust:
III_URL=$(III_URL) III_HTTP_URL=$(III_HTTP_URL) \
cargo test -p iii-sdk --all-features
test-sdk-all: test-sdk-node test-sdk-python test-sdk-rust
# ── Lint ──────────────────────────────────────────────────────────────────────
lint-python:
cd $(PYTHON_SDK_DIR) && uv run ruff check src
lint-rust:
cargo clippy -p iii-sdk --all-targets --all-features -- -D warnings
lint-console:
pnpm --filter console-frontend lint
lint: lint-python lint-rust lint-console
# ── Format Check ──────────────────────────────────────────────────────────────
fmt-check-rust:
cargo fmt -p iii-sdk -- --check
fmt-check-all: engine-fmt-check fmt-check-rust
# ── Type Check ────────────────────────────────────────────────────────────────
typecheck-node:
pnpm --filter iii-sdk exec tsc --noEmit
typecheck-python:
cd $(PYTHON_SDK_DIR) && uv run mypy src
typecheck: typecheck-node typecheck-python
# ── Build ─────────────────────────────────────────────────────────────────────
build-sdk-node:
pnpm --filter iii-sdk build
build-console:
pnpm --filter console-frontend build
cargo build -p iii-console --release
build: sandbox build-console ## Build everything: init + engine + worker + console
@echo ""
@echo "Build complete. Binaries:"
@echo " engine: $(CURDIR)/target/release/iii"
@echo " console: $(CURDIR)/target/release/iii-console"
@echo " worker: $(CURDIR)/target/$(WORKER_TARGET)/release/iii-worker"
@echo ""
@echo "Add them to your PATH:"
@echo ' export PATH="$(CURDIR)/target/release:$(CURDIR)/target/$(WORKER_TARGET)/release:$$PATH"'
# ── CI Jobs (mirror ci.yml) ──────────────────────────────────────────────────
ci-engine: engine-build engine-test engine-fmt-check
ci-sdk-node: engine-up-bridges
@trap '$(MAKE) engine-down' EXIT; \
$(MAKE) typecheck-node build-sdk-node test-sdk-node
ci-sdk-python: engine-up
@trap '$(MAKE) engine-down' EXIT; \
$(MAKE) install-python lint-python typecheck-python test-sdk-python
ci-sdk-rust: engine-up
@trap '$(MAKE) engine-down' EXIT; \
$(MAKE) fmt-check-rust lint-rust test-sdk-rust
ci-console:
$(MAKE) lint-console build-console
# ── Convenience ───────────────────────────────────────────────────────────────
cli-docs: ## Regenerate docs/next/cli-reference/ from the clap CLI definitions
./scripts/generate-cli-docs.sh
fix: fix-fmt fix-lint
fix-fmt:
cargo fmt --all
fix-lint:
cd $(PYTHON_SDK_DIR) && uv run ruff check --fix --unsafe-fixes src && uv run ruff format src
cargo clippy -p iii-sdk --all-targets --all-features --fix --allow-dirty --allow-staged -- -D warnings
pnpm --filter console-frontend run lint:fix
check: lint fmt-check-all typecheck build-sdk-node build-console
ci-local: ci-engine ci-sdk-node ci-sdk-python ci-sdk-rust ci-console