-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (46 loc) · 1.28 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
DOCKER_REGISTRY ?= radixdev.azurecr.io
BINS = radix-github-webhook
IMAGES = radix-github-webhook
GIT_TAG = $(shell git describe --tags --always 2>/dev/null)
VERSION ?= ${GIT_TAG}
IMAGE_TAG ?= ${VERSION}
LDFLAGS += -s -w
CX_OSES = linux windows
CX_ARCHS = amd64
.PHONY: build
build: $(BINS)
.PHONY: test
test:
go test -cover `go list ./...`
.PHONY: lint
lint: bootstrap
golangci-lint run --max-same-issues 0
.PHONY: $(BINS)
$(BINS):
go build -ldflags '$(LDFLAGS)' -o bin/$@ .
.PHONY: docker-build
docker-build: $(addsuffix -image,$(IMAGES))
%-image:
docker build $(DOCKER_BUILD_FLAGS) -t $(DOCKER_REGISTRY)/$*:$(IMAGE_TAG) .
.PHONY: docker-push
docker-push: $(addsuffix -push,$(IMAGES))
%-push:
docker push $(DOCKER_REGISTRY)/$*:$(IMAGE_TAG)
.PHONY: mocks
mocks: bootstrap
mockgen -source ./radix/api_server.go -destination ./radix/api_server_mock.go -package radix
.PHONY: generate
generate: mocks
.PHONY: verify-generate
verify-generate: generate
git diff --exit-code
HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;)
HAS_MOCKGEN := $(shell command -v mockgen;)
.PHONY: bootstrap
bootstrap:
ifndef HAS_GOLANGCI_LINT
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.58.2
endif
ifndef HAS_MOCKGEN
go install github.com/golang/mock/mockgen@v1.6.0
endif