-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
77 lines (62 loc) · 1.7 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
VERSION ?= $(shell ./hack/get_version_from_git.sh)
FLAVOR ?= "Community"
LDFLAGS = -X github.com/trento-project/runner/version.Version="$(VERSION)"
LDFLAGS := $(LDFLAGS) -X github.com/trento-project/runner/version.Flavor="$(FLAVOR)"
ARCHS ?= amd64 arm64 ppc64le s390x
DEBUG ?= 0
ifeq ($(DEBUG), 0)
LDFLAGS += -s -w
GO_BUILD = CGO_ENABLED=0 go build -o trento-runner -ldflags "$(LDFLAGS)" -trimpath
else
GO_BUILD = CGO_ENABLED=0 go build -o trento-runner -ldflags "$(LDFLAGS)"
endif
.PHONY: default
default: clean mod-tidy fmt vet-check test build
.PHONY: clean
clean: clean-binary
.PHONY: clean-binary
clean-binary:
go clean
rm -rf build
.PHONY: mod-tidy
mod-tidy:
go mod tidy
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: vet-check
vet-check:
go vet ./...
.PHONY: test
test:
GIN_MODE=test go test -v -p 1 ./...
.PHONY: build
build: trento-runner
trento-runner:
$(GO_BUILD)
.PHONY: cross-compiled $(ARCHS)
cross-compiled: $(ARCHS)
$(ARCHS):
@mkdir -p build/$@
GOOS=linux GOARCH=$@ $(GO_BUILD) -o build/$@/trento
.PHONY: fmt-check
fmt-check:
gofmt -l .
[ "`gofmt -l .`" = "" ]
.PHONY: generate
generate:
ifeq (, $(shell command -v mockery 2> /dev/null))
$(error "'mockery' command not found. You can install it locally with 'go install github.com/vektra/mockery/v2'.")
endif
ifeq (, $(shell command -v swag 2> /dev/null))
$(error "'swag' command not found. You can install it locally with 'go install github.com/swaggo/swag/cmd/swag'.")
endif
go generate ./...
.PHONY: full-check
full-check: generate vet-check test
.PHONY: test-coverage
test-coverage: build/coverage.out
build/coverage.out:
@mkdir -p build
GIN_MODE=test go test -cover -coverprofile=build/coverage.out ./...
go tool cover -html=build/coverage.out