-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
54 lines (46 loc) · 1.27 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
GO ?= go
BIN := bin
GOOS ?= $(shell uname | tr A-Z a-z)
GOLANGCI_LINT_VERSION = v1.60.3
PROJECT := package-feeds
.PHONY: help
help: ## Display this help
@awk \
-v "col=${COLOR}" -v "nocol=${NOCOLOR}" \
' \
BEGIN { \
FS = ":.*##" ; \
printf "Available targets:\n"; \
} \
/^[a-zA-Z0-9_-]+:.*?##/ { \
printf " %s%-25s%s %s\n", col, $$1, nocol, $$2 \
} \
/^##@/ { \
printf "\n%s%s%s\n", col, substr($$0, 5), nocol \
} \
' $(MAKEFILE_LIST)
.PHONY: build
build:
mkdir -p $(BIN)/$(PROJECT) && \
env CGO_ENABLED=0 GOOS=$(GOOS) go build -o $(BIN)/$(PROJECT) -a ./...
.PHONY: clean
clean: ## Clean the build directory
rm -rf $(BIN)
.PHONY: go-mod
go-mod: ## Cleanup and verify go modules
$(GO) mod tidy && $(GO) mod verify
# Verification targets
.PHONY: verify
verify: verify-go-mod verify-go-lint ## Run all verification targets
.PHONY: verify-go-mod
verify-go-mod: go-mod ## Verify the go modules
./hacks/tree-status
.PHONY: verify-go-lint
verify-go-lint: golangci-lint ## Verify the golang code by linting
$(BIN)/golangci-lint run -c ./.golangci.yml
golangci-lint:
export \
VERSION=$(GOLANGCI_LINT_VERSION) \
URL=https://raw.githubusercontent.com/golangci/golangci-lint \
BINDIR=$(BIN) && \
curl -sfL $$URL/$$VERSION/install.sh | sh -s $$VERSION