forked from praxis-proxy/ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (109 loc) · 4.02 KB
/
Copy pathMakefile
File metadata and controls
138 lines (109 loc) · 4.02 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
# -------------------------------------------------------------------
# Configuration
# -------------------------------------------------------------------
VERSION ?= $(shell perl -ne 'print $$1 if /^version\s*=\s*"(.+)"/' Cargo.toml)
IMAGE ?= praxis-ai
CONTAINER_ENGINE ?= $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null)
V ?=
ifneq ($(V),)
_NOCAPTURE := -- --nocapture
endif
.PHONY: all build release check clean \
test test-unit test-integration \
lint fmt doc audit coverage-check \
require-container-engine \
container container-run \
setup-hooks help
# -------------------------------------------------------------------
# All
# -------------------------------------------------------------------
all: build fmt lint test audit
# -------------------------------------------------------------------
# Build
# -------------------------------------------------------------------
build:
cargo build --workspace
release:
cargo build --workspace --release
check:
cargo check --workspace
clean:
cargo clean
# -------------------------------------------------------------------
# Container
# -------------------------------------------------------------------
require-container-engine:
ifndef CONTAINER_ENGINE
$(error No container engine found — install podman or docker)
endif
container: | require-container-engine
$(CONTAINER_ENGINE) build -t $(IMAGE):$(VERSION) -f Containerfile ..
container-run: | require-container-engine
$(CONTAINER_ENGINE) run --rm --network=host $(IMAGE):$(VERSION) 2>&1
# -------------------------------------------------------------------
# Test
# -------------------------------------------------------------------
test:
cargo test --workspace $(_NOCAPTURE)
test-unit:
cargo test -p praxis-ai-apis $(_NOCAPTURE)
cargo test -p praxis-ai-filters $(_NOCAPTURE)
cargo test -p praxis-ai-proxy $(_NOCAPTURE)
test-integration:
cargo test -p praxis-ai-tests-integration $(_NOCAPTURE)
# -------------------------------------------------------------------
# Quality
# -------------------------------------------------------------------
AI_PKGS := -p praxis-ai-proxy -p praxis-ai-filters -p praxis-ai-apis -p xtask
lint:
cargo clippy --workspace --all-targets -- -D warnings
cargo +nightly fmt $(AI_PKGS) -- --check
fmt:
cargo +nightly fmt $(AI_PKGS)
doc:
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
audit:
cargo audit
cargo deny check
coverage-check:
cargo llvm-cov --workspace --json \
--exclude xtask \
--ignore-filename-regex '(target/|tests/)' \
--fail-under-lines 95 \
--output-path coverage.json
# -------------------------------------------------------------------
# Dev Setup
# -------------------------------------------------------------------
setup-hooks:
ln -sf ../../.hooks/pre-commit .git/hooks/pre-commit
@echo "Git hooks installed."
# -------------------------------------------------------------------
# Help
# -------------------------------------------------------------------
help:
@echo "Variables:"
@echo " V=1 show test output (--nocapture)"
@echo ""
@echo "Top-level:"
@echo " all build + lint + test + audit"
@echo ""
@echo "Build:"
@echo " build cargo build --workspace"
@echo " release cargo build --workspace --release"
@echo " check cargo check --workspace"
@echo " clean cargo clean"
@echo ""
@echo "Test:"
@echo " test run all tests"
@echo " test-unit unit tests (providers, filters, server)"
@echo " test-integration integration tests"
@echo ""
@echo "Quality:"
@echo " lint clippy + rustfmt check"
@echo " fmt format with nightly rustfmt"
@echo " doc rustdoc with warnings"
@echo " audit cargo audit + cargo deny"
@echo ""
@echo "Container:"
@echo " container build praxis-ai container image"
@echo " container-run run container in foreground (host network)"