-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
94 lines (69 loc) · 2.36 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
.PHONY: all build clean fmt test lint vendor install
## overridable Makefile variables
# test to run
TESTSET = .
# benchmarks to run
BENCHSET ?= .
# version (defaults to short git hash)
VERSION ?= $(shell git rev-parse --short HEAD)
# use correct sed for platform
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SED := gsed
else
SED := sed
endif
PKG_NAME=github.com/Octops/agones-event-broadcaster
LDFLAGS := -X "${PKG_NAME}/internal/version.Version=${VERSION}"
LDFLAGS += -X "${PKG_NAME}/internal/version.BuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "${PKG_NAME}/internal/version.GitCommit=$(shell git rev-parse HEAD)"
LDFLAGS += -X "${PKG_NAME}/internal/version.GitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
GO := GO111MODULE=on GOPRIVATE=github.com/Octops GOSUMDB=off go
GOBUILD := CGO_ENABLED=0 $(GO) build $(BUILD_FLAG)
GOTEST := $(GO) test -gcflags='-l' -p 3
CURRENT_DIR := $(shell pwd)
FILES := $(shell find internal cmd -name '*.go' -type f -not -name '*.pb.go' -not -name '*_generated.go' -not -name '*_test.go')
TESTS := $(shell find internal cmd -name '*.go' -type f -not -name '*.pb.go' -not -name '*_generated.go' -name '*_test.go')
BROADCASTER_BIN := bin/broadcaster-http
DOCKER_IMAGE_TAG ?= octops/agones-broadcaster-http:v0.2.0-alpha
default: clean build
build: clean $(BROADCASTER_BIN)
$(BROADCASTER_BIN):
CGO_ENABLED=0 GOOS=linux go build -ldflags '$(LDFLAGS)' -a -installsuffix cgo -o $(BROADCASTER_BIN) .
dist:
CGO_ENABLED=0 GOOS=linux go build -ldflags '$(LDFLAGS)' -a -installsuffix cgo -o $(BROADCASTER_BIN) .
CGO_ENABLED=0 GOOS=darwin go build -ldflags '$(LDFLAGS)' -a -installsuffix cgo -o $(BROADCASTER_BIN)-darwin .
clean:
rm -f $(BROADCASTER_BIN)*
get:
$(GO) get ./...
$(GO) mod verify
$(GO) mod tidy
update:
$(GO) get -u -v all
$(GO) mod verify
$(GO) mod tidy
fmt:
gofmt -s -l -w $(FILES) $(TESTS)
lint:
golangci-lint run
test:
$(GOTEST) -run=$(TESTSET) ./...
@echo
@echo Configured tests ran ok.
test-strict:
$(GO) test -p 3 -run=$(TESTSET) -gcflags='-l -m' -race ./...
@echo
@echo Configured tests ran ok.
bench:
DEBUG=0 $(GOTEST) -run=nothing -bench=$(BENCHSET) -benchmem ./...
@echo
@echo Configured benchmarks ran ok.
vendor:
$(GO) mod vendor
docker:
docker build -t $(DOCKER_IMAGE_TAG) .
push: docker
docker push $(DOCKER_IMAGE_TAG)
install:
kubectl apply -f install/install.yaml