-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
184 lines (152 loc) · 5.62 KB
/
Copy pathJustfile
File metadata and controls
184 lines (152 loc) · 5.62 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
# Justfile - Convenient commands for mlnative development
# Works with uv and cargo
# Default recipe - show help
_default:
@just --list
# Setup development environment (installs deps)
setup:
uv venv
uv pip install -e ".[dev,web]"
# CI-friendly setup (assumes tools are pre-installed)
ci-setup:
uv venv
uv pip install -e ".[dev]"
# Build Rust native binary
build-rust:
cd rust && cargo build --release --locked
# Run all tests
test:
uv run python -m pytest tests/ -v --tb=short
# Run specific test
test-single TEST:
uv run python -m pytest {{TEST}} -v
# Run tests matching pattern
test-filter PATTERN:
uv run python -m pytest tests/ -v -k "{{PATTERN}}"
# Run only unit tests (skip integration)
test-unit:
uv run python -m pytest tests/ -v -m "not integration" --tb=short
# Run linting
lint:
uv run ruff check mlnative/ tests/ examples/ scripts/
# Run linting with auto-fix
lint-fix:
uv run ruff check mlnative/ tests/ examples/ scripts/ --fix
# Format code
format:
uv run ruff format mlnative/ tests/ examples/ scripts/
# Check formatting (CI)
format-check:
uv run ruff format mlnative/ tests/ examples/ scripts/ --check
# Run type checking
typecheck:
uv run mypy mlnative/
# Check packaged runtime wiring without starting renderer
doctor:
uv run python -m mlnative doctor
# Smoke-check native renderer with a local empty style
smoke:
uv run python -m mlnative doctor --render
# Run all quality checks (CI)
check: lint format-check typecheck test-unit
# Build package
build:
uv build
# Build the local manylinux image used by cibuildwheel
build-cibw-image:
#!/usr/bin/env bash
set -euo pipefail
case "$(uname -m)" in
x86_64) base_image="quay.io/pypa/manylinux_2_28_x86_64" ;;
aarch64|arm64) base_image="quay.io/pypa/manylinux_2_28_aarch64" ;;
*) echo "Unsupported cibuildwheel host architecture: $(uname -m)" >&2; exit 1 ;;
esac
docker build \
--build-arg BASE_IMAGE="${base_image}" \
-t mlnative-manylinux:latest \
-f docker/cibuildwheel-manylinux.Dockerfile .
# Build wheels for all platforms (requires Docker)
build-wheels: build-cibw-image
uv run cibuildwheel --platform linux --output-dir wheelhouse
# Clean build artifacts
clean:
rm -rf dist/ build/ *.egg-info .pytest_cache .mypy_cache .ruff_cache wheelhouse
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
cd rust && cargo clean 2>/dev/null || true
# CI: Build binary for current platform
# Usage: just ci-build-binary <platform>
# Platform format: linux-x64, darwin-arm64, win32-x64, etc.
ci-build-binary PLATFORM:
#!/usr/bin/env bash
set -euo pipefail
echo "Building binary for {{PLATFORM}}..."
cd rust && cargo build --release --locked
mkdir -p ../mlnative/bin
if [[ "{{PLATFORM}}" == win32-* ]]; then
cp target/release/mlnative-render.exe ../mlnative/bin/mlnative-render-{{PLATFORM}}.exe
else
cp target/release/mlnative-render ../mlnative/bin/mlnative-render-{{PLATFORM}}
chmod +x ../mlnative/bin/mlnative-render-{{PLATFORM}}
fi
echo "✓ Binary built: mlnative/bin/mlnative-render-{{PLATFORM}}"
# CI: Build platform wheels with cibuildwheel
ci-build-wheels: build-cibw-image
uv run cibuildwheel --platform linux --output-dir dist
# CI: Build one platform wheel from the current GitHub runner host
ci-build-host-wheel PLATFORM:
#!/usr/bin/env bash
set -euo pipefail
rm -rf dist wheelhouse
just ci-build-binary {{PLATFORM}}
uv build --wheel --out-dir wheelhouse
for wheel in wheelhouse/*.whl; do
uv run python scripts/build_cibw_wheel.py retag "${wheel}" dist
done
# CI: Build source distribution
ci-build-sdist:
uv pip install build
uv run python -m build --sdist
# Run FastAPI example server
serve:
uv run python examples/fastapi_server.py
# Run web test interface
serve-test:
uv run python examples/web_test_server.py
# Run basic example
example:
uv run python examples/basic.py
# Show code statistics
stats:
scc --by-file --exclude-dir=.venv,__pycache__,bin,target
# Run tests in container (for systems with incompatible libraries)
test-docker:
docker build -f Dockerfile.test -t mlnative-test .
docker run --rm mlnative-test
# Generate visual comparison renders (mlnative vs Chrome)
visual-render:
#!/usr/bin/env bash
set -e
if ! uv run python -c "import playwright" 2>/dev/null; then
echo "Installing playwright..."
uv pip install playwright
fi
if ! uv run python -c "from playwright.sync_api import sync_playwright; p=sync_playwright().start(); p.chromium.executable_path; p.stop()" 2>/dev/null; then
echo "Installing chromium browser..."
uv run playwright install chromium
fi
uv run python scripts/visual_compare.py
# Compare renders using AI (requires opencode with kimi model)
visual-compare:
@echo "Comparing renders with AI..."
@echo ""
@echo "Simple map:"
opencode run -m kimi-for-coding/k2p5 "Compare test-output/simple-mlnative.png with test-output/simple-chrome.png. What rendering differences exist? Focus on layout, colors, and text."
@echo ""
@echo "Zoomed out map:"
opencode run -m kimi-for-coding/k2p5 "Compare test-output/zoomed-out-mlnative.png with test-output/zoomed-out-chrome.png. What rendering differences exist?"
@echo ""
@echo "With bearing:"
opencode run -m kimi-for-coding/k2p5 "Compare test-output/with-bearing-mlnative.png with test-output/with-bearing-chrome.png. What rendering differences exist?"
# Full visual test: render + compare
visual-test: visual-render visual-compare