-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
75 lines (63 loc) · 2.78 KB
/
Makefile
File metadata and controls
75 lines (63 loc) · 2.78 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
.PHONY: build test lint lint-go lint-fmt snapshot snapshot-error-codes release release-snapshot docs-commands docs-commands-check docs-preview
# Build a local agora binary with stripped paths.
build:
go build -trimpath -o agora .
# Run the full Go test suite.
test:
go test ./...
# Aggregate lint target. Runs gofmt, golangci-lint (if installed), the
# error-code coverage audit, and the docs/commands.md drift check. Use
# this in CI and pre-commit.
lint: lint-fmt lint-go snapshot-error-codes docs-commands-check
lint-fmt:
@unformatted="$$(gofmt -l .)"; \
if [ -n "$$unformatted" ]; then \
echo "::error::gofmt found unformatted files:"; \
echo "$$unformatted"; \
exit 1; \
fi
# Run golangci-lint with the project config (.golangci.yml).
# CI uses v1.64.8 (matched in .github/workflows/ci.yml). To install locally:
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
# | sh -s -- -b "$$(go env GOPATH)/bin" v1.64.8
# Set LINT_GO_STRICT=1 to fail when golangci-lint is missing (CI default).
lint-go:
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run --timeout=5m ./...; \
elif [ "$${LINT_GO_STRICT:-0}" = "1" ]; then \
echo "::error::golangci-lint not installed. Install: https://golangci-lint.run/usage/install/" >&2; \
exit 1; \
else \
echo "golangci-lint not installed; skipping. Install: https://golangci-lint.run/usage/install/"; \
fi
# Snapshot the introspect envelope (mainly used to spot-check schema changes).
snapshot:
go run . introspect --json
# Audit that docs/error-codes.md documents every Code: literal in internal/cli/*.go.
# Fails non-zero if any code is undocumented. Wired into CI via `make lint`.
snapshot-error-codes:
./scripts/check-error-codes.sh
# Run a full GoReleaser snapshot release locally (no publish, no GitHub release).
# Useful for verifying .goreleaser.yaml changes before tagging.
release-snapshot:
@if command -v goreleaser >/dev/null 2>&1; then \
goreleaser release --snapshot --clean; \
else \
echo "::error::goreleaser not installed. Install: https://goreleaser.com/install/"; \
exit 1; \
fi
# Alias for release-snapshot to match common Make conventions.
release: release-snapshot
# Regenerate docs/commands.md from the live cobra command tree. Run this
# whenever you add, remove, rename, or rewrap a command/flag.
docs-commands:
go run ./cmd/gendocs
# Drift check used in CI: fails non-zero if docs/commands.md does not match
# the current command tree. The fix is to run `make docs-commands` and
# commit the result alongside the code change.
docs-commands-check:
go run ./cmd/gendocs -check
# Build and serve the GitHub Pages docs locally with the custom theme.
# Uses an empty local baseurl so assets resolve from http://localhost:4000/.
docs-preview:
./scripts/preview-pages-site.sh