-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (84 loc) · 3.96 KB
/
Copy pathMakefile
File metadata and controls
101 lines (84 loc) · 3.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
# Reins — the stable command surface (CLAUDE.md §6). Keep these target names forever.
#
# The Python package lives in packages/python with its own pyproject.toml
# (ruff / mypy / pytest config). `make setup` builds a local venv there; every
# other target uses that venv's tools, falling back to whatever is on PATH so a
# single target still runs if `make setup` was skipped.
PKG := packages/python
VBIN := $(PKG)/.venv/bin
GODIR := packages/go
JSDIR := packages/js
# Prefer the project venv's tools. abspath keeps the path valid after `cd $(PKG)`.
PY := $(if $(wildcard $(VBIN)/python),$(abspath $(VBIN)/python),python3)
RUFF := $(if $(wildcard $(VBIN)/ruff),$(abspath $(VBIN)/ruff),ruff)
MYPY := $(if $(wildcard $(VBIN)/mypy),$(abspath $(VBIN)/mypy),mypy)
PYTEST := $(if $(wildcard $(VBIN)/pytest),$(abspath $(VBIN)/pytest),pytest)
GO := go
.DEFAULT_GOAL := help
.PHONY: help setup lint types test conformance check demo clean go-lint go-test go-check js-setup js-check
help:
@echo "Reins — make targets:"
@echo " setup install deps + pre-commit (prefers uv, falls back to pip)"
@echo " lint ruff check + format check"
@echo " types mypy --strict on src/"
@echo " test pytest (happy + unhappy paths)"
@echo " conformance run spec/conformance (linter + golden cases)"
@echo " check lint + types + test + conformance <- the Python gate"
@echo " demo run the flagship example end-to-end"
@echo " go-check gofmt + go vet + go test <- the Go gate (Phase 6)"
@echo " js-check prettier + tsc --noEmit + vitest <- the TS gate (Phase 7)"
@echo " clean remove the local venv and caches"
setup:
@if command -v uv >/dev/null 2>&1; then \
echo ">> setup: using uv"; \
uv venv $(PKG)/.venv >/dev/null; \
uv pip install --python $(PKG)/.venv/bin/python -e "$(PKG)[dev]"; \
else \
echo ">> setup: using python venv + pip"; \
test -d $(PKG)/.venv || python3 -m venv $(PKG)/.venv; \
$(PKG)/.venv/bin/python -m pip install --quiet --upgrade pip; \
$(PKG)/.venv/bin/python -m pip install -e "$(PKG)[dev]"; \
fi
@$(PKG)/.venv/bin/pre-commit install >/dev/null 2>&1 \
&& echo ">> pre-commit hook installed" \
|| echo ">> note: pre-commit hook not installed (needs a git repo + pre-commit)"
lint:
cd $(PKG) && $(RUFF) check src tests
cd $(PKG) && $(RUFF) format --check src tests
types:
cd $(PKG) && $(MYPY) src
test:
cd $(PKG) && $(PYTEST) --cov=reins --cov-report=term-missing --cov-fail-under=90
# Run the language-neutral conformance cases via the Python adapter. Cases xfail
# until their feature is built (spec/contract.md §7.6); -v -rxX reports per-case
# status. `-o addopts=` clears the package default (-q) so the run is verbose;
# `-o python_files=...` lets pytest collect the (non-test-named) runner file.
conformance:
cd $(PKG) && $(PYTEST) -o addopts= -o python_files=conformance_runner.py -v -rxX tests/conformance_runner.py
check: lint types test conformance
@echo ">> check: all green"
# The Go port (Phase 6). Kept a separate gate from `check` so the Python CI job
# needs no Go toolchain and vice versa; a dedicated CI job runs `go-check`.
go-lint:
cd $(GODIR) && test -z "$$(gofmt -l .)" || { echo "gofmt needs to run on:"; gofmt -l .; exit 1; }
cd $(GODIR) && $(GO) vet ./...
go-test:
cd $(GODIR) && $(GO) test ./...
go-check: go-lint go-test
@echo ">> go-check: all green"
# The TypeScript port (Phase 7). Like go-check, a separate gate with its own CI job
# so the Python and Go jobs need no Node toolchain. `js-setup` installs deps.
js-setup:
cd $(JSDIR) && npm install
js-check:
cd $(JSDIR) && npm run format:check
cd $(JSDIR) && npm run typecheck
cd $(JSDIR) && npm test
@echo ">> js-check: all green"
# The flagship example: a deterministic end-to-end walkthrough (FakeModel, no key).
demo:
$(PY) -m examples.fastapi_sqlalchemy.demo
clean:
rm -rf $(PKG)/.venv
find . -type d -name __pycache__ -prune -exec rm -rf {} +
find . -type d -name '.*_cache' -prune -exec rm -rf {} +