Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (45 loc) · 1.81 KB
/
Copy pathMakefile
File metadata and controls
53 lines (45 loc) · 1.81 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
SHELL := /bin/bash
.PHONY: dev install-hooks lint test _lint-openapi-drift _lint-links
OPENAPI_URL ?= https://raw.githubusercontent.com/agentsfleet/agentsfleet/main/public/openapi.json
dev:
bun run dev
install-hooks:
@git config core.hooksPath .githooks
@echo "Git hooks enabled from .githooks"
test:
@python3 scripts/test-documentation.py
@python3 scripts/check-documentation.py .
lint: test _lint-openapi-drift
bun run validate
bun run broken-links
$(MAKE) _lint-links
_lint-links:
@git ls-files --cached --others --exclude-standard -z '*.mdx' | \
while IFS= read -r -d '' page; do \
if [ -f "$$page" ]; then \
bun run check-links --config .mlc-config.json "./$$page" || exit; \
fi; \
done
_lint-openapi-drift:
@command -v jq >/dev/null 2>&1 || { echo "jq is required for the OpenAPI drift check"; exit 1; }
@tmp=$$(mktemp); \
if ! curl -sSfL --connect-timeout 5 --max-time 10 "$(OPENAPI_URL)" -o "$$tmp"; then \
echo "could not fetch $(OPENAPI_URL) for the OpenAPI drift check"; \
rm -f "$$tmp"; exit 1; \
fi; \
upstream=$$(jq -r '.paths | to_entries[] | . as $$p | $$p.value | keys[] | (ascii_upcase + " " + $$p.key)' "$$tmp" | sort -u); \
referenced=$$(grep -hoE '"(GET|POST|PUT|DELETE|PATCH) /[^"]+"' docs.json api-reference/endpoint/*.mdx 2>/dev/null | tr -d '"' | sort -u); \
missing=$$(comm -23 <(echo "$$referenced") <(echo "$$upstream")); \
unlisted=$$(comm -13 <(echo "$$referenced") <(echo "$$upstream")); \
rm -f "$$tmp"; \
if [ -n "$$missing" ]; then \
echo "❌ openapi drift: paths referenced by docs but missing from $(OPENAPI_URL):"; \
echo "$$missing" | sed 's/^/ - /'; \
exit 1; \
fi; \
if [ -n "$$unlisted" ]; then \
echo "❌ openapi drift: operations missing from docs.json:"; \
echo "$$unlisted" | sed 's/^/ - /'; \
exit 1; \
fi; \
echo "✓ openapi drift check clean"