-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (59 loc) · 1.55 KB
/
Makefile
File metadata and controls
73 lines (59 loc) · 1.55 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
# Go variables
GOCMD=go
GOBUILD=go build
GOCLEAN=go clean
GOLINT=golangci-lint run
GOFMT=gofmt
GOTEST=go test
GOMOD=go mod
GORUN=go run
GOVET=go vet
# Project variables
BINARY_NAME=topic
MODULE_PATH=./pkg/
OUTPUT_DIR=./dist
# Default target executed when running `make`.
.DEFAULT_GOAL := help
build:
@echo "Building application..."
@mkdir -p $(OUTPUT_DIR)
(cd $(MODULE_PATH) && CGO_ENABLED=0 $(GOBUILD) -v -ldflags="-s -w" -o ../$(OUTPUT_DIR)/$(BINARY_NAME) .)
run:
@echo "Running application..."
(cd $(MODULE_PATH) && $(GORUN) .)
clean:
@echo "Cleaning up..."
@rm -rf $(OUTPUT_DIR)
$(GOCLEAN)
test:
@echo "Running tests..."
(cd $(MODULE_PATH) && $(GOTEST) -coverprofile=coverage.out ./...)
view-coverage:
@echo "==> Opening coverage report in browser..."
(cd $(MODULE_PATH) && go tool cover -html=coverage.out)
deps:
@echo "Tidying dependencies..."
(cd $(MODULE_PATH) && $(GOMOD) tidy)
(cd $(MODULE_PATH) && $(GOMOD) vendor)
format:
@echo "Formatting code..."
(cd $(MODULE_PATH) && $(GOFMT) -s -w ./)
lint:
@echo "Linting code..."
(cd $(MODULE_PATH) && $(GOLINT))
ci-check: format lint test
@echo "CI checks passed."
help:
@echo ""
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@echo " build Build the application binary"
@echo " run Run the application"
@echo " test Run all tests"
@echo " lint Lint the source code"
@echo " deps Tidy and vendor dependencies"
@echo " clean Remove build artifacts"
@echo " help Show this help message"
@echo ""
.PHONY: all build run clean test deps lint help