Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (55 loc) · 3.23 KB
/
Copy pathMakefile
File metadata and controls
62 lines (55 loc) · 3.23 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
# Test, lint, and format the repository.
.DEFAULT_GOAL := help
.PHONY: help test fix verify git-hooks custom-gcl
# The custom-gcl binary is not byte-reproducible (golangci-lint custom builds
# in a random temp directory and stamps VCS metadata), so staleness is tracked
# by hashing the build inputs instead of comparing mtimes: the plugin config
# plus the pinned golangci-lint version and the Go toolchain. A branch switch
# that recreates .custom-gcl.yml with a fresh timestamp must not trigger a
# rebuild; a version or config change must.
.PHONY: custom-gcl
custom-gcl:
@version=$$(go list -m -f '{{.Version}}' github.com/golangci/golangci-lint/v2) || exit 1; \
want=$$({ sha256sum .custom-gcl.yml | cut -d" " -f1; echo "$$version"; go env GOVERSION; } | sha256sum | cut -d" " -f1); \
if [ -x custom-gcl ] && [ "$$want" = "$$(cat .custom-gcl.sha 2>/dev/null)" ]; then exit 0; fi; \
echo 'Building custom-gcl with the methodfilecheck plugin (one-off; runs when the config, golangci-lint version, or Go toolchain changes)...'; \
go tool golangci-lint custom --version "$$version" && echo "$$want" > .custom-gcl.sha
# The one static gate. The gofmt and goimports formatters are checked by
# custom-gcl run itself (formatters section of .golangci.yml) with its warm
# analysis cache; a separate `go tool golangci-lint fmt --diff` pass would re-typecheck
# the whole tree without that cache. Caveat: when another linter fails on the
# same file, run reports the lint error only, so a formatting problem there
# surfaces on the next verify after the lint fix. fix applies the formatters
# through `go tool golangci-lint fmt`.
verify: custom-gcl
@go mod tidy -diff
@go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12
@./custom-gcl run --show-stats=false ./...
@uv run --locked ruff format --check --quiet .
@uv run --locked ruff check --quiet .
@files=$$(git ls-files '*.sh' 'scripts/hooks/*'); [ -z "$$files" ] || go tool shfmt -d $$files
@go tool addlicense -ignore '.venv/**' -ignore '.ruff_cache/**' -ignore 'examples/**' -ignore '**/testdata/**' -check .
@uv run --locked python scripts/lint_binaries.py
@uv run --locked python scripts/update_agents_file_index.py --check
@uv run --locked python -m unittest discover -s providers/claudecode -p 'test_*.py'
# Order matters: the index refresh runs last so it matches the fixed tree.
fix: custom-gcl
@go mod tidy
@./custom-gcl run --show-stats=false ./... --fix
@go tool golangci-lint fmt
@uv run --locked ruff check --quiet --fix .
@uv run --locked ruff format . >/dev/null
@files=$$(git ls-files '*.sh' 'scripts/hooks/*'); [ -z "$$files" ] || go tool shfmt -w $$files
@uv run --locked python scripts/update_agents_file_index.py
test:
@go test -timeout=600s -covermode=count -coverprofile coverage.txt -bench=. -benchtime=1x ./...
git-hooks:
@./scripts/install-git-hooks.sh
help:
@echo 'genai - Go library for talking to LLM providers'
@echo ''
@echo 'Available targets:'
@printf ' %-14s - %s\n' 'make fix' 'Apply every autofix, then refresh the file index'
@printf ' %-14s - %s\n' 'make verify' 'Static gate: gofmt, ruff, shfmt, licenses, binaries, docs'
@printf ' %-14s - %s\n' 'make test' 'Run Go tests with coverage and benchmark smoke checks'
@printf ' %-14s - %s\n' 'make git-hooks' 'Install git hooks'