114 lines
5.4 KiB
Makefile
114 lines
5.4 KiB
Makefile
run: ## Run the application (cross-platform; uses go run for dev on Linux/macOS/Windows)
|
|
@go run .
|
|
|
|
run-debug: ## Run the application with debug logging (cross-platform)
|
|
@go run . --log-level debug
|
|
|
|
build: deps lint ## Build a snapshot of the application for the current platform (uses -short for fast feedback)
|
|
@go test -short -v ./...
|
|
@goreleaser build --single-target --snapshot --clean
|
|
|
|
test: deps lint ## Run all tests
|
|
@go test -shuffle=on -timeout=5m -v ./...
|
|
|
|
test-race: deps lint ## Run all tests with the race detector
|
|
@go test -race -shuffle=on -timeout=5m -v ./...
|
|
|
|
lint: deps check-review-labels ## Run golangci-lint + review label hygiene check
|
|
@golangci-lint run ./...
|
|
|
|
check-review-labels: ## Fail if temporary review labels (P0-01, T1, I3, R2, etc.) are found in source
|
|
@! grep -rnE '\b[A-Z][0-9][^a-zA-Z]' --include='*.go' --include='*.md' --include='*.yaml' --include='*.sh' --exclude='AGENTS.md' . 2>/dev/null | grep -v 'G[0-9]\{3\}' || (echo "Error: Found temporary review labels (P*, T*, I*, etc.) in source. See AGENTS.md for the rule." && exit 1)
|
|
|
|
deps: ## Download dependencies
|
|
@go mod tidy
|
|
|
|
clean: ## Remove build artifacts and test cache
|
|
@rm -rf bin/ dist/ *.test coverage.out steamcache2
|
|
|
|
clean-disk: ## Remove disk cache
|
|
@rm -rf validate-disk/
|
|
|
|
bench: deps ## Run all benchmarks (MemoryFS + DiskFS variants, including all eviction strategies)
|
|
@echo "Running MemoryFS benchmarks..."
|
|
@go test -bench=. -benchmem -run=^$ -benchtime=1s ./vfs/memory
|
|
@echo "Running DiskFS benchmarks..."
|
|
@go test -bench=. -benchmem -run=^$ -benchtime=1s ./vfs/disk
|
|
@echo "Bench done."
|
|
|
|
setcap: build ## Explicitly set cap_net_bind_service on the (just-built) binary for port 80 use outside validate targets
|
|
@echo "Setting cap_net_bind_service on the binary so it can listen on port 80 as your normal user..."
|
|
@sudo setcap 'cap_net_bind_service=+ep' dist/default_linux_amd64_v1/steamcache2
|
|
@echo "Done. You should now be able to run 'make run-validation' as your normal user (no root)."
|
|
|
|
validate run-validation: build clean-disk ## Start steamcache2 on :80 with small test caches (foreground)
|
|
@echo "=== Starting steamcache2 in validation mode ==="
|
|
@echo "Port 80 + small memory/disk caches (for exercising disk tier, GC, etc.)"
|
|
@echo "Press Ctrl-C to stop the server."
|
|
@echo ""
|
|
@BINARY=dist/default_linux_amd64_v1/steamcache2; \
|
|
if [ "$$(id -u)" -ne 0 ] && ! getcap "$$BINARY" 2>/dev/null | grep -q cap_net_bind_service; then \
|
|
echo "Setting cap_net_bind_service on the freshly built binary (sudo may prompt)..."; \
|
|
sudo setcap 'cap_net_bind_service=+ep' "$$BINARY" || { \
|
|
echo "ERROR: setcap failed (or was cancelled)."; \
|
|
echo "You can run 'make setcap' manually, then retry 'make validate'."; \
|
|
exit 1; \
|
|
}; \
|
|
fi; \
|
|
if [ "$$(id -u)" -ne 0 ] && ! getcap "$$BINARY" 2>/dev/null | grep -q cap_net_bind_service; then \
|
|
echo "ERROR: Port 80 still requires the capability after setcap attempt."; \
|
|
echo "Run 'make setcap' and retry."; \
|
|
exit 1; \
|
|
fi; \
|
|
exec "$$BINARY" --config docs/examples/validate-config.yaml --log-level info
|
|
|
|
validate-kill: ## Kill leftover steamcache2 processes (safer, checks process name)
|
|
@echo "Looking for steamcache2 processes on common validation ports (80 is primary)..."
|
|
@for port in 80 8040 8080; do \
|
|
pids=""; \
|
|
if command -v ss >/dev/null 2>&1; then \
|
|
pids=$$(ss -tlnp 2>/dev/null | grep ":$${port} " | sed -n 's/.*pid=\([0-9]*\).*/\1/p' | sort -u); \
|
|
fi; \
|
|
if [ -z "$$pids" ] && command -v lsof >/dev/null 2>&1; then \
|
|
pids=$$(lsof -ti :$${port} 2>/dev/null | sort -u); \
|
|
fi; \
|
|
for pid in $$pids; do \
|
|
proc=$$(ps -p $$pid -o comm= 2>/dev/null || true); \
|
|
cmd=$$(ps -p $$pid -o cmd= 2>/dev/null || true); \
|
|
if echo "$$proc $$cmd" | grep -qi "steamcache"; then \
|
|
echo " Killing steamcache2 (port $$port, PID $$pid, $$proc)"; \
|
|
kill -TERM $$pid 2>/dev/null || true; \
|
|
sleep 0.2; \
|
|
kill -0 $$pid 2>/dev/null && kill -9 $$pid 2>/dev/null || true; \
|
|
else \
|
|
echo " Skipping PID $$pid on port $$port (not steamcache2: $$proc)"; \
|
|
fi; \
|
|
done; \
|
|
done
|
|
@echo "Validation server cleanup complete."
|
|
|
|
prefill: ## Download latest SteamPrefill into bin/steam-prefill/SteamPrefill (gitignored)
|
|
@./scripts/download-prefill.sh
|
|
|
|
|
|
|
|
|
|
|
|
help: ## Show this help message
|
|
@echo "steamcache2 Makefile"
|
|
@echo "Available targets:"
|
|
@echo " run Run the application (cross-platform via go run)"
|
|
@echo " run-debug Run the application with debug logging (cross-platform)"
|
|
@echo " build Build the application (goreleaser snapshot)"
|
|
@echo " test Run all tests"
|
|
@echo " test-race Run all tests with the race detector"
|
|
@echo " lint Run golangci-lint + review label check"
|
|
@echo " check-review-labels Fail on temporary review labels (P*, T*, I*, R*, etc.)"
|
|
@echo " deps Download dependencies"
|
|
@echo " clean Remove build/test artifacts"
|
|
@echo " clean-disk Remove disk cache"
|
|
@echo " bench Run low-level VFS microbenchmarks"
|
|
@echo " validate / run-validation Start server on :80 (builds, auto-setcaps fresh binary, then runs as normal user, cleans disk cache first)"
|
|
@echo " setcap Explicitly set cap on current build (for port 80 use outside validate)"
|
|
@echo " validate-kill Kill leftover steamcache2 processes (safer)"
|
|
@echo " prefill Download latest SteamPrefill into bin/steam-prefill/SteamPrefill (gitignored)"
|