-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
76 lines (59 loc) · 1.55 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
.PHONY: none
none:
deps: go.mod
@echo "+ $@"
@go mod tidy
ifdef CI
@git diff --exit-code -- go.mod go.sum || { echo "go.mod/go.sum files were updated after running 'go mod tidy', run this command on your local machine and commit the results." ; exit 1 ; }
endif
go mod verify
@touch deps
GOBIN := $(CURDIR)/.gobin
PATH := $(GOBIN):$(PATH)
# Makefile on Mac doesn't pass the updated PATH and GOBIN to the shell
# and so, without the following line, the shell does not end up
# trying commands in $(GOBIN) first.
# See https://stackoverflow.com/a/36226784/3690207
SHELL := env GOBIN=$(GOBIN) PATH=$(PATH) /bin/bash
########################################
###### Binaries we depend on ###########
########################################
GOLANGCILINT_BIN := $(GOBIN)/golangci-lint
$(GOLANGCILINT_BIN): deps
@echo "+ $@"
cd tool-imports; \
GOBIN=$(GOBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint
###########
## Lint ##
###########
.PHONY: golangci-lint
golangci-lint: $(GOLANGCILINT_BIN)
ifdef CI
@echo '+ $@'
@echo 'The environment indicates we are in CI; running linters in check mode.'
@echo 'If this fails, run `make lint`.'
golangci-lint run
else
golangci-lint run --fix
endif
.PHONY: lint
lint: golangci-lint
####################
## Code generation #
####################
.PHONY: go-generated-srcs
go-generated-srcs: deps
go generate ./...
.PHONY: generated-srcs
generated-srcs: go-generated-srcs
#############
## Compile ##
#############
.PHONY: build
build:
##########
## Test ##
##########
.PHONY: test
test:
go test ./...