forked from ortuman/jackal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (53 loc) · 1.38 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
.POSIX:
.SUFFIXES:
GOFILES!=find . -name '*.go'
GOLDFLAGS =-s -w -extldflags $(LDFLAGS)
.PHONY: install
install:
@go install -ldflags="-s -w" github.com/sxmpp/jackal
.PHONY: install-tools
install-tools:
@env GO111MODULE=off go get -u \
golang.org/x/lint/golint \
golang.org/x/tools/cmd/goimports
.PHONY: fmt
fmt: install-tools
@echo "Checking go files format..."
@GOIMP=$$(for f in $$(find . -type f -name "*.go" ! -path "./.cache/*" ! -path "./vendor/*" ! -name "bindata.go") ; do \
goimports -l $$f ; \
done) && echo $$GOIMP && test -z "$$GOIMP"
go.sum: $(GOFILES) go.mod
go mod tidy
jackal: $(GOFILES) go.mod go.sum
@echo "Building binary..."
@go build\
-trimpath \
-o $@ \
-ldflags "$(GOLDFLAGS)"
.PHONY: build
build: jackal
.PHONY: test
test:
@echo "Running tests..."
@go test -race $$(go list ./...)
.PHONY: coverate
coverage:
@echo "Generating coverage profile..."
@go test -race -coverprofile=coverage.txt -covermode=atomic $$(go list ./...)
.PHONY: vet
vet:
@echo "Searching for buggy code..."
@go vet $$(go list ./...)
.PHONY: lint
lint: install-tools
@echo "Running linter..."
@golint $$(go list ./...)
.PHONY: dockerimage
dockerimage:
@echo "Building binary..."
@env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w"
@echo "Building docker image..."
@docker build -f dockerfiles/Dockerfile -t sxmpp/jackal .
.PHONY: clean
clean:
@go clean