-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
59 lines (45 loc) · 1.69 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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTOOL=$(GOCMD) tool
GOTEST=$(GOCMD) test
GOTESTRACE=$(GOTEST) -race
GOGET=$(GOCMD) get
GOFMT=$(GOCMD)fmt
BINARY_NAME=statusbay
BINARY_LINUX=$(BINARY_NAME)_linux
DOCKER=docker
DOCKER_IMAGE=statusbay
DOCKER_UI_IMAGE=statusbay-ui
DOCKER_TAG=dev
all: build
build: ## Download dependecies and Build the default binary
$(GOBUILD) -o $(BINARY_NAME) -v
test: ## Run tests for the project
$(GOTEST) -count=1 -coverprofile=cover.out -short -cover -failfast ./...
test-race: ## Run tests for the project (while detecting race conditions)
$(GOTESTRACE) -coverprofile=cover.out -short -cover -failfast ./...
test-html: test ## Run tests with HTML for the project
$(GOTOOL) cover -html=cover.out
build-linux: ## Build Cross Platform Binary
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_LINUX) -v
build-docker: ## Build Docker image file
$(DOCKER) build -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
cd ui/ && $(DOCKER) build -t $(DOCKER_UI_IMAGE):$(DOCKER_TAG) .
gofmt: ## gofmt code formating
@echo Running go formating with the following command:
$(GOFMT) -e -s -w .
fmt-validator: ## Validate go format
@echo checking gofmt...
@res=$$($(GOFMT) -d -e -s $$(find . -type d \( -path ./src/vendor \) -prune -o -name '*.go' -print)); \
if [ -n "$${res}" ]; then \
echo checking gofmt fail... ; \
echo "$${res}"; \
exit 1; \
else \
echo Your code formating is according gofmt standards; \
fi
checks-validator: fmt-validator ## Run all Statusbay validations
help: ## Show Help menu
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'