-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (120 loc) · 4 KB
/
Makefile
File metadata and controls
148 lines (120 loc) · 4 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
139
140
141
142
143
144
145
146
147
148
##############################
# VARIABLES
##############################
# Load .env if exists (loaded first so defaults can override if not set)
-include .env
# Default values (can be overridden by .env or command line)
APP_NAME ?= bbrew
APP_VERSION ?= 0.0.1-local
CONTAINER_IMAGE_NAME ?= bbrew
BUILD_GOVERSION ?= 1.25
BUILD_GOOS ?= $(shell go env GOOS)
BUILD_GOARCH ?= $(shell go env GOARCH)
# Container runtime command
CONTAINER_RUN = podman run --rm -v $(PWD):/app:Z $(CONTAINER_IMAGE_NAME)
##############################
# HELP
##############################
.PHONY: help
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Available targets:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
.DEFAULT_GOAL := help
##############################
# CONTAINER
##############################
.PHONY: container-build-image
container-build-image: ## Build container image
@podman build -f Containerfile -t $(CONTAINER_IMAGE_NAME) .
.PHONY: container-build-force
container-build-force: ## Force rebuild container image (no cache)
@podman build --no-cache -f Containerfile -t $(CONTAINER_IMAGE_NAME) .
.PHONY: container-clean
container-clean: ## Remove container image
@podman rmi $(CONTAINER_IMAGE_NAME) 2>/dev/null || true
##############################
# RELEASE
##############################
.PHONY: release-snapshot
release-snapshot: container-build-image ## Build and release snapshot (testing)
@$(CONTAINER_RUN) goreleaser release --snapshot --clean
.PHONY: build-snapshot
build-snapshot: container-build-image ## Build snapshot without release
@$(CONTAINER_RUN) goreleaser build --snapshot --clean
##############################
# BUILD
##############################
.PHONY: build
build: container-build-image ## Build the application binary
@$(CONTAINER_RUN) env GOOS=$(BUILD_GOOS) GOARCH=$(BUILD_GOARCH) \
go build -o $(APP_NAME) ./cmd/$(APP_NAME)
.PHONY: build-local
build-local: ## Build locally without container (requires Go installed)
@go build -o $(APP_NAME) ./cmd/$(APP_NAME)
.PHONY: run
run: build ## Build and run the application
@./$(APP_NAME)
.PHONY: clean
clean: ## Clean build artifacts
@rm -f $(APP_NAME)
@rm -rf dist/
##############################
# QUALITY
##############################
.PHONY: quality
quality: container-build-image ## Run linter checks
@$(CONTAINER_RUN) golangci-lint run
.PHONY: quality-local
quality-local: ## Run linter locally (requires golangci-lint installed)
@golangci-lint run
.PHONY: test
test: ## Run tests
@go test -v ./...
.PHONY: test-coverage
test-coverage: ## Run tests with coverage
@go test -v -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
##############################
# SECURITY
##############################
.PHONY: security
security: security-vuln security-scan ## Run all security checks
.PHONY: security-vuln
security-vuln: container-build-image ## Check for known vulnerabilities
@$(CONTAINER_RUN) govulncheck ./...
.PHONY: security-vuln-local
security-vuln-local: ## Check vulnerabilities locally (requires govulncheck)
@govulncheck ./...
.PHONY: security-scan
security-scan: container-build-image ## Run security scanner
@$(CONTAINER_RUN) gosec ./...
.PHONY: security-scan-local
security-scan-local: ## Run security scanner locally (requires gosec)
@gosec ./...
##############################
# WEBSITE
##############################
.PHONY: build-site
build-site: ## Build the static website
@node build.js
.PHONY: serve-site
serve-site: ## Serve the website locally
@npx http-server docs -p 3000
.PHONY: dev-site
dev-site: build-site serve-site ## Build and serve the website
##############################
# UTILITY
##############################
.PHONY: install
install: build-local ## Install binary to $GOPATH/bin
@go install ./cmd/$(APP_NAME)
.PHONY: deps
deps: ## Download and tidy dependencies
@go mod download
@go mod tidy
.PHONY: deps-update
deps-update: ## Update all dependencies
@go get -u ./...
@go mod tidy