-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile
69 lines (54 loc) · 1.84 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
# General
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := help
BIN := $(CURDIR)/.bin
TOOLS := $(CURDIR)/tools
PATH := $(abspath $(BIN)):$(PATH)
UNAME_OS := $(shell uname -s)
UNAME_ARCH := $(shell uname -m)
$(BIN):
mkdir -p $(BIN)
.PHONY: os
os: ## show os name
@echo "$(UNAME_OS)"
.PHONY: help
help: ## print help
@grep -E '^[/a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# Go
.PHONY: mod
mod: ## download Go modules
go mod download
.PHONY: vendor
vendor: ## make go vendor
go mod vendor
.PHONY: test
test: ## run go test. If you need test options, pass them in like OPTIONS="-v"
go test ./... $(OPTIONS)
# Install golangci-lint
GOLANGCLI_LINT := $(BIN)/golangci-lint
GOLANGCLI_LINT_VERSION := v1.51.0
$(GOLANGCLI_LINT): | $(BIN) ## Install golangci-lint
@curl -sSfL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b $(BIN) $(GOLANGCLI_LINT_VERSION)
@chmod +x "$(BIN)/golangci-lint"
.PHONY: lint
lint: | $(GOLANGCLI_LINT) ## run golangci-lint with config .golangcli.yml
$(BIN)/golangci-lint run --verbose --config=.golangci.yml ./...
# Install gofumpt
# This setting is only available for Mac
GOFMPT := $(BIN)/gofumpt
GOFMPT_VERSION := v0.4.0
ifeq "$(UNAME_OS)" "Darwin"
GOFMPT_BIN=gofumpt_$(GOFMPT_VERSION)_darwin_amd64
endif
$(GOFMPT): | $(BIN) ## Install gofumpt
@curl -sSfL "https://github.com/mvdan/gofumpt/releases/download/$(GOFMPT_VERSION)/$(GOFMPT_BIN)" \
-o "$(BIN)/gofumpt"
@chmod +x "$(BIN)/gofumpt"
.PHONY: fmt
fmt: | $(GOFMPT) ## format files via gofumpt and list impacted files
@$(BIN)/gofumpt -l -w . ./legacy
.PHONY: generate
generate: ## generate go code (e.g. make generate OBJECT=Contact FILEPATH=contact.csv)
@cd $(TOOLS)/model_generator && go run model_gen.go $(OBJECT) $(FILEPATH)
$(MAKE) fmt