-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
101 lines (79 loc) · 2.71 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
# Install tools locally instead of in $HOME/go/bin.
export GOBIN := $(CURDIR)/bin
export PATH := $(GOBIN):$(PATH)
export RELEASE_VERSION ?= $(shell git describe --always)
export DEPLOY ?= goer
COMPILEDAEMON = $(GOBIN)/CompileDaemon
GIT = git
GOER = $(GOBIN)/goer
GOLANGCI_LINT = $(GOBIN)/golangci-lint
GOVVV = $(GOBIN)/govvv
MOCKGEN = $(GOBIN)/mockgen
PIGEON = $(GOBIN)/pigeon
GOLANGCI_LINT_VERSION := v1.53.3
GOLANGCI_LINT_INSTALLATION_SHA256 := 060f1f3deb31b3d3b9515d691d9a776354cd63c7fcb5e036f18f0444cf2c934b
GOLANGCI_LINT_BINARY_SHA256 := 09237052ea9582630019182e890288ec155567fc949e6f329e3beb2c6e76b1b5
.PHONY: all
all: test build start
.PHONY: gen-deps
gen-deps: $(MOCKGEN) $(PIGEON)
.PHONY: gen
gen: gen-deps
go generate ./...
.PHONY: build
build: gen $(GOVVV)
$(GOVVV) build -o $(GOER) ./cmd/goer
.PHONY: clean
clean:
$(RM) $(GOER) $(GOVVV) $(MOCKGEN) $(PIGEON)
docker-compose --project-directory . -f deploy/$(DEPLOY)/docker-compose.yml rm || true
docker volume rm goer-volume || true
.PHONY: check
check: staticcheck test
.PHONY: staticcheck
staticcheck: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run
.PHONY: test
test: gen
go test -cover -timeout 30s -race $(shell go list ./... | grep -v test)
# Start a development docker with a database that restarts on file changes.
.PHONY: start
start: $(COMPILEDAEMON) gen-deps
docker-compose --project-directory . -f deploy/$(DEPLOY)/docker-compose.yml up
.PHONY: stop
stop:
docker-compose --project-directory . -f deploy/$(DEPLOY)/docker-compose.yml down
# Build a docker using the production Dockerfile
.PHONY: docker
docker:
docker build --build-arg revision=$(RELEASE_VERSION) -t eiffel-goer -f ./deploy/$(DEPLOY)/Dockerfile .
.PHONY: tidy
tidy:
go mod tidy
.PHONY: check-dirty
check-dirty:
$(GIT) diff --exit-code HEAD
# Build dependencies
$(COMPILEDAEMON):
mkdir -p $(dir $@)
go install github.com/githubnemo/[email protected]
# Download the installation script for golangci-lint, verify its SHA-256 digest,
# run it if everything checks out, and verify the resulting binary.
$(GOLANGCI_LINT):
mkdir -p $(dir $@)
curl -sSfL \
https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_LINT_VERSION)/install.sh \
echo "$(GOLANGCI_LINT_INSTALLATION_SHA256) [email protected]" | sha256sum -c --quiet -
sh -s -- -b $(dir $@) $(GOLANGCI_LINT_VERSION) < [email protected]
rm -f [email protected]
echo "$(GOLANGCI_LINT_BINARY_SHA256) $@" | sha256sum -c --quiet - || ( rm $@ ; exit 1 )
$(GOVVV):
mkdir -p $(dir $@)
go install github.com/ahmetb/[email protected]
$(MOCKGEN):
mkdir -p $(dir $@)
go install github.com/golang/mock/[email protected]
$(PIGEON):
mkdir -p $(dir $@)
go install github.com/mna/[email protected]