-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (61 loc) · 2.21 KB
/
Makefile
File metadata and controls
78 lines (61 loc) · 2.21 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
.PHONY: build test clean install run help
# Build variables
BINARY_NAME=secret-hunter
BINARY_DIR=bin
GO_FILES=$(shell find . -name '*.go' -type f)
VERSION?=1.0.0
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
build: ## Build the binary
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BINARY_DIR)
@go build -ldflags="-X main.version=$(VERSION)" -o $(BINARY_DIR)/$(BINARY_NAME) ./cmd/secret-hunter
@echo "Build complete: $(BINARY_DIR)/$(BINARY_NAME)"
test: ## Run tests
@echo "Running tests..."
@go test -v ./...
test-coverage: ## Run tests with coverage
@echo "Running tests with coverage..."
@go test -v -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
clean: ## Clean build artifacts
@echo "Cleaning..."
@rm -rf $(BINARY_DIR)
@rm -f coverage.out coverage.html
@rm -f *.sarif secrets-report.*
@echo "Clean complete"
install: build ## Install the binary to GOPATH/bin
@echo "Installing $(BINARY_NAME)..."
@go install ./cmd/secret-hunter
@echo "Install complete"
run: build ## Build and run with default settings
@echo "Running $(BINARY_NAME)..."
@./$(BINARY_DIR)/$(BINARY_NAME)
run-test: build ## Run on test data
@echo "Running on test data..."
@./$(BINARY_DIR)/$(BINARY_NAME) --paths=test-data --verbose
lint: ## Run linters
@echo "Running linters..."
@which golangci-lint > /dev/null 2>&1 || (echo "golangci-lint not installed. Run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
@golangci-lint run ./...
fmt: ## Format code
@echo "Formatting code..."
@go fmt ./...
@gofmt -s -w .
vet: ## Run go vet
@echo "Running go vet..."
@go vet ./...
deps: ## Download dependencies
@echo "Downloading dependencies..."
@go mod download
@go mod tidy
generate-config: build ## Generate example config
@echo "Generating config..."
@./$(BINARY_DIR)/$(BINARY_NAME) --generate-config=example-config.yaml
check: fmt vet test ## Run formatting, vetting, and tests
all: clean deps check build ## Clean, get deps, run checks, and build
.DEFAULT_GOAL := help