Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (52 loc) · 2.05 KB
/
Copy pathMakefile
File metadata and controls
64 lines (52 loc) · 2.05 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
.PHONY: build test check fmt fmt-check vet lint cover install-hooks gen
build:
go build ./...
test:
go test -race ./...
cover:
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
fmt:
gofmt -w ./internal ./cmd
fmt-check:
@out=$$(gofmt -l ./internal ./cmd); \
if [ -n "$$out" ]; then \
echo "unformatted files:"; echo "$$out"; exit 1; \
fi
vet:
go vet ./...
lint:
@command -v golangci-lint >/dev/null || { echo "golangci-lint not installed: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2"; exit 1; }
golangci-lint run ./...
# Runs lint too so the forbidigo bans (e.g. huh.NewSelect) fire on pre-commit,
# not just in CI. Skips gracefully when golangci-lint isn't installed — CI still
# enforces it.
check: fmt-check vet test
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not installed — skipping lint locally; CI enforces it (install: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2)"; \
fi
tidy:
go mod tidy
install-hooks:
@command -v lefthook >/dev/null || go install github.com/evilmartians/lefthook@latest
@if command -v lefthook >/dev/null; then \
lefthook install; \
else \
PATH="$(shell go env GOPATH)/bin:$$PATH" lefthook install; \
fi
gen: ## Regenerate API types from OpenAPI spec
@if ! python3 -c "import yaml" 2>/dev/null; then \
echo "Installing pyyaml into /tmp/pyyaml-env ..."; \
python3 -m venv /tmp/pyyaml-env && /tmp/pyyaml-env/bin/pip install -q pyyaml; \
PYTHON=/tmp/pyyaml-env/bin/python3; \
else \
PYTHON=python3; \
fi; \
$$PYTHON scripts/preprocess-spec.py docs/specs/v2-developer.yaml /tmp/v2-clean.yaml docs/specs/v2-beta-overlay.yaml && \
$$PYTHON scripts/gen-paths.py /tmp/v2-clean.yaml docs/specs/cli-coverage.yaml internal/api/paths_gen.go
go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen \
--config oapi-codegen.yaml /tmp/v2-clean.yaml
preview: ## Render output snapshots to SVGs in docs/previews (brew install charmbracelet/tap/freeze)
./scripts/preview.sh