-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (114 loc) · 3.95 KB
/
Makefile
File metadata and controls
138 lines (114 loc) · 3.95 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
# Chisel Makefile
.PHONY: build test test-integration clean fmt lint install dev docs
# Build variables
BINARY_NAME=forge
BUILD_DIR=bin
DOCS_DIR=docs
VERSION?=$(shell git describe --tags --always --dirty)
LDFLAGS=-ldflags "-X main.version=${VERSION}"
# Go variables
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
# Default target
all: test docs build
# Generate documentation
docs:
@echo "Generating documentation..."
@mkdir -p $(DOCS_DIR)
@$(GOCMD) run scripts/generate-docs.go $(DOCS_DIR)/
@echo "Documentation generated in $(DOCS_DIR)/"
# Build the binary
build: docs
mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/forge
# Development build (faster, no docs)
dev-build:
mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/forge
# Run tests
test:
$(GOTEST) -v -race -coverprofile=coverage.out ./...
# Run integration tests
test-integration:
$(GOTEST) -v -tags=integration ./tests/integration/...
# Clean build artifacts
clean:
$(GOCLEAN)
rm -rf $(BUILD_DIR)
rm -rf $(DOCS_DIR)
rm -f coverage.out
# Format code
fmt:
$(GOCMD) fmt ./...
# Lint code
lint:
golangci-lint run
# Install dependencies
deps:
$(GOMOD) download
$(GOMOD) tidy
# Install binary to GOPATH/bin
install: build
cp $(BUILD_DIR)/$(BINARY_NAME) $(GOPATH)/bin/
# Development mode - watch for changes and rebuild
dev:
@echo "Starting development mode..."
@which air > /dev/null || (echo "Installing air..." && go install github.com/cosmtrek/air@latest)
air
# Generate code coverage report
coverage: test
$(GOCMD) tool cover -html=coverage.out -o coverage.html
# Run benchmarks
bench:
$(GOTEST) -bench=. -benchmem ./...
# Security scan
security:
@which gosec > /dev/null || (echo "Installing gosec..." && go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest)
gosec ./...
# Check for vulnerabilities
vuln:
@which govulncheck > /dev/null || (echo "Installing govulncheck..." && go install golang.org/x/vuln/cmd/govulncheck@latest)
govulncheck ./...
# Release build for multiple platforms
release: docs
mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/forge
GOOS=linux GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./cmd/forge
GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/forge
GOOS=darwin GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/forge
GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./cmd/forge
# Docker build
docker:
docker build -t forge:$(VERSION) .
# Run examples
example-simple: dev-build
./$(BUILD_DIR)/$(BINARY_NAME) plan --module examples/simple-file/module.yaml
example-user: dev-build
./$(BUILD_DIR)/$(BINARY_NAME) plan --module examples/user-management/module.yaml
# Help
help:
@echo "Available targets:"
@echo " build - Build the binary with documentation"
@echo " dev-build - Fast development build (no docs)"
@echo " docs - Generate documentation only"
@echo " test - Run unit tests"
@echo " test-integration - Run integration tests"
@echo " clean - Clean build artifacts"
@echo " fmt - Format code"
@echo " lint - Lint code"
@echo " deps - Install dependencies"
@echo " install - Install binary to GOPATH/bin"
@echo " dev - Development mode with hot reload"
@echo " coverage - Generate coverage report"
@echo " bench - Run benchmarks"
@echo " security - Run security scan"
@echo " vuln - Check for vulnerabilities"
@echo " release - Build for multiple platforms"
@echo " docker - Build Docker image"
@echo " example-simple - Run simple file example"
@echo " example-user - Run user management example"
@echo " help - Show this help"