This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
84 lines (63 loc) · 1.97 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
SOURCEDIR=.
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
PACKAGE_PATH=$(shell go list -m)
COMMIT_SHA=$(shell git rev-parse HEAD)
VERSION_TAG=$(shell git describe --abbrev=0 --tags)
DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
LDFLAGS=-ldflags '-s -w -X $(PACKAGE_PATH)/cmd.commitSHA=$(COMMIT_SHA) -X $(PACKAGE_PATH)/cmd.version=$(VERSION_TAG) -X $(PACKAGE_PATH)/cmd.buildDate=$(DATE)'
BINARY=k8s-pixy-auth
.DEFAULT_GOAL: $(BINARY)
$(BINARY): $(SOURCES)
BUILD_OUTPUT=$(BINARY) $(MAKE) base-build
.PHONY: lint
lint:
@go vet $(PACKAGE_PATH)
@golint ./...
.PHONY: test
test:
@mkdir -p test-results/junit
go test -count=1 ./... # use count=1 to force not using the test cache
.PHONY: test-watch
test-watch:
@ginkgo watch ./...
.PHONY: cover
cover:
go test -v -cover -race -coverprofile cover.out ./...
go tool cover -html=cover.out -o cover.html
.PHONY: coveralls
coveralls: cover
go get golang.org/x/tools/cmd/cover
go get github.com/mattn/goveralls
go test -v -covermode=count -coverprofile=coverage.out
goveralls -coverprofile=cover.out -service=travis-ci -repotoken=$(COVERALLS_TOKEN)
.PHONY: fmt
fmt:
@gofmt -e -s -l -w $(shell find . -name "*.go")
.PHONY: base-build
base-build:
go build -o $(BUILD_OUTPUT) $(LDFLAGS) .
.PHONY: build-linux
build-linux:
GOOS=linux BUILD_OUTPUT=binaries/linux/$(BINARY) $(MAKE) base-build
.PHONY: build-windows
build-windows:
GOOS=windows BUILD_OUTPUT=binaries/windows/$(BINARY).exe $(MAKE) base-build
.PHONY: build-darwin
build-darwin:
GOOS=darwin BUILD_OUTPUT=binaries/darwin/$(BINARY) $(MAKE) base-build
.PHONY: build-all-platforms
build-all-platforms: build-linux build-windows build-darwin
.PHONY: install-tools
install-tools:
go get golang.org/x/lint/[email protected]
go get github.com/onsi/ginkgo/[email protected]
go get gotest.tools/[email protected]
.PHONY: install-modules
install-modules:
go mod download
.PHONY: echo-version
echo-version:
@echo $(VERSION_TAG)
.PHONY: package
package:
./scripts/package.sh