-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (67 loc) · 2.1 KB
/
Makefile
File metadata and controls
79 lines (67 loc) · 2.1 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
.PHONY: all build test lint clean docker-build help snapshot release run cover
# Project Variables
BINARY_NAME=scanner-cli
CMD_PATH=./cmd/scanner-cli
DOCKER_IMAGE=evm-scanner:latest
# Default Target
all: build
# Print Help Information
help:
@echo "Available commands:"
@echo " make build - Build the scanner-cli binary to bin/"
@echo " make test - Run all unit tests with coverage"
@echo " make cover - Show core logic coverage (excluding examples)"
@echo " make lint - Run golangci-lint"
@echo " make clean - Remove binaries, temp files, and artifacts"
@echo " make docker-build - Build the Docker image"
@echo " make run - Run the scanner (requires config.yaml/app.yaml)"
@echo " make snapshot - Test build with goreleaser (local)"
@echo " make release - Build and release with goreleaser"
# Build Binary
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p bin
go build -o bin/$(BINARY_NAME) $(CMD_PATH)
@echo "Done! Binary is at bin/$(BINARY_NAME)"
# Run Tests
test:
@echo "Running tests..."
go test -v -cover ./...
# Coverage Report (Excluding examples)
cover:
@echo "Calculating core coverage..."
go test -coverprofile=coverage.out $$(go list ./... | grep -v "examples/" | grep -v "cmd/example")
go tool cover -func=coverage.out
@rm coverage.out
# Lint Code (requires golangci-lint)
lint:
@echo "Running linter..."
@if command -v golangci-lint >/dev/null; then \
golangci-lint run; \
else \
echo "golangci-lint not installed. Skipping."; \
fi
# Clean Build Artifacts
clean:
@echo "Cleaning up..."
rm -rf bin/
rm -rf data/
rm -f coverage.out
rm -f scanner-cli
@echo "Cleaned."
# Docker Build
docker-build:
@echo "Building Docker image $(DOCKER_IMAGE)..."
docker build -t $(DOCKER_IMAGE) .
# GoReleaser Local Test
snapshot:
@echo "Running goreleaser snapshot..."
goreleaser release --snapshot --clean --skip=publish
# GoReleaser Release (typically run in CI)
release:
@echo "Running goreleaser release..."
goreleaser release --clean
# Local Run (for development)
run: build
@echo "Starting scanner..."
./bin/$(BINARY_NAME)