-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
35 lines (28 loc) · 890 Bytes
/
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
GOCMD = go
GOTEST = $(GOCMD) test
GOLANGCI_VERSION ?= v1.57.2
TOOLS_BIN := $(shell mkdir -p build/tools && realpath build/tools)
GOLANGCI = $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION)
$(GOLANGCI):
rm -f $(TOOLS_BIN)/golangci-lint*
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_VERSION)/install.sh | sh -s -- -b $(TOOLS_BIN) $(GOLANGCI_VERSION)
mv $(TOOLS_BIN)/golangci-lint $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION)
test:
$(GOTEST) ./...
validate: validate-lint validate-dirty ## Run validation checks.
validate-lint: $(GOLANGCI)
$(GOLANGCI) run
define go-install-tool
@[ -f $(1) ] || { \
set -e ;\
echo "Downloading $(2)" ;\
GOBIN=$(TOOLS_BIN) go install $(2) ;\
}
endef
validate-dirty:
ifneq ($(shell git status --porcelain --untracked-files=no),)
@echo worktree is dirty
@git --no-pager status
@git --no-pager diff
@exit 1
endif