-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (70 loc) · 3.04 KB
/
Copy pathMakefile
File metadata and controls
91 lines (70 loc) · 3.04 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
.DEFAULT_GOAL := help
.PHONY: build run test clean docker-build docker-run help lint verify-deps coverage check
# Variables
BINARY_NAME=inboundparse
DOCKER_IMAGE=inboundparse:latest
GOBIN := $(shell go env GOPATH)/bin
# govulncheck must load packages with the same Go version as go.mod; otherwise
# the loader can fail (e.g. internal error: x/sys/unix "without types").
GOTOOLCHAIN_GO := go$(shell awk '/^go /{print $$2; exit}' go.mod)
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}'
build: ## Build the binary
@echo "Building $(BINARY_NAME)..."
go build -o $(BINARY_NAME) ./cmd/inboundparse
deps: ## Download dependencies
@echo "Downloading dependencies..."
go mod tidy
go mod download
run-dev: build ## Run with non-privileged port
@echo "Starting inboundparse server on port 2525..."
@echo "Webhook URL: $${WEBHOOK_URL:-http://localhost:8080/webhook}"
./$(BINARY_NAME) -listen=:2525
test: ## Run tests
@echo "Running tests..."
go test -v ./...
clean: ## Clean build artifacts
@echo "Cleaning build artifacts..."
rm -f $(BINARY_NAME)
go clean
docker-build: ## Build Docker image
@echo "Building Docker image..."
docker build -t $(DOCKER_IMAGE) .
up: ## Start the docker containers
@echo "Starting the docker containers"
@docker compose -f docker-compose.dev.yml up --build --detach
down: ## Stop the docker containers
@echo "Stopping the docker containers"
@docker compose -f docker-compose.dev.yml down
dev: down up ## Restart the docker containers
status: ## Show service status
@echo "Checking service status..."
@docker-compose ps 2>/dev/null || echo "Docker Compose not running"
@ps aux | grep $(BINARY_NAME) | grep -v grep || echo "Binary not running"
ci: ## Run CI workflow
gh act push -W .github/workflows/ci.yml
format: ## Format the code
@echo "Running golangci-lint..."
@command -v $(GOBIN)/golangci-lint >/dev/null 2>&1 || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
@$(GOBIN)/golangci-lint fmt
vet: ## Vet the code
@echo "Vetting code..."
go vet ./...
lint: ## Lint (golangci-lint) + vuln scan (govulncheck)
@echo "Running golangci-lint..."
@command -v $(GOBIN)/golangci-lint >/dev/null 2>&1 || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
@$(GOBIN)/golangci-lint run --fix --timeout=5m
@echo "Running govulncheck ($(GOTOOLCHAIN_GO))..."
@GOTOOLCHAIN=$(GOTOOLCHAIN_GO) go install golang.org/x/vuln/cmd/govulncheck@latest
@GOTOOLCHAIN=$(GOTOOLCHAIN_GO) $(GOBIN)/govulncheck ./...
fl: format lint vet ## Format, lint, and vet the code
verify-deps: ## Verify and report dependency status
@echo "Verifying dependencies..."
go mod verify
@echo "Outdated modules:"
@go list -u -m all | grep -v "^inboundparse " | grep -E "\[[^\]]*\]$$" || true
coverage: ## Run tests with coverage and print summary
@echo "Running tests with coverage..."
go test -covermode=atomic -coverpkg=./... -coverprofile=cover.out ./...
@go tool cover -func=cover.out | tail -n1
check: deps lint ## Run deps, linters, vulncheck