-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathMakefile
More file actions
176 lines (141 loc) · 6.76 KB
/
Copy pathMakefile
File metadata and controls
176 lines (141 loc) · 6.76 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
.PHONY: build build-collector build-server build-all test lint docker docker-collector docker-server docker-standard up down clean seed release ui-build ui-dev ui-test standard standard-run standard-stop deps-check size-check slop-check version-check sync-version docs-check prerelease preflight-build preflight-collector preflight-server preflight-docker preflight-docker-compose preflight-server-running
# Release tooling is pinned independently of the project's Go version.
# Go may download the tool's newer required toolchain on the first local run.
GORELEASER := go run github.com/goreleaser/goreleaser/v2@v2.15.4
# Preflight gates. Verify required tools are present and at the expected
# major versions BEFORE attempting a build, so newcomers get a friendly
# error instead of a cryptic "command not found" deep in the chain.
# Set AGENTHOUND_SKIP_PREFLIGHT=1 to bypass.
preflight-build:
@bash scripts/preflight.sh build
preflight-collector:
@bash scripts/preflight.sh build-collector
preflight-server:
@bash scripts/preflight.sh build-server
preflight-docker:
@bash scripts/preflight.sh docker
preflight-docker-compose:
@bash scripts/preflight.sh docker-compose
preflight-server-running:
@bash scripts/preflight.sh server-running
ui-build:
cd server/ui && npm ci --ignore-scripts && npm run build
# Preserve dist/.gitkeep (committed so go:embed all:ui/dist works on
# fresh clones); clear other contents and copy in the freshly-built UI.
find server/internal/api/ui/dist -mindepth 1 -not -name .gitkeep -delete
mkdir -p server/internal/api/ui/dist
cp -r server/ui/dist/. server/internal/api/ui/dist/
ui-dev:
cd server/ui && npm run dev
ui-test:
cd server/ui && npm test
build-collector: preflight-collector
go build -o bin/agenthound ./collector/cmd/agenthound
build-server: preflight-server ui-build
go build -o bin/agenthound-server ./server/cmd/agenthound-server
build-all: build-collector build-server
# `build` keeps its name and now produces both binaries.
build: build-all
test:
go test ./... -v -race -count=1
lint:
golangci-lint run ./...
docker-collector: preflight-docker
docker build -f docker/Dockerfile.agenthound -t agenthound:collector .
docker-server: preflight-docker
docker build -f docker/Dockerfile.agenthound-server -t agenthound:server .
docker-standard: preflight-docker
docker build -f docker/Dockerfile.standard -t agenthound:standard .
# `docker` builds both split images (server + collector). The all-in-one
# standard image is built explicitly via `make docker-standard` (or `make standard`).
docker: docker-collector docker-server
up: preflight-docker-compose
docker compose -f docker/docker-compose.yml up -d
down: preflight-docker-compose
docker compose -f docker/docker-compose.yml down
clean:
rm -rf bin/ coverage.out server/ui/dist
# Clear built UI but keep the .gitkeep marker.
find server/internal/api/ui/dist -mindepth 1 -not -name .gitkeep -delete 2>/dev/null || true
seed: preflight-server-running
@bash scripts/seed-test-data.sh
release: ui-build
$(GORELEASER) check
$(GORELEASER) release --clean --snapshot
standard: preflight-docker
docker build -f docker/Dockerfile.standard -t agenthound:latest .
standard-run: preflight-docker
# Build the image first if it doesn't exist locally. agenthound:latest
# is built by `make standard`; running `make standard-run` on a fresh
# checkout without that image would otherwise fail (or worse, pull an
# unrelated image from a default registry).
@if ! docker image inspect agenthound:latest >/dev/null 2>&1; then \
echo ">>> agenthound:latest not found locally; building first (this takes a few minutes)"; \
$(MAKE) standard; \
fi
# Bind on loopback only — the server has no application-layer auth.
# Override with -p 0.0.0.0:8080:8080 only inside a network you trust.
docker run -d --name agenthound -p 127.0.0.1:8080:8080 \
-v agenthound-data:/data --restart unless-stopped agenthound:latest
standard-stop: preflight-docker
docker stop agenthound && docker rm agenthound
deps-check:
@bash scripts/deps-check.sh
size-check:
@bash scripts/size-check.sh
# UI design-system regression gate — fails if banned slop patterns reappear.
# Override individual rules with SLOP_SKIP="rule1,rule2".
slop-check:
@bash scripts/slop-check.sh
# Assert the install.sh + README version pins match the CHANGELOG (the version
# source of truth). Also runs inside `make prerelease`, so release.yml enforces
# it at tag time too.
version-check:
@bash scripts/version-check.sh
@bash scripts/release-process-test.sh
# Rewrite the install.sh + README version pins from the CHANGELOG top header
# (or VERSION=). Usage: make sync-version or make sync-version VERSION=0.7.1
sync-version:
@bash scripts/sync-version.sh $(VERSION)
# Build the MkDocs site in --strict mode (orphan pages, broken links, bad
# anchors). Mirrors the path-filtered Docs CI; needs the docs toolchain.
docs-check:
@bash scripts/docs-check.sh
# Pre-release gate — run BEFORE tagging a release. Mirrors the CI checks that
# gate every release; fails fast on first error. Usage: make prerelease
# (Docs `mkdocs build --strict` is enforced separately by the path-filtered
# Docs workflow + `make docs-check`, so it is intentionally NOT folded in here
# to keep this gate Go/Node-only.)
prerelease:
@echo "=== [1/13] version-check ==="
@bash scripts/version-check.sh
@bash scripts/release-process-test.sh
@echo "=== [2/13] gofmt ==="
@test -z "$$(gofmt -l .)" || (echo "FAIL: gofmt found unformatted files:" && gofmt -l . && exit 1)
@echo "=== [3/13] golangci-lint ==="
golangci-lint run ./...
@echo "=== [4/13] go vet ==="
go vet ./...
@echo "=== [5/13] govulncheck ==="
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
@echo "=== [6/13] go-licenses ==="
go run github.com/google/go-licenses@latest check --allowed_licenses=Apache-2.0,MIT,BSD-2-Clause,BSD-3-Clause,ISC,MPL-2.0,Unlicense,Zlib ./collector/cmd/agenthound/... ./server/cmd/agenthound-server/...
@echo "=== [7/13] go build ==="
go build ./...
@echo "=== [8/13] go test -race -short ==="
go test ./... -race -short -count=1
@echo "=== [9/13] deps-check ==="
@bash scripts/deps-check.sh
@echo "=== [10/13] size-check ==="
@bash scripts/size-check.sh
@echo "=== [11/13] slop-check ==="
# SLOP_SKIP=hardcoded-grids matches the CI ui job: the dashboard grid-cols ->
# Every-Layout migration is a deferred, visually-QA'd task.
@SLOP_SKIP=hardcoded-grids bash scripts/slop-check.sh
@echo "=== [12/13] UI build ==="
cd server/ui && npm run build
@echo "=== [13/13] cross-compile (linux/amd64 + darwin/arm64) ==="
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags='-s -w' -o /dev/null ./collector/cmd/agenthound
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags='-s -w' -o /dev/null ./collector/cmd/agenthound
@echo ""
@echo "=== ALL GATES PASS — safe to tag ==="