-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
204 lines (176 loc) · 6.96 KB
/
Copy pathMakefile
File metadata and controls
204 lines (176 loc) · 6.96 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
.PHONY: help install sync dev test lint format boundary clean web-install web-dev web-build build-nu build-nudle build-all test-kernel list
# =============================================================================
# Configuration
# =============================================================================
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m
# The kernel is the repo root; everything else is a directory under pkgs/.
PY_PKGS := . pkgs/nustd pkgs/nucli pkgs/nudle
TS_ROOT := pkgs/ts
NUDLE_APP := pkgs/ts/nudle
# =============================================================================
# Help
# =============================================================================
help:
@echo "$(BLUE)nu monorepo$(NC)"
@echo ""
@echo "$(GREEN)Setup:$(NC)"
@echo " make install Install uv if needed"
@echo " make sync Sync workspace (install all packages)"
@echo " make dev Full dev setup (sync + pre-commit)"
@echo ""
@echo "$(GREEN)Development:$(NC)"
@echo " make test Run all tests"
@echo " make test-pkg PKG=x Run tests for one suite (e.g., PKG=tests/nustd)"
@echo " make test-kernel Run kernel tests"
@echo " make test-cov Run tests with coverage"
@echo " make test-fast Run tests (fail fast, no slow)"
@echo ""
@echo "$(GREEN)Code Quality:$(NC)"
@echo " make lint Check code with ruff"
@echo " make format Format code with ruff"
@echo " make check Run format-check + lint + boundary"
@echo " make boundary Check the kernel does not import nustd"
@echo ""
@echo "$(GREEN)Packages:$(NC)"
@echo " make list List workspace packages"
@echo " make build PKG=x Build specific package"
@echo " make build-nu Build the three nu wheels (kernel, nustd, nucli)"
@echo " make build-nudle Build the nudle web-bundle wheel"
@echo " make build-all Build both wheels"
@echo ""
@echo "$(GREEN)ts workspace:$(NC)"
@echo " make web-install npm install across pkgs/ts (ui-core, ui-kit, nudle)"
@echo " make web-dev Run vite dev server (HMR, ws proxy to :8080)"
@echo " make web-build Build the vite bundle into $(NUDLE_APP)/dist"
@echo ""
@echo "$(GREEN)Cleanup:$(NC)"
@echo " make clean Remove build artifacts"
@echo " make clean-all Remove everything including .venv"
# =============================================================================
# Setup
# =============================================================================
install:
@command -v uv >/dev/null 2>&1 || { \
echo "$(BLUE)Installing uv...$(NC)"; \
curl -LsSf https://astral.sh/uv/install.sh | sh; \
}
@echo "$(GREEN)uv ready$(NC)"
sync: install
@echo "$(BLUE)Syncing workspace...$(NC)"
uv sync --all-packages --all-extras
@echo "$(GREEN)Workspace synced$(NC)"
dev: sync
@echo "$(BLUE)Installing pre-commit hooks...$(NC)"
uv run pre-commit install
@echo "$(GREEN)Dev environment ready$(NC)"
# =============================================================================
# Testing
# =============================================================================
test:
@echo "$(BLUE)Running all tests...$(NC)"
uv run pytest
test-pkg:
ifndef PKG
$(error PKG not set. Usage: make test-pkg PKG=tests/nustd)
endif
@echo "$(BLUE)Testing $(PKG)...$(NC)"
uv run pytest $(PKG) -v
test-kernel:
@echo "$(BLUE)Running kernel tests...$(NC)"
uv run pytest tests/nu -q
test-cov:
@echo "$(BLUE)Running tests with coverage...$(NC)"
uv run pytest --cov --cov-report=html --cov-report=term-missing
@echo "$(GREEN)Report: reports/coverage/index.html$(NC)"
test-fast:
@echo "$(BLUE)Running fast tests...$(NC)"
uv run pytest -m "not slow" -x
# =============================================================================
# Code Quality
# =============================================================================
lint:
@echo "$(BLUE)Linting...$(NC)"
uv run ruff check .
format:
@echo "$(BLUE)Formatting...$(NC)"
uv run ruff format .
uv run ruff check --fix .
@echo "$(GREEN)Done$(NC)"
format-check:
@echo "$(BLUE)Checking format...$(NC)"
uv run ruff format --check .
boundary:
@echo "$(BLUE)Checking kernel boundary...$(NC)"
uv run python scripts/check_kernel_boundary.py
check: format-check lint boundary
@echo "$(GREEN)All checks passed$(NC)"
# =============================================================================
# Packages
# =============================================================================
list:
@echo "$(BLUE)Workspace packages:$(NC)"
@echo ""
@echo "$(GREEN)Python:$(NC)"
@echo " . (nucore, src/nu)"
@ls -d pkgs/*/ 2>/dev/null | grep -v 'pkgs/ts/' | sed 's|/$$||' | sed 's|^| |'
@echo ""
@echo "$(GREEN)TypeScript (pkgs/ts):$(NC)"
@ls -d pkgs/ts/*/ 2>/dev/null | grep -v node_modules | sed 's|/$$||' | sed 's|^| |'
build:
ifndef PKG
$(error PKG not set. Usage: make build PKG=nu)
endif
@echo "$(BLUE)Building $(PKG)...$(NC)"
cd $(PKG) && uv build
@echo "$(GREEN)Built: $(PKG)/dist/$(NC)"
# =============================================================================
# nudle web + nu wheel
# =============================================================================
web-install:
@echo "$(BLUE)Installing ts workspace deps (ui-core, ui-kit, nudle)...$(NC)"
cd $(TS_ROOT) && npm install
@echo "$(GREEN)Installed$(NC)"
web-dev:
@echo "$(BLUE)Starting vite dev server...$(NC)"
cd $(NUDLE_APP) && npm run dev
web-build:
@echo "$(BLUE)Building nudle web bundle...$(NC)"
cd $(NUDLE_APP) && npm run build
@echo "$(GREEN)Built: $(NUDLE_APP)/dist/$(NC)"
build-nu:
@echo "$(BLUE)Building nu wheels (kernel + nustd + nucli)...$(NC)"
uv build --wheel --package nucore
uv build --wheel --package nustd
uv build --wheel --package nucli
@echo "$(GREEN)Built: dist/$(NC)"
build-nudle: web-build
@echo "$(BLUE)Building nudle web-bundle wheel...$(NC)"
uv build --wheel --package nudle
@echo "$(GREEN)Built: dist/$(NC)"
build-all: build-nu build-nudle
@echo "$(GREEN)Both wheels built$(NC)"
# =============================================================================
# Cleanup
# =============================================================================
clean:
@echo "$(BLUE)Cleaning...$(NC)"
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "dist" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "build" -exec rm -rf {} + 2>/dev/null || true
rm -rf .coverage htmlcov/ reports/
@echo "$(GREEN)Clean$(NC)"
clean-all: clean
@echo "$(BLUE)Removing .venv...$(NC)"
rm -rf .venv/
@echo "$(GREEN)Deep clean$(NC)"
# =============================================================================
# CI
# =============================================================================
ci: check test-cov
@echo "$(GREEN)CI passed$(NC)"