-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
72 lines (54 loc) · 2.21 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
# Makefile for releasing gate-keeper
#
# The release version is controlled from pkg/version
TAG?=latest
NAME:=gate-keeper
CLI_NAME:=gate-keeper-cli
DOCKER_REPOSITORY:=ivanvg
DOCKER_IMAGE_NAME:=$(DOCKER_REPOSITORY)/$(NAME)
GIT_COMMIT:=$(shell git describe --dirty --always)
VERSION:=$(shell grep "version = " pkg/version/version.go | awk '{ print $$4 }' | tr -d '"')
run:
GO111MODULE=on go run -ldflags "-s -w -X github.com/imorph/gate-keeper/pkg/version.revision=$(GIT_COMMIT)" cmd/gk/* --log-level=debug
test:
GO111MODULE=on go test -v -race ./...
bench:
GO111MODULE=on go test -bench=. ./pkg/core/... -benchmem
GO111MODULE=on go test -bench=. ./pkg/server/... -benchmem
docker-bench:
docker-compose up -d
docker exec gate-keeper_gk_1 gkcli simple-bench
docker-compose down
build:
GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-s -w -X github.com/imorph/gate-keeper/pkg/version.revision=$(GIT_COMMIT) -X github.com/imorph/gate-keeper/pkg/version.appname=$(NAME)" -a -o ./bin/gk ./cmd/gk/*
GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-s -w -X github.com/imorph/gate-keeper/pkg/version.revision=$(GIT_COMMIT) -X github.com/imorph/gate-keeper/pkg/version.appname=$(CLI_NAME)" -a -o ./bin/gkcli ./cmd/gkcli/*
release: build-container push-container
git tag $(VERSION)
git push origin $(VERSION)
goreleaser --rm-dist
fmt:
GO111MODULE=on gofmt -l -w -s ./pkg
GO111MODULE=on gofmt -l -w -s ./cmd
vet:
GO111MODULE=on go vet ./pkg/...
GO111MODULE=on go vet ./cmd/...
lint: install-golint
golint pkg/...
golint cmd/...
install-golint:
which golint || go install golang.org/x/lint/golint@latest
errcheck: install-errcheck
errcheck ./pkg/...
errcheck ./cmd/...
install-errcheck:
which errcheck || go install github.com/kisielk/errcheck@latest
check-all: fmt vet lint errcheck golangci-lint
golangci-lint: install-golangci-lint
golangci-lint --version
golangci-lint run -D errcheck -D structcheck
install-golangci-lint:
which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
build-container:
docker build -t $(DOCKER_IMAGE_NAME):$(VERSION) .
push-container:
docker push $(DOCKER_IMAGE_NAME):$(VERSION)