ring/scripts/codereview/Makefile
Fred Amaral 6af7444a47
refactor(codereview): simplify build system with pattern rules
Replace 7 repetitive Makefile targets with single pattern rule. Refactor install.sh to use shared BINARIES array, subshells for directory safety, and --user flag for pip. Update tool versions: staticcheck 2024.1.1, gosec v2.22.0, golangci-lint v1.63.4.

X-Lerian-Ref: 0x1
2026-01-14 15:13:28 -03:00

56 lines
1.3 KiB
Makefile

.PHONY: all build test test-coverage clean install fmt vet golangci-lint lint \
scope-detector static-analysis ast-extractor call-graph data-flow compile-context run-all \
build-context
# Binary output directory
BIN_DIR := bin
# All binaries to build
BINARIES := scope-detector static-analysis ast-extractor call-graph data-flow compile-context run-all
all: build
build: $(BINARIES)
# Pattern rule for building all phase binaries
# Replaces individual targets with identical echo/mkdir/go-build pattern
$(BINARIES):
@echo "Building $@..."
@mkdir -p $(BIN_DIR)
@go build -o $(BIN_DIR)/$@ ./cmd/$@
# Convenience target for Phase 5 binaries only
build-context: compile-context run-all
@echo "Context binaries built."
test:
@echo "Running tests..."
@go test -v -race ./...
test-coverage:
@echo "Running tests with coverage..."
@go test -v -race -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
clean:
@echo "Cleaning..."
@rm -rf $(BIN_DIR)
@rm -f coverage.out coverage.html
install: build
@echo "Installing binaries to $(BIN_DIR)..."
@chmod +x $(BIN_DIR)/*
# Development helpers
fmt:
@go fmt ./...
vet:
@go vet ./...
golangci-lint:
@echo "Running golangci-lint..."
@golangci-lint run ./...
lint: fmt vet golangci-lint