-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
74 lines (61 loc) · 2.05 KB
/
Makefile
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
GO ?= go
GOLANGCI_LINT ?= golangci-lint
BINARY_NAME=mongo-bench
.PHONY: all
all: build ## Builds the binary
.PHONY: build
build: test ## Builds the binary
@echo "🔹 Building binary ..."
$(GO) build -o $(BINARY_NAME) *.go
@echo "Build complete: $(BINARY_NAME)"
.PHONY: run
run: ## Runs the application with THREADS, DOCS, and URI variables
@echo "Running $(BINARY_NAME) with THREADS=$(THREADS), DOCS=$(DOCS), URI=$(URI)"
./$(BINARY_NAME) -threads $(THREADS) -docs $(DOCS) -uri $(URI)
.PHONY: clean
clean: ## Remove generated binary
@echo "🔹 Deleting go binary $(BINARY_NAME)"
@rm -rf $(BINARY_NAME)
@echo "✅ Environment cleaned!"
.PHONY: test
test: ## Run tests
@echo "🔹 Running tests ..."
$(GO) test -v ./...
@echo "✅ Tests OK!"
.PHONY: format
format: ## Format Go code
@echo "🔹 Formatting Go code..."
@$(GO) fmt ./...
@echo "✅ Code formatted!"
.PHONY: lint
lint: ## Run Go linter
@echo "🔹 Running linter..."
@command -v $(GOLANGCI_LINT) >/dev/null 2>&1 || { \
echo "⚠️ golangci-lint not found! Installing..."; \
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \
}
@$(GOLANGCI_LINT) run
@echo "✅ Linting complete!"
.PHONY: format-lint
format-lint: format lint ## Run format and lint checks
@echo "🎯 Formatting & Linting completed successfully!"
.PHONY: update
update: ## Update dependencies and tidy the go.mod file
@echo "Updating dependencies" \
&& go get -u ./... \
&& go mod tidy
.PHONY: run-compose
run-compose: ## Running integration tests
@echo "🔹 Starting integration tests with mongo in docker-compose ..."
@docker-compose up --build -d
@docker-compose logs -f mongo-bench
@docker-compose down
@echo "✅ Integration tests completed!"
reset: clean ## Reset the development environment
@echo "🔹 resetting dev environment"
@docker-compose down
@echo "✅ Environment cleaned!"
.PHONY: help
help:
@echo "📌 Available make targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "🎯 \033[36m%-20s\033[0m %s\n", $$1, $$2}'