-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (38 loc) · 1.45 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
.PHONY: clean run build install dep test lint format docker
# Set the bin path
PATHINSTBIN = $(abspath ./bin)
export PATH := $(PATHINSTBIN):$(PATH)
BIN_NAME ?= migration
DEFAULT_INSTALL_DIR := $(go env GOPATH)/bin
DEFAULT_ARCH := $(shell go env GOARCH)
DEFAULT_GOOS := $(shell go env GOOS)
ARCH ?= $(DEFAULT_ARCH)
GOOS ?= $(DEFAULT_GOOS)
INSTALL_DIR ?= $(DEFAULT_INSTALL_DIR)
.DEFAULT_GOAL := run
VERSION := $(shell git describe --tags || echo "v0.0.0")
VER_CUT := $(shell echo $(VERSION) | cut -c2-)
# Dependency versions
GOLANGCI_VERSION = latest
help:
@echo "\nSpecify a subcommand:\n"
@grep -hE '^[0-9a-zA-Z_-]+:.*?## .*$$' ${MAKEFILE_LIST} | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[0;36m%-20s\033[m %s\n", $$1, $$2}'
@echo ""
build: ## Build the migration binary
@CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH) \
go build -o $(PATHINSTBIN)/$(BIN_NAME) ./cmd/$(BIN_NAME)
all: clean target
clean: ## Clean the project binaries
@rm -rf $(PATHINSTBIN)
tidy: ## tidy the go modules
@go mod tidy
test: ## Run the all tests
@go test ./...
lint: ## Run the linter
@golangci-lint run --timeout 5m
format: ## Run the linter with fix
@golangci-lint run --fix
tools-golangci-lint: ## Install golangci-lint
@mkdir -p $(PATHINSTBIN)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | BINARY=golangci-lint bash -s -- ${GOLANGCI_VERSION}
tools: tools-golangci-lint ## Install all tools