forked from devstream-io/devstream
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
56 lines (44 loc) · 1.59 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
DTM_ROOT=github.com/devstream-io/devstream
SELF_DIR=$(dir $(lastword $(MAKEFILE_LIST)))
GOOS=$(shell go env GOOS)
GOPATH=$(shell go env GOPATH)
GOARCH=$(shell go env GOARCH)
# COLORS
RED = $(shell printf "\33[31m")
GREEN = $(shell printf "\33[32m")
WHITE = $(shell printf "\33[37m")
YELLOW = $(shell printf "\33[33m")
RESET = $(shell printf "\33[0m")
ifeq ($(origin ROOT_DIR),undefined)
ROOT_DIR := $(abspath $(shell cd $(SELF_DIR) && pwd -P))
endif
FIND := find . -path './cmd/*.go' -o -path './internal/pkg/*.go'
.PHONY: build
build: fmt vet mod-tidy ## Build dtm core only, without plugins, locally.
go build -trimpath -o dtm .
@echo "${GREEN}✔'dtm' has been generated in the current directory($(PWD))!${RESET}"
.PHONY: fmt
fmt: verify.goimports ## Run 'go fmt' & goimports against code.
@echo "$(YELLOW)Formating codes$(RESET)"
@$(FIND) -type f | xargs gofmt -s -w
@$(FIND) -type f | xargs ${GOPATH}/bin/goimports -w -local $(DTM_ROOT)
@go mod edit -fmt
#.PHONY: lint
#lint: verify.golangcilint ## Run 'golangci-lint' against code.
# @echo "$(YELLOW)Run golangci to lint source codes$(RESET)"
# @${GOPATH}/bin/golangci-lint -c $(ROOT_DIR)/.golangci.yml run $(ROOT_DIR)/...
.PHONY: vet
vet: ## Run "go vet ./...".
go vet ./...
.PHONY: mod-tidy
mod-tidy: ## Run "go mod tidy".
go mod tidy
.PHONY: verify.%
verify.%:
@if ! command -v $* >/dev/null 2>&1; then $(MAKE) install.$*; fi
.PHONY: install.goimports
install.goimports:
@go install golang.org/x/tools/cmd/goimports@latest
.PHONY: install.golangcilint
install.golangcilint:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest