-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (91 loc) · 2.63 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
PACKAGE_NAME := github.com/PlanktoScope/forklift
GOLANG_CROSS_VERSION ?= v1.23.0
.DEFAULT_GOAL := dev
.PHONY: dev
dev: ## dev build
dev: clean install generate vet fmt spell lint test mod-tidy
.PHONY: ci
ci: ## CI build
ci: dev diff
.PHONY: clean
clean: ## remove files created during build pipeline
$(call print-target)
rm -rf dist
rm -f coverage.*
.PHONY: install
install: ## go install tools
$(call print-target)
cd tools && go install $(shell cd tools && go list -e -f '{{ join .Imports " " }}' -tags=tools)
.PHONY: generate
generate: ## go generate
$(call print-target)
go generate ./...
.PHONY: vet
vet: ## go vet
$(call print-target)
go vet ./...
.PHONY: fmt
fmt: ## go fmt
$(call print-target)
go fmt ./...
.PHONY: spell
spell: ##misspell
$(call print-target)
misspell -error -locale=US -w **.md
.PHONY: lint
lint: ## golangci-lint
$(call print-target)
golangci-lint run
.PHONY: test
test: ## go test with race detector and code covarage
$(call print-target)
go test -race -covermode=atomic -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
.PHONY: mod-tidy
mod-tidy: ## go mod tidy
$(call print-target)
go mod tidy
cd tools && go mod tidy
.PHONY: diff
diff: ## git diff
$(call print-target)
git diff --exit-code
RES=$$(git status --porcelain) ; if [ -n "$$RES" ]; then echo $$RES && exit 1 ; fi
.PHONY: build
build: ## Use goreleaser-cross (due to macOS CGo requirement) to run goreleaser --snapshot --skip=publish --clean
build: install
$(call print-target)
# goreleaser --snapshot --skip=publish --clean
docker run \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --snapshot --skip publish --clean
.PHONY: release
release: ## Use goreleaser-cross (due to macOS CGo requirement) to run goreleaser --clean
release: install
$(call print-target)
# goreleaser --clean
docker run \
--rm \
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean
.PHONY: run
run: ## go run
@go run -race ./cmd/forklift
.PHONY: go-clean
go-clean: ## go clean build, test and modules caches
$(call print-target)
go clean -r -i -cache -testcache -modcache
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef